Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* C code */
int add(int x, int y) {
return x+y;
}
void caller() {
int a = add(3, 4);
}
/* x86 assembly */
caller:
# Prelude
pushl %ebp
movl %esp, %ebp
subl $16, %esp
# Push arguments onto the stack
pushl $4
pushl $3
# Call `add`
call add
# Pop the two arguments
addl $8, %esp
...
/* amd64 assembly */
caller:
# Prelude
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
# Put arguments in registers
movl $4, %esi
movl $3, %edi
# Invoke `add`
call add
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.