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
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...