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 DUMXAMPL
TTL *** Dummy Labels ***
LIST
SYM
MEX
ORG 6000H
; This is the macro definition:macxampl MACR
MOV\0 A,@R1
MOV\1 A,@A+DPTR
\.0 A\2 A,#34H
JNZ \.0
ENDM
; This is the macro call:
macxampl X,C,NL
And now the listing generated during assembly: 1 NAM DUMXAMPL
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 MOV\0 A,@R1
12 MOV\1 A,@A+DPTR
13 \.0 A\2 A,#34H
14 JNZ \.0
15 ENDM
16
17 ; This is the macro call:
18
19 macxampl X,C,NL
6000 E3 MOVX A,@R1
6001 93 MOVC A,@A+DPTR
6002 54 34 .00000 ANL A,#34H
6004 70 FC JNZ .00000
Assembly complete
Total bytes generated: 6
0 errors
0 warnings