Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // c code
- MyFunction1(a, b);
- // assembly code
- main:
- push a
- push b
- push rbp ; save frame pointer on stack
- mov rsp, rbp ; save stack pointer in frame pointer
- xor rax, rax ; set function return value to 0.
- call _MyFunction
- mov rbp, rsp ; restore stack pointer
- pop rbp ; restore frame pointer
- ret ; return to calling function
- ile.c:
- foo(int x)
- {
- return x+1;
- }
- file.s:
- .file "t.c"
- .text
- .globl foo
- .type foo, @function
- foo:
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %eax
- addl $1, %eax
- popl %ebp
- ret
- .size foo, .-foo
- .ident "GCC: (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3"
- .section .note.GNU-stack,"",@progbits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement