Texas Instruments TMS320C2XX Calculator User Manual


 
Program-Address Generation
5-5
Program Control
PSHD and POPD. These instructions allow you to build a stack in data
memory for the nesting of subroutines or interrupts beyond eight levels.
The PSHD instruction pushes a data-memory value onto the top of the
stack. The POPD instruction pops a value from the top of the stack to data
memory.
Whenever a value is pushed onto the top of the stack (by an instruction or by
the address-generation logic), the content of each level is pushed down one
level, and the bottom (eighth) location of the stack is lost. Therefore, data is
lost (stack overflow occurs) if more than eight successive pushes occur before
a pop. Figure 5–2 shows a push operation.
Figure 5–2. A Push Operation
Before Instruction After Instruction
Accumulator Accumulator
or memory 7h or memory 7h
location location
2h 7h
5h 2h
Stack 3h Stack 5h
0h 3h
12h 0h
86h 12h
54h 86h
3Fh 54h
Pop operations are the reverse of push operations. A pop operation copies the
value at each level to the next higher level. Any pop after seven sequential
pops yields the value that was originally at the bottom of the stack because,
by then, the bottom value has been copied upward to all of the stack levels.
Figure 5–3 shows a pop operation.