Subroutines 115
ADDQ.L
MOVEA.L
ADD.W
MOVEM.L
RTS
#4/AO
(AO),A1
(Al)/DO
(SP)+/A0-A1
-> 2ND. ARG
RESTORE REGS
12
13
14.
15.
ARGLST :DC.L A
DC.L B
A: DC.W
I
B;
DC.W 1
11. The return address is pushed onto the stack, and control transfers to
the location specified by the operand of the JSR.
The return address is popped from the stack, and control transfers to
the return address.
There is no matching pop to the push of DO onto the stack, and there
fore the RTS instruction will not obtain the correct return address.
The DO register is not saved and restored by the procedure.
16.
17.
SKIPLINES: MOVE.L DO(SP) SAVE DO
NEXT:
JSR NEWLINE
OUTPUT NEWLINE
SUBQ.L #1/DO
DECREMENT COUNT
BNE NEXT
BRANCH IF MORE
MOVE.L (SP)+/D0
RTS
RESTORE DO
caller can use an
ADD instruction
to register SP.
PAIRS: MOVE.L
DO/-(SP)
SAVE DO
MOVE.L
12(SP)/DO
GET VAL1
JSR
OUTDEC
OUTPUT
MOVE.B
#' '
BLANK
JSR
PUTC OUTPUT BLANK
MOVE.L
8 (SP)/DO GET VAL2
JSR
OUTDEC OUTPUT
JSR NEWLINE
MOVE.L
RTS
(SP) +,D0 RESTORE DO
18.
Note that VAL2 is at 8(SP) because of the extra 4 bytes used when
we saved DO on the stack. VAL1 is at 12(SP) because it was pushed
first.
With call by value, a copy of the data is placed on the stack. With
call by reference, the address of the data is placed on the stack.
19.
PEA ALPHA
Comments to this Manuals