English
Language : 

45111 Datasheet, PDF (165/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
15 Appendix E: SX Data Sheet
15.2.18 The Stack
The stack is an area of memory used to remember where to return to once a subroutine is complete. The
stack is eight levels deep with the Stack Extend (STACKX) option set and two levels deep by default
(On SX48/52 devices, the stack is always eight levels deep). That means it can remember the return addresses
for subroutines nested up to eight levels. The following explanation assumes that the SX has the Stack
Extend option selected. The stack is capable of two operations; push and pop. The stack behaves like a
plate holder in a salad buffet. A push is similar to placing a plate on the top of the stack and a pop is
similar to removing a plate from the top of the stack.
15.2.19 The Push
When a subroutine is called, the return address is pushed onto the stack. Specifically, each address in
the stack is moved to the next lower level in order to make room for the new address to be stored.
Stack 1 gets the value that was in the program counter. Stack 8 is overwritten with what was in Stack 7.
Consequently, the previous contents of Stack 8 are lost forever.
Figure 34 - The Push
PC<10:0>
Stack 1
Stack 2
Stack 3
Stack 4
Stack 5
Stack 6
Stack 7
Stack 8
SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc. • Page 165