0% found this document useful (0 votes)
108 views1 page

Macro Calls Within A Macro: Saves The System State

Macro calls can be successfully processed within other macros. For example, a PUTMSG macro calls a PUTC macro within it to output characters. Both macros save the system state before executing and restore it afterwards. While nested, the outer macro's $ system qualifier is resumed after the inner macro finishes, allowing separate qualifier values for chained macro calls.

Uploaded by

Mohamed Med
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views1 page

Macro Calls Within A Macro: Saves The System State

Macro calls can be successfully processed within other macros. For example, a PUTMSG macro calls a PUTC macro within it to output characters. Both macros save the system state before executing and restore it afterwards. While nested, the outer macro's $ system qualifier is resumed after the inner macro finishes, allowing separate qualifier values for chained macro calls.

Uploaded by

Mohamed Med
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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).

You might also like