Calling Standard Macros
The following defines a macro named BMOVE that takes three arguments: source, destination, and count. The macro produces code that copies any number of bytes from one part of memory to another.
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
To call this macro, specify the macro name and the list of parameters. For example, the above macro may be called as follows:
BMOVE array1, array2, 10
The macro is expanded as:
MOV R2,#10
MOV R1,#array1
MOV R0,#array2
??0000: MOV A,@R1
MOV @R0,A
INC R0
INC R1
DJNZ R2,??0000
Note
- The above example produces assembly errors because the source file includes no segment definitions.
- The GEN and GENONLY directives may be used to include macro definition and macro calls in the assembler listing file.