I have this following sample code in the start-up file for Cortex-M3 taken from Keil(compiling it with Microlib).
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
EXPORT __initial_sp
Stack_Size EQU 0x00000100
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
And this area is finally placed into a RAM region starting at address 0x20000000 with size of the executable region say 0x400 in the scatter file.
When I get into the debugger I see the that the value at memory address 0x0 is 0x20000118 which is the initial stack pointer and even the register window shows the msp register as 0x20000118.
But my understanding was that the start of the stack would be from 0x20000100 because that is what the above code snippet is doing.
I am unable to get from where are these extra 0x18 bytes coming from.
Also, i just switch off the Microlib mode, now I see the initial stack pointer is 0x20000120.
Again, from where are these extra 0x20 bytes offset coming from to the stack pointer.
Why isn't stack starting from where I want it to be(0x20000100), instead having some extra offsets?