fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. void* a;
  5. void* b;
  6. void* c;
  7. a=b=c=NULL;
  8. __asm__ volatile (
  9. "mov %%esp,%%eax\n\t"
  10. "push %%eax\n\t"
  11. "mov %%esp,%%ebx\n\t"
  12. "pop %%eax\n\t"
  13. "mov %%esp,%%ecx\n\t"
  14. "mov %%eax,%0\n\t"
  15. "mov %%ebx,%1\n\t"
  16. "mov %%ecx,%2\n\t"
  17. : "=m"(a),"=m"(b),"=m"(c)
  18. ::"%eax","%ebx","%ecx");
  19. printf("%p\n%p\n%p\n",a,b,c);
  20. putchar('\n');
  21. a=b=c=NULL;
  22. __asm__ volatile (
  23. "mov %%esp,%0\n\t"
  24. "push %%eax\n\t"
  25. "mov %%esp,%1\n\t"
  26. "pop %%eax\n\t"
  27. "mov %%esp,%2\n\t"
  28. : "=m"(a),"=m"(b),"=m"(c)
  29. ::);
  30. printf("%p\n%p\n%p\n",a,b,c);
  31. putchar('\n');
  32. a=b=NULL;
  33. __asm__ volatile (
  34. "mov %%esp,%0\n\t"
  35. "push %%eax\n\t"
  36. "lea %1,%%ebx\n\t"
  37. "pop %%eax\n\t"
  38. "mov %%ebx,%0\n\t"
  39. : "=m"(a),"=m"(b)
  40. ::"%ebx");
  41. printf("%p\n%p\n",a,&b);
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
0xbffceb60
0xbffceb5c
0xbffceb60

0xbffceb5c
(nil)
0xbffceb60

0xbffceb74
0xbffceb78