RM0016 Memory and register map
Doc ID 14587 Rev 8 31/449
3.1.2 Stack handling
Default stack model
The stack of the STM8S and STM8A microcontrollers is implemented in the user RAM area.
The default stack model is shown in Figure 4.
Figure 4. Default stack model
1. The stack roll-over limit is not implemented on all devices. Refer to the datasheets for detailed information.
Stack pointer initialization value
This is the default value of the stack pointer. The user must take care to initialize this pointer.
Correct loading of this pointer is usually performed by the initialization code generated by
the development tools (linker file). In the default stack model this pointer is initialized to the
RAM end address.
Stack roll-over limit
In some devices, a stack roll-over limit is implemented at a fixed address. If the stack pointer
is decreased below the stack roll-over limit, using a push operation or during context saving
for subroutines or interrupt routines, it is reset to the RAM end address. The stack pointer
does not roll over if stack pointer arithmetic is used.
Such behavior of the stack pointer is of particular importance when developing software on
a device with a different memory configuration than the target device.
ai15055
Default stack model
End address
Stack roll-over limit
(1)
Stack pointer initialization value
Start address
RAM