159/317
6 - STMicroelectronics Programming Tools
ments a word variable. Unlike the example above, the low byte is incremented, then we test if
it is zero. If yes, we increment the high byte:
IncWord MACRO LowByte, HiByte
inc LowByte
jrne NoIncHigh
inc HiByte
NoIncHigh:
MEND
this macro expands correctly when invoked:
63 IncWord CounterLo, CounterHi
63 0013 3C00 inc CounterLo
63 0015 R 2602 jrne NoIncHigh
63 0017 3C01 inc CounterHi
63 NoIncHigh:
But if we attempt to expand this macro one more time, we get an error. This is because the
label
NoIncHigh is also defined in the second expansion, which makes a duplicated identifier.
Obviously, a macro that can be expanded only once is not very useful.
To get rid of this difficulty, the macro language allows you to define local symbols. When a
symbol is defined as local to the macro, it will be automatically replaced by a special symbol,
that is unique for each expansion. So, the following, slightly modified macro:
IncWord MACRO LowByte, HiByte
local NoIncHigh
inc LowByte
jrne NoIncHigh
inc HiByte
NoIncHigh:
MEND
when expanded twice, produces the following text:
65 IncWord CounterLo, CounterHi
65
65 0013 3C00 inc CounterLo
65 0015 R 2602 jrne LOC0
65 0017 3C01 inc CounterHi
65 LOC0:
66 0019
67 IncWord CounterLo, CounterHi