Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who defines the stack pointer address

Tags:

In terms of microcontrollers and embedded systems with C startup code, one of the functions of the C startup code is to initialize the stack pointer.

Is this initial stack pointer address and C startup code generally defined and provided by the chip vendor?

Or is it up to us as the firmware / software developers to manually modify or create the C startup code and specify the stack pointer? This part confuses me.

like image 812
Engineer999 Avatar asked Feb 20 '19 18:02

Engineer999


1 Answers

Every architecture does it it's way. ARM Cortex uCs have the initial stack pointer location stored as the first 32 bits value in the vector table. This value is loaded by the hardware when the uC is booted. So this address is fully controllable by the programmer.

Then the start-up routine can change it or set the double stack (one for the thread another for the privileged mode).

like image 157
0___________ Avatar answered Oct 04 '22 01:10

0___________