Local Symbols
Standard macros may include local labels that are the targets of branches.
Fixed label names cause errors if the macro is called more than once. This happens because the same label name may be used only once in a source file. This problem may be solved by using local symbols. Local macro symbols are replaced with a unique, sequentially-numbered label that increments each time the macro is invoked.
The following example shows how the local label lab is created using the LOCAL statement in the macro definition.
BMOVE MACRO src, dst, cnt
LOCAL lab
MOV R2,#cnt
MOV R1,#src
MOV R0,#dst
lab: MOV A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,lab
ENDM
Note
- Local labels must be declared in the line immediately following the macro definition.
- Up to 16 local labels may be defined in a macro.