Ell
To keep data on the system stack aligned properly, data entry on the stack is
restricted so that data is always put in the stack on a word boundary. Thus, byte
data is pushed on or pulled from the system stack in the high-order half of the
word; the low-order half is unchanged.
3.7.2 User Stacks
The user can implement stacks with the address register indirect with
postincrement and predecrement addressing modes. With address register An
(n
=
0 to 6), the user can implement a stack that is filled either from high to low
memory or from low to high memory. Important considerations are as follows:
• Use the predecrement mode to decrement the register before its contents
are used as the pointer to the stack.
• Use the postincrement mode to increment the register after its contents are
used as the pointer to the stack.
• Maintain the SP correctly when byte, word, and long-word items are mixed
in these stacks.
To implement stack growth from high to low memory, use -(An) to push data on
the stack, (An)+ to pull data from the stack.
For this type of stack, after either a push or a pull operation, register An points to
the top item on the stack. This scheme is illustrated as follows
LOW MEMORY
(FREE)
An
~
TOP OF STACK
' 7
·
l
·
L
·
BOTTOM OF STACK
HIGH MEMORY
To implement stack growth from low to high memory, use (An) +to push data on
the stack, -(An) to pull data from the stack.
In this case, after either a push or pull operation, register An points to the next
available space on the stack. This scheme is illustrated as follows:
MOTOROLA
3-20
DATA ORGANIZATION AND
CPU32 REFERENCE MANUAL
ADDRESSING CAPABILITIES