分类: C/C++
2008-05-06 10:30:38
#include int main() { __asm__("pop (%esp)"); return 0; } |
(gdb) b main Breakpoint 1 at 0x8048352: file t_esp.c, line 5. (gdb) r Starting program: /home/wangyao/a.out Breakpoint 1, main () at t_esp.c:5 5 __asm__("pop (%esp)"); (gdb) x $esp 0xbf876f64: 0xbf876f80 (gdb) x $esp+4 0xbf876f68: 0xbf876fd8 (gdb) x $esp+8 0xbf876f6c: 0xb7de1050 (gdb) s 8 return 0; (gdb) x $esp 0xbf876f68: 0xbf876f80 (gdb) x $esp+4 0xbf876f6c: 0xb7de1050 (gdb) q |
#include int main() { int temp = 0x1234; int temp0,temp1,temp2,temp3; __asm__ __volatile__("push %4\n\t" "movl 4(%%esp),%0\n\t" "movl -4(%%esp),%1\n\t" "pop (%%esp)\n\t" "movl (%%esp),%2\n\t" "movl -4(%%esp),%3\n\t" :"=r"(temp0),"=r"(temp1),"=r"(temp2),"=r"(temp3) :"g"(temp)); printf("---------------\n"); printf("esp+4:0x%08x\n", temp0); printf("esp:0x%08x\n", temp); printf("esp-4:0x%08x\n", temp1); printf("----- pop -----\n"); printf("esp:0x%08x\n", temp2); printf("esp-4:0x%08x\n", temp3); return 0; } |