Table of Contents Previous topic Next topic
CROSS ASSEMBLER->Assembler Macros->Dummy Labels
If you include an ordinary label in the macro definition then, except where it is being defined using the SET directive, it will only be possible to call that macro once. A second call will generate a duplicate label error. Dummy labels overcome this problem. Dummy labels are \.0 to \.9 and \.A to \.Z (or \.a to \.z since the dummy labels are case insensitive). These symbols are used within the macro definition in place of ordinary labels, and when the macro is expanded the assembler replaces them with labels .00000, .00001, .00002 etc. Unique labels are therefore generated each time the macro is called.
The following example illustrates the use of dummy labels.
Firstly the source code listing:
NAM MACXAMPL
TTL *** Dummy Labels ***
LIST
SYM
MEX
ORG 6000H
* This is the macro definition:
macxampl MACR
\.0 LDA \0
LDA \1
BNE \.0
ENDM
* This is the macro call:
macxampl $60,$52
And now the listing generated during assembly:
1 NAM MACXAMPL
2 TTL *** Dummy Labels ***
3 LIST
4 SYM
5 MEX
6 6000 ORG 6000H
7
8 * This is the macro definition:
9
10 macxampl MACR
11 \.0 LDA \0
12 LDA \1
13 BNE \.0
14 ENDM
15
16 * This is the macro call:
17
18 macxampl $60,$52 call:
6000 96 60 .00000 LDA $60
6002 96 52 LDA $52
6004 26 FA BNE .00000
Assembly complete
Total bytes generated: 6
0 errors
0 warnings
Symbol table:
.00000 6000
1 symbols.