Created
August 15, 2018 17:11
-
-
Save gnuvince/212fc4f54e61fe7a5e813c7e2bf5eeeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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