Example 1:
A macro, which can be used to define macros with arbitrary names, may look as follows:DEFINE MACRO MACNAME MACNAME MACRO DB 'I am the macro &MACNAME.' ENDM ENDM
In order not to overload the example with “knowhow”, the nested macro only introduces itself kindly with a suitable character string in ROM. The callDEFINE Obiwanwould define the macroObiwan MACRO DB 'I am the macro Obiwan.' ENDM
and the callDEFINE Skywalkerwould define the following macro:Skywalker MACRO DB 'I am the macro Skywalker.' ENDM
Example 2:
A macro is to insert a variable number of NOPs into the program. For this, a macro with a nested REPT block seems to be best-suited:REPEAT MACRO NOPS REPT NOPS NOP ENDM ENDMThe macro callREPEAT 4results in something like that:Line I Addr Code Source 9+ 1 N 0004 REPT 4 10+ 1 NOP 11+ 1 ENDM 12+ 2 0000 00 NOP 13+ 2 0001 00 NOP 14+ 2 0002 00 NOP 15+ 2 0003 00 NOP