How is the value of _stack calculated
Hi all,
Sorry if this is a repeat post, the forum search is seemingly broken and wont find anything related to "stack" or "_stack".
Im wondering how the value of _stack is determined, or perhaps where it is determined. So far everything I can find seems to suggest it originates somewhere around the linking stage, either from the linker script, or perhaps internally within the linker itself?
But, I dont see anything in my linker script defining _stack directly, so perhaps it is formed internally somehow?
Basically I would like to try and find out why sp is initialised to a value of 0xa000fff8 by crt0 on my PIC (PIC32MX450F256). Ive seen some suggestions that the stack should be aligned to 8 bytes, so that somewhat explains the f8 bit.
But has something already been stored on the stack already between f8-ff, suggesting pre-decrement? Or can I consider that the f8 address is the first place I can push something onto the stack, which would mean post-decrement right? Ordinarily I would expect to see the stack pointer initialised to the very end of RAM, or 0xa0010000 on my PIC which has 64K of RAM, and use pre-decrement for push and post-increment for pop. So this has me confused a little.
Any insight appreciated.
Thanks!
post edited by toms - 2021/01/16 13:04:28