System and User Stack Management
6-30
6.10.2 Stacks
Stacks can be built from low to high memory or high to low memory. Two cases
for each type of stack are shown. Stacks can be built using the preincrement/
decrement and postincrement/decrement modes of modifying the auxiliary
registers (AR). Stack growth from high-to-low memory can be implemented in
two ways:
CASE 1:
Stores to memory using *– – AR
n to push data onto the stack and
reads from memory using *AR
n ++ to pop data off the stack.
CASE 2:
Stores to memory using *AR
n – – to push data onto the stack and
reads from memory using * ++ AR
n to pop data off the stack.
Figure 6–10 illustrates these two cases. The only difference is that in case 1,
the AR always points to the top of the stack, and in case 2, the AR always points
to the next free location on the stack.
Figure 6–10. Implementations of High-to-Low Memory Stacks
Top of stack
Low memory
High memory
(Free)
Bottom of stack
AR
n
Top of stack
Low memory
High memory
(Free)
Bottom of stack
Case 1
Case 2
AR
n
→
→
Stack growth from low-to-high memory can be implemented in two ways:
CASE 3:
Stores to memory using *++ AR
n to push data onto the stack and
reads from memory using *AR
n – – to pop data off the stack.
CASE 4:
Stores to memory using *AR
n ++ to push data onto the stack and
reads from memory using *– – AR
n to pop data off the stack.
Figure 6–11 shows these two cases. In case 3, the AR always points to the top
of the stack. In case 4, the AR always points to the next free location on the stack.