EasyManuals Logo
Home>ST>Microcontrollers>STM8S

ST STM8S Reference Manual

ST STM8S
449 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #24 background imageLoading...
Page #24 background image
Central processing unit (CPU) RM0016
24/449 Doc ID 14587 Rev 8
Figure 1. Programming model
Stack pointer (SP)
The stack pointer is a 16-bit register. It contains the address of the next free location of the
stack. Depending on the product, the most significant bits can be forced to a preset value.
The stack is used to save the CPU context on subroutine calls or interrupts. The user can
also directly use it through the POP and PUSH instructions.
The stack pointer can be initialized by the startup function provided with the C compiler. For
applications written in C language, the initialization is then performed according to the
address specified in the linker file for C users. If you use your own linker file or startup file,
make sure the stack pointer is initialized properly (with the address given in the datasheets).
For applications written in assembler, you can use either the startup function provided by ST
or write your own by initializing the stack pointer with the correct address.
The stack pointer is decremented after data has been pushed onto the stack and
incremented after data is popped from the stack. It is up to the application to ensure that the
lower limit is not exceeded.
A subroutine call occupies two or three locations. An interrupt occupies nine locations to
store all the internal registers (except SP). For more details refer to Figure 2.
Note: The WFI/HALT instructions save the context in advance. If an interrupt occurs while the CPU
is in one of these modes, the latency is reduced.
07
A ACCUMULATOR
07815
SP STACK POINTER
SH S
X INDEX
Y INDEX
07815
PC PROGRAM COUNTER
PCH PCL
07
CC CODE CONDITION
VI1HI0NZC
1623
PCE
07815
XH XL
07815
XH XL
0

Table of Contents

Other manuals for ST STM8S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM8S and is the answer not in the manual?

ST STM8S Specifications

General IconGeneral
BrandST
ModelSTM8S
CategoryMicrocontrollers
LanguageEnglish

Related product manuals