- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am learning to use ARM MCUs and I want to make a stack monitor. I managed with filling it, monitor it ecc, but I want to start to fill it from a proper unused location without knowing the r13 value in debug. So I just need to implement a way to store the r13 somewhere in the code and using it later. So far I was visually checking the content of r13 in debug and adjusting the code accordingly.
What is the right way of storing locally the content of SP (r13) register in a ARM Cortex M3?
Thank you,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi user_381194313,
You can try the following snippet to track the stack pointer in your code:
register uint32 sp_track asm("sp");
int main()
{
// your code
}
The variable sp_track will now hold the value of the stack pointer and will change when the stack pointer changes, like pointer.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi user_381194313,
You can try the following snippet to track the stack pointer in your code:
register uint32 sp_track asm("sp");
int main()
{
// your code
}
The variable sp_track will now hold the value of the stack pointer and will change when the stack pointer changes, like pointer.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
thanks for the hint! But I wonder, what does return the asm instruction "sp", a pointer? In this case what is doing the "register" attribute? Can I avoid that?