Motorola M68000 User's Guide Page 125

  • Download
  • Add to my manuals
  • Print
  • Page
    / 256
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 124
Subroutines 111
HOVEA.L A6,SP
RTS
All of these operations are made simpler by using the LINK and
UNLK instructions. These have the added advantage that the register
used as the frame pointer is automatically saved and restored. The LINK
instruction has the general form
LINK A n r#<<3i6placement>
where <displacement> is the value to be added to the stack pointer.
Normally a negative displacement is used to allocate locals. The LINK
instruction first pushes An on the stack, and then loads An with the
updated value. Finally, the displacement is added to SP. The result will
look almost like our example above, except that An will be on the stack.
Here is what a frame will look like after a LINK instruction.
High
Lou
arguments
return address
saved fin
locals
temporaries
fin (Frame Pointer)
SP
Naturally, the offsets to the parameters are slightly different. The first
parameter is now found at 8(An) rather than 4(An).
The unlink instruction, UNLK, merely loads SP from An and pops the
saved An from its location on the stack. As a final example, let’s write a
subroutine, GAMMA, that uses LINK and UNLK and requires 100 bytes
of local storage.
Page view 124
1 2 ... 120 121 122 123 124 125 126 127 128 129 130 ... 255 256

Comments to this Manuals

No comments