Macros can be nested, i.e., a macro may invoke another macro.
When macros are expanded, the nesting level is shown on the
left of each expanded statement.
Example: Let us write a macro to copy a string
using two other macros to save and restore registers.
SAVE_REGS MACRO R1, R2, R3
PUSH R1
PUSH R2
PUSH R3
ENDM
RESTORE_REGS MACRO R1, R2, R3
POP R1
POP R2
POP R3
ENDM
COPYS MACRO SOURCE, DESTINATION, LENGTH
SAVE_REGS CX, SI, DI
LEA SI, SOURCE
LEA DI, DESTINATION
CLD
MOV CX, LENGTH
REP MOVSB
RESTORE_REGS DI, SI, CX
ENDM
Example: Show the code that the assembler will
generate when it encounters the macro invocation
COPYS STRING1, STRING2, 15.
PUSH CX
PUSH SI
PUSH DI
LEA SI, STRING1
LEA DI, STRING2
CLD
MOV CX, 15
REP MOVSB
POP DI
POP SI
POP CX
 Recursive Macros
A macro may invoke itself; such macros are called recursive macros.