Motorola M68000 User's Guide Page 106

  • Download
  • Add to my manuals
  • Print
  • Page
    / 256
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 105
92 Assembly Language Programming for the 68000 Family
To retrieve elements from the stack, we use a MOVE instruction with ad
dress register indirect with postincrement addressing. The general form
of this addressing mode is (An)+ and (SP)+ for the stack pointer. The
use of this addressing mode is the reverse of register indirect with pre
decrement addressing and results in popping the topmost value off the
stack. The data element pointed to by the stack pointer, SP, is obtained
from the stack and placed into the destination operand of the MOVE
instruction. The stack pointer is then incremented by 2 or 4. If we perform a
MOVE.W (SP)+,D0
on the above stack, the value 5555 is placed in the DO register. The stack
then looks like this:
HIGH ADDRESS
D0 <
--
5555
LOW ADDRESS
Notice that the value 5555 has not been changed on the stack. However, it
is below the stack pointer and is therefore no longer relevant. You might
be tempted to try to access this value by modifying the stack pointer
directly, perhaps with a SUB instruction. This is not a good idea. In fact, if
hardware interrupts are enabled, it might be changed without your being
able to predict just when (hardware interrupts will be covered in Chapter
12). Always regard data below the stack pointer as lost forever.
What happens if we pop one too many elements from the stack? Since
SP-
1234
5555
Page view 105
1 2 ... 101 102 103 104 105 106 107 108 109 110 111 ... 255 256

Comments to this Manuals

No comments