rtd
Return and deallocate
Returns from a subroutine and removes arguments from the stack.
68010 and 68020 only: select opt p=68010 before any code or data
XNZVC –––––
- Changes no flag
Forms
rtd
Operands
#imm- A signed 16-bit number of bytes added to the stack pointer once the return address is popped: the size of the arguments, for example
#8. More
It pops the return address, as rts does, then adds a signed 16-bit byte count to the stack pointer. If the caller pushed 8 bytes of arguments, rtd #8 removes them before returning, so the caller needs no stack adjustment after the call.
opt p=68010
* --- A subroutine that removes its own arguments ---
move.l #5, -(sp) ; first argument
move.l #7, -(sp) ; second argument
bsr add_args
move.l d0, d1 ; d1 = 12, and sp is back where it was before the pushes
bra END
add_args:
move.l 4(sp), d0 ; the second argument, just above the return address
add.l 8(sp), d0 ; plus the first
rtd #8 ; return, then take the 8 bytes of arguments off the stack
END: