increment addressing mode in macro

Thread Starter

snr

Joined Mar 14, 2016
6
I try to write my own clear which clears a number of locations starting with an address by using a macro. i.e. clear $1200 5 it clears content of from $1200 to $1205. However, I can't do like in macro
Code:
;The code section works well, The issue I can't integrate it in macro
LDX $1200
CLR 1, X+
In macro try
Code:
clear MACRO
      LDX \1
      LDAB #\2
\@SONERLOOP
      CLR 1, x+ ; it will clear current address then increment adress  one more not content (first issue incrementing adress)
      DECB #\2 ; I have also tried DEC to decrement counter but not work (second issue decrementing counter)
      BNE \@SONERLOOP
      ENDM
How can it be fixed?
 

Papabravo

Joined Feb 24, 2006
21,225
It would help immensely if you could identify the assembler that you are using to construct this macro. Unfortunately each assembler does these things just a bit differently. It is not a case of learning one assembler and knowing them all. Here you have to learn each one in excruciating detail.
 

JohnInTX

Joined Jun 26, 2012
4,787
What errors does it report? I don't know the syntax for your assembler but in lines 3 and 4 of the macro, it looks like you are using parameters. In every assembler I know of, you have to specify those in the macro definition i.e.
Clear MACRO (target,count)
LDX \target
LDAB #\count
ENDM
The macro expansion is a simple text substitution so invoking
Clear ($1200,5)
expands to
LDX $1200
LDAB #5

Do you have the assembler reference to clear up the syntax for the 68HC12? Post a link to it if so.
 

Thread Starter

snr

Joined Mar 14, 2016
6
It would help immensely if you could identify the assembler that you are using to construct this macro. Unfortunately each assembler does these things just a bit differently. It is not a case of learning one assembler and knowing them all. Here you have to learn each one in excruciating detail.
thanks for the advise. that is hcs12
 

Thread Starter

snr

Joined Mar 14, 2016
6
What errors does it report? I don't know the syntax for your assembler but in lines 3 and 4 of the macro, it looks like you are using parameters. In every assembler I know of, you have to specify those in the macro definition i.e.
Clear MACRO (target,count)
LDX \target
LDAB #\count
ENDM
The macro expansion is a simple text substitution so invoking
Clear ($1200,5)
expands to
LDX $1200
LDAB #5

Do you have the assembler reference to clear up the syntax for the 68HC12? Post a link to it if so.
I can't use increment addressing with argument CLR 1, \1+ erroring register expected but argument is already register. HCS12 instruction reference manual pdf link: http://www.nxp.com/files/microcontrollers/doc/ref_manual/CPU12RM.pdf
 

Papabravo

Joined Feb 24, 2006
21,225
thanks for the advise. that is hcs12
My hcs12 assembler does not have macros like that. Who is the vendor of your particular assembler?

What you are trying to do is called "token pasting". What you want to do is concatenate the expansion of the argument \1, which should be a register name and the + operator. The assembler might need a delimiter between the \1 and the + or maybe some brackets around the \1. Some manual digging might help.
 

atferrari

Joined Jan 6, 2004
4,769
The micro in question, does it have indirect addressing mode?

Clearing RAM memory, which I do upfront at startup, is certainly simple in the PIC 18F family.
 

Thread Starter

snr

Joined Mar 14, 2016
6
The micro in question, does it have indirect addressing mode?

Clearing RAM memory, which I do upfront at startup, is certainly simple in the PIC 18F family.
no there are only inherent, immediate, direct extended, relative modes.
 

Thread Starter

snr

Joined Mar 14, 2016
6
My hcs12 assembler does not have macros like that. Who is the vendor of your particular assembler?

What you are trying to do is called "token pasting". What you want to do is concatenate the expansion of the argument \1, which should be a register name and the + operator. The assembler might need a delimiter between the \1 and the + or maybe some brackets around the \1. Some manual digging might help.
I'm using codewarrior and I have read the macro usage in Mazidi's HCS12 book. I try to make my own clear. Like

Clear: “clear <address> <numberOfLocations>”

Clears a number of locations starting with an address. For instance: clear $1200 12

Then writes zero to 12 locations between $1200 and $120B.

Also, I wonder that there is another way to use macro. Can I write it in other way?
 

Papabravo

Joined Feb 24, 2006
21,225
I'm using codewarrior and I have read the macro usage in Mazidi's HCS12 book. I try to make my own clear. Like

Clear: “clear <address> <numberOfLocations>”

Clears a number of locations starting with an address. For instance: clear $1200 12

Then writes zero to 12 locations between $1200 and $120B.

Also, I wonder that there is another way to use macro. Can I write it in other way?
Not familiar with Code Warrior so I can't with the specific problem. I do understand what you're trying to do, but I'll need to research the specifics of the Macro Processor.
 
Top