XC2200 Derivatives
System Units (Vol. 1 of 2)
Memory Organization
User’s Manual
3-14
V2.1, 2008-08
MemoryX2K, V1.3
3.5
System Stack
The system stack may be defined anywhere within the XC2200’s memory areas
(including external memory).
For all system stack operations the respective stack memory is accessed via a 24-bit
stack pointer. The Stack Pointer (SP) register provides the lower 16 bits of the stack
pointer (stack pointer offset), the Stack Pointer Segment (SPSEG) register adds the
upper 8 bits of the stack pointer (stack segment). The system stack grows downward
from higher towards lower locations as it is filled. Only word accesses are supported to
the system stack.
Register SP is decremented before data is pushed on the system stack, and
incremented after data has been pulled from the system stack. Only word accesses are
supported to the system stack.
By using register SP for stack operations, the size of the system stack is limited to
64 KBytes. The stack must be located in the segment defined by register SPSEG.
The stack pointer points to the latest system stack entry, rather than to the next available
system stack address.
A stack overflow (STKOV) register and a stack underflow (STKUN) register are provided
to control the lower and upper limits of the selected stack area. These two stack
boundary registers can be used both for protection against data corruption.
For best performance it is recommended to locate the stack to the DPRAM or to the
DSRAM. Using the DPRAM may conflict with register banks or MAC operands.