Last active
August 29, 2015 13:59
-
-
Save whyrusleeping/10611308 to your computer and use it in GitHub Desktop.
Quick assembly demo
This file contains hidden or 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
int myFunc(int x, int y) { | |
return x + y | |
} | |
int main() { | |
int x = 1; | |
int y = 2; | |
int z = myFunc(x,y); | |
} |
This file contains hidden or 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
myFunc: | |
movl %edi, -4(%rbp) #grab x off stack | |
movl %esi, -8(%rbp) #grab y off stack | |
add %esi, %edi #add x and y | |
movl %esi, %eax #return x + y | |
ret | |
.globl main | |
main: | |
movl $1, -4(%rbp) #x = 1 | |
movl $2, -8(%rbp) #y = 2 | |
call myFunc | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment