
DocID13284 Rev 2
77/564
UM0404
The central processing unit (CPU)
Fatal error indication
treats the stack overflow as a system error through the associated
trap service routine. Under these circumstances data in the bottom of the stack may have
been overwritten by the status information stacked upon servicing the stack overflow trap.
Automatic system stack flushing
allows to use the system stack as a 'Stack Cache' for a
bigger external user stack. In this case register STKOV should be initialized to a value,
which represents the desired lowest Top of Stack address plus 12 according to the selected
maximum stack size. This considers the worst case that will occur when a stack overflow
condition is detected just during entry into an interrupt service routine. Then, six additional
stack word locations are required to push IP, PSW and CSP for both the interrupt service
routine and the hardware trap service routine.
More details about the stack overflow trap service routine and virtual stack management are
given in
Section 27: System programming on page 545
3.4.12 The
stack
underflow pointer STKUN
This non-bit-addressable register is compared against the SP register after each operation,
which pops data from the system stack (POP and RET instructions) and after each addition
to the SP register. If the content of the SP register is greater than the content of the STKUN
register, a stack underflow hardware trap will occur.
Since the least significant bit of register STKUN is tied to '0' and bits 15 through 12 are tied
to '1' by hardware, the STKUN register can only contain values from F000h to FFFEh.
STKUN (FE16h / 0Bh)
SFR
Reset Value:FC00h
The Stack Underflow Trap (entered when (SP) > (STKUN)) may be used in two different
ways:
•
Fatal error indication
treats the stack underflow as a system error through the
associated trap service routine.
•
Automatic system stack refilling
allows to use the system stack as a 'Stack Cache'
for a bigger external user stack. In this case register STKUN should be initialized to a
value, which represents the desired highest Bottom of Stack address.
More details about the stack underflow trap service routine and virtual stack management
are given in
Section 27: System programming on page 545
.
Scope of stack limit control
The stack limit control realized by the register pair STKOV and STKUN detects cases where
the stack pointer SP is moved outside the defined stack area either by ADD or SUB
instructions or by PUSH or POP operations (explicit or implicit, CALL or RET instructions).
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
1
1
1
STKUN
0
R
R
R
R
RW
R
Bit
Function
STKUN
Modifiable portion of register STKUN
Specifies the upper limit of the internal system stack.