Phr0zen_Penguin

sp.c - The Linux Stack Pointer

Apr 3rd, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. /**
  2.  * [sp.c]
  3.  * A program that prints its stack pointer (on Linux).
  4.  *
  5.  *
  6.  * compile with:
  7.  * gcc -o sp sp.c
  8.  */
  9.  
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12.  
  13. unsigned long get_sp(void)
  14. {
  15.     __asm__("movl   %esp, %eax");
  16. }
  17.  
  18. int main(void)
  19. {
  20.     printf("0x%x\n", get_sp());
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment