3.3.10.3 Stack Pointer Overflow
The Stack Pointer Limit (SPLIM) register specifies the size of the stack buffer. SPLIM is a
32-bit register, but SPLIM[1:0] is fixed to ‘00
’ because all stack
operations must be long word-aligned.
The stack overflow check is not enabled until a long word write to SPLIM occurs. After this, it
can only be disabled by a device Reset. All Effective Addresses (EAs), generated using
W15 as a source or destination, are compared against the value in SPLIM. If Effective
Addresses (EAs) exceed the contents of the SPLIM register, and a PUSH operation
is performed, a stack error trap occurs on a subsequent PUSH operation. For
example, if it is desirable to cause a stack error trap when the stack grows beyond
address 0x5000 in RAM, initialize the SPLIM with the value 0x4FFC.
Note: A stack error trap can be caused by any instruction that uses
the contents of the W15 register to generate an Effective Address (EA). Therefore,
if the contents of W15 are greater than the contents of the SPLIM register by a
value of four, and a
CALL
instruction is executed, or if an
interrupt occurs, a stack error trap is generated.If stack overflow checking is enabled, a stack error trap also occurs if the W15 Effective Address calculation wraps over the end of data space.
A pre/post inc/dec operation is performed on W15 that results in EA[1:0] != 2’b00 (i.e., not long word aligned). This will detect byte and word pre/post inc/dec operations that are otherwise considered aligned but would result in a misaligned Stack Pointer.
Note: A write to the SPLIM should not be followed by an indirect read
operation using W15.