Atari Logo
Atari Computer

Hauptseite -
Welches System? -
Hardware -
Software -
Emulatoren -
Internet
MausNet
Programmieren
Verweise
Über

Assembler

Previous Next TOC

NAME LINK -- Create local stack frame
SYNOPSIS
LINKAn,#<data>
Size = (Word)
Size = (Word, Long) (68020+)
FUNCTION This instruction saves the specified address register onto the stack, then places the new stack pointer in that register. It then adds the specificed immediate data to the stack pointer. To allocate space on the stack for a local data area, a negative value should be used for the second operand.
The use of a local stack frame is critically important to the programmer who wishes to write re-entrant or recursive functions. The creation of a local stack frame on the MC680x0 family is done through the use of the LINK and UNLK instructions. The LINK instruction saves the frame pointer onto the stack, and places a pointer to the new stack frame in it. The UNLK instruction restores the old stack frame. For example:
   link a5,#-8 ; a5 is chosen to be the frame
               ; pointer. 8 bytes of local stack
               ; frame are allocated.
...
   unlk a5     ; a5, the old frame pointer, and the
               ; old SP are restored.
Since the LINK and UNLK instructions maintain both the frame pointer and the stack pointer, the following code segment is perfectly legal:
   link    a5,#-4
   movem.l d0-a4,-(sp)
   pea     (500).w
   move.l  d2,-(sp)
   bsr.b   Routine
   unlk    a5
   rts
FORMAT For Word size:
1514131211109876543210
0100111001010REGISTER
16 BITS OFFSET (d)
For Long size:
1514131211109876543210
0100111001010REGISTER
32 BITS OFFSET (d) (16 bits of lower weight)
32 BITS OFFSET (d) (16 bits of upper weight)
"REGISTER" indicates the number of address register.
OFFSET is a signed value, generally negative, which enables to move the stack pointer.
RESULT None.


Best viewed with any browser English version not yet available.

Änderungen und Irrtümer vorbehalten. Letzte Änderung:
14 September 2001.
Home - Mail an den Webmaster - Impressum