Skip to content

Instantly share code, notes, and snippets.

@rbarzic
Created June 18, 2015 07:06
Show Gist options
  • Save rbarzic/37c254d12f7cc4c5d997 to your computer and use it in GitHub Desktop.
Save rbarzic/37c254d12f7cc4c5d997 to your computer and use it in GitHub Desktop.
getting stack pointer value from C using gcc
inline uint32_t get_stack_pointer(void) {
uint32_t sp;
asm("mov %0,sp" : "=r"(sp));
return sp;
}
@rbarzic
Copy link
Author

rbarzic commented Jun 18, 2015

32-bit CPU obviously :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment