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

%nitems 3

The document describes a macro called SWAPR that swaps the values of two registers. The macro uses a third temporary register to store one of the values during the swap. If more than two arguments are passed to the macro, it performs an optimized swap using direct register-to-register moves, otherwise it uses memory to store the temporary value.

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)
67 views1 page

%nitems 3

The document describes a macro called SWAPR that swaps the values of two registers. The macro uses a third temporary register to store one of the values during the swap. If more than two arguments are passed to the macro, it performs an optimized swap using direct register-to-register moves, otherwise it uses memory to store the temporary value.

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

For example, given the macro definition

MACRO
&LABL SWAPR &ONE, &TWO, &TEMP
IF (%NITEMS() GT 2)
&LABL ST→&ONE &TEMP
RMO &TWO, &ONE
LD→&TWO &TEMP
ELSE
&LABL ST→&ONE $TEMP
RMO &TWO, &ONE
LD→&TWO $TEMP
J $NEXT
$TEMP RESW 1
SNEXT RESW 0
ENDIF
MEND
%NITEMS() = 3

then the call


SWAPR S, T, SWAPAREA
has the expansion

. SWAPR S, T, SWAPAREA
STA SWAPAREA
RMO S,T
LDT SWAPAREA
%NITEMS() = 2
and the call (first macro call, so $ → $AA)
SWAPR S, T
has the expansion

. SWAPR S, T
STA $AATEMP
RMO S,T
LDT $AATEMP
J $AANEXT
$AATEMP RESW 1
$AANEXT RESW 0

You might also like