|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
The stack pointer is initialized at the end of the C startup code in STARTUP.A51. Why is this necessary?
The last few lines of the startup code appear as follows:
IF PBPSTACK <> 0 EXTRN DATA (?C_PBP) MOV ?C_PBP,#LOW PBPSTACKTOP ENDIF MOV SP,#?STACK-1 LJMP ?C_START
After reset, the stack pointer is initialized to 07h. The stack will start growing up from address 8h.
The Keil C compiler uses internal DATA memory for your variables and also allows you to use register banks 1, 2, and 3. If the stack pointer were not adjusted, calls to functions and interrupts would overwrite your variables.
Therefore, the last thing the startup code does is to set the stack pointer to the end of all your internal DATA variables.
Article last edited on: 2001-11-16 00:00:00
Did you find this article helpful? Yes No
How can we improve this article?