Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // c code
  2. MyFunction1(a, b);
  3.  
  4. // assembly code
  5. main:
  6. push a
  7. push b
  8. push rbp ; save frame pointer on stack
  9. mov rsp, rbp ; save stack pointer in frame pointer
  10. xor rax, rax ; set function return value to 0.
  11. call _MyFunction
  12. mov rbp, rsp ; restore stack pointer
  13. pop rbp ; restore frame pointer
  14. ret ; return to calling function
  15.  
  16. ile.c:
  17. foo(int x)
  18. {
  19. return x+1;
  20. }
  21.  
  22. file.s:
  23. .file "t.c"
  24. .text
  25. .globl foo
  26. .type foo, @function
  27. foo:
  28. pushl %ebp
  29. movl %esp, %ebp
  30. movl 8(%ebp), %eax
  31. addl $1, %eax
  32. popl %ebp
  33. ret
  34. .size foo, .-foo
  35. .ident "GCC: (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3"
  36. .section .note.GNU-stack,"",@progbits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement