fork download
  1. #include <stdio.h>
  2.  
  3. unsigned int hoge(void);
  4. __asm__(
  5. "hoge:\n\t"
  6. "pushl %ebx\n\t"
  7.  
  8. "subl $4, %esp # allocate a buffer\n\t"
  9. "leal 1(%esp), %ebx\n\t"
  10. "pushl %ebx # where to store the second character\n\t"
  11. "decl %ebx\n\t"
  12. "pushl %ebx # where to store the first character\n\t"
  13. "pushl $str1\n\t"
  14. "call scanf\n\t"
  15. "add $12, %esp # discard the arguments\n\t"
  16. "movzwl (%esp), %ebx\n\t"
  17. "addl $4, %esp # discard the buffer\n\t"
  18.  
  19.  
  20. "movl %ebx, %eax\n\t"
  21. "popl %ebx\n\t"
  22. "ret\n\t"
  23.  
  24. "# put this where won't be executed\n\t"
  25. "str1: .asciz \"%c %c\"\n\t"
  26. );
  27.  
  28. int main(void) {
  29. printf("%x\n",hoge());
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 2164KB
stdin
12
stdout
3231