Macro Calls Within a Macro
There is no reason that the macro facility cannot successfully process
a macro call within a macro. For example,
MACRO
&TOP PUTMSG &MSG, &DEV, &LEN
&TOP STA $SAVA
STX $SAVX
CLEAR X
$LOOP PUTC ((&MSG,X)), &DEV
TIX &LEN
JLT $LOOP
LDA $SAVA
LDX $SAVX
J $NEXT
$SAVA RESW 1
$SAVX RESW 1
$NEXT RESW 0
MEND
Observations
• The PUTMSG macro (and the PUTC macro for that matter)
generate code that first saves the system state (by saving the
registers it works with), then restores the system state upon
exit. Strictly speaking, this is not necessary (the programmer
could do it), but it is advisable since the whole idea of using
macros is to save the programmer work.
• The value of the $ system qualifier for a PUTMSG macro
expansion is resumed after the PUTC expansion contained
within it is completed (although PUTC gets its own $
system qualifier value). This means that if PUTMSG is used
twice in succession by a programmer, then if for the first
expansion the $ system qualifier has value $AC, on the 2nd
call the $ system qualifier for PUTMSG will have the value
$AE since there was an intervening expansion of PUTC
(which gets the $ system qualifier value of $AD).