link
Link and allocate
Pushes an address register onto the stack, copies a7 into it, then adds a signed displacement to a7.
Used in
- bsr, rts, link and unlkM68K assembly
- Stack arguments and a stack frameM68K assembly
- Recursion: factorial and FibonacciM68K assembly
XNZVC –––––
- Changes no flag
Forms
link ,
68020 only
These forms require the 68020. Select opt p=68020 before any code or data.
link ,Size .wlink ,Size .l
Operands
Use a negative displacement to reserve space for local values.
On the 68020, link.w is the same instruction as link, and link.l accepts a signed 32-bit displacement. On the 68000 and 68010, write link without a size suffix.
* --- Create stack frame with 8 bytes of local space ---
link a6, #-8
; a6 now points to the old a6 (frame pointer)
; sp = a6 - 8 (room for locals)
move.l #$1234, -4(a6) ; local variable 1
move.l #$5678, -8(a6) ; local variable 2
unlk a6 ; restore sp and a6