Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. int add(int a, int b) {
  2. return a + b;
  3. }
  4.  
  5. int main() {
  6. return add(42, 1337);
  7. }
  8.  
  9. .file "test.c"
  10. .text
  11. .globl add
  12. .type add, @function
  13. add:
  14. pushq %rbp
  15. movq %rsp, %rbp
  16. pushq %rdi
  17. pushq %rsi
  18. mov -8(%rbp), %eax
  19. pushq %rax
  20. mov -16(%rbp), %eax
  21. pushq %rax
  22. popq %rax
  23. popq %rcx
  24. addl %ecx, %eax
  25. push %rax
  26. popq %rax
  27. movq %rbp, %rsp
  28. popq %rbp
  29. ret
  30. .size add, .-add
  31. .text
  32. .globl main
  33. .type main, @function
  34. main:
  35. pushq %rbp
  36. movq %rsp, %rbp
  37. pushq %rbx
  38. movq %rsp, %rbx
  39. andq $-16, %rsp
  40. subq $8, %rsp
  41. pushq $add
  42. push $1337
  43. push $42
  44. popq %rdi
  45. popq %rsi
  46. movq 0(%rsp), %rax
  47. call *%rax
  48. movq %rbx, %rsp
  49. popq %rbx
  50. pushq %rax
  51. popq %rax
  52. movq %rbp, %rsp
  53. popq %rbp
  54. ret
  55. .size main, .-main
  56. .ident "Sortix CC"
  57. .section .note.GNU-stack,"",@progbits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement