
The central processing unit (CPU)
UM0404
76/564
DocID13284 Rev 2
3.4.10
The stack pointer SP
This non-bit-addressable register is used to point to the top of the internal system stack
(TOS). The SP register is pre-decremented whenever data is to be pushed onto the stack,
and it is post-incremented whenever data is to be popped from the stack. Thus, the system
stack grows from higher toward lower memory locations.
Since the least significant bit of register SP is tied to '0' and bits 15 through 12 are tied to '1'
by hardware, the SP register can only contain values from F000h to FFFEh. This allows to
access a physical stack within the IRAM of the MCU. A virtual stack (usually bigger) can be
realized via software. This mechanism is supported by registers STKOV and STKUN (see
respective descriptions below).
The SP register can be updated via any instruction which is capable of modifying an SFR.
Note:
Due to the internal instruction pipeline, a POP or RETURN instructions must not
immediately follow an instruction updating the SP register.
SP (FE12h / 09h)
SFR
Reset Value:FC00h
3.4.11
The stack overflow pointer STKOV
This non-bit-addressable register is compared against the SP register after each operation,
which pushes data onto the system stack (PUSH and CALL instructions or interrupts) and
after each subtraction from the SP register. If the content of the SP register is less than the
content of the STKOV register, a stack overflow hardware trap will occur. Since the least
significant bit of register STKOV is tied to '0' and bits 15 through 12 are tied to '1' by
hardware, the STKOV register can only contain values from F000h to FFFEh.
STKOV (FE14h / 0Ah)
SFR
Reset Value: FA00h
The Stack Overflow Trap (entered when (SP) < (STKOV)) may be used in two different
ways:
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
1
1
1
SP
0
R
R
R
R
RW
R
Bit
Function
SP
Modifiable portion of register SP
Specifies the top of the internal system stack.
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
1
1
1
STKOV
0
R
R
R
R
RW
R
Bit
Function
STKOV
Modifiable portion of register STKOV
Specifies the lower limit of the internal system stack.