Chapter
S.
Macros
SBMAC
MACRO
SBMAC
MACRO
CALL
SUBR
;;REDEFINITION OF
SBMAC
ENDM
CALL
SUBR
LINK:
IMP
DUN
SUBR:
RET
DUN:
ENDM
Notice that both versions of
SBMAC
contain CALL
SUBR
instructions. This
is
necessary to provide a return
address at the end of the
SUBR
routine. The jump instruction labelled
LINK
is
required to prevent the SUBR
subroutine from executing a return to itself. Notice that the return address for the second CALL SUBR
instruction would
be
SUBR
if
the jump instruction were omitted. The
IMP
DUN
instruction simply transfers
control past the end
of
the subroutine.
NOTE
The assembler allows the
use
of a source line consisting
only of a label. Such a label
is
assigned to the next source
line
for
which code or data
is
generated. Notice that
neither code nor data
is
generated for
an
ENDM
directive,
so
the label
DUN
is
assigned to whatever instruction follows
the
ENDM
directive. This construct
is
required because the
ENDM
directive itself may not be given a label.
Method #2: Conditional Assembly
The second method for altering the expansion of the
SBMAC
macro
uses
conditional assembly. I n this example,
a switch (FIRST)
is
set TRUE just before the first
call
for
SBMAC.
SBMAC
is
defined
as
follows:
TRUE
FALSE
FIRST
SBMAC
FIRST
LINK:
SUBR:
DUN:
EQU
EQU
SET
MACRO
CALL SUBR
IF
SET
JMP
RET
ENDIF
ENDM
OFFH
0
TRUE
FIRST
FALSE
DUN
5·19