Skip to content

Instantly share code, notes, and snippets.

@whyrusleeping
Last active August 29, 2015 13:59
Show Gist options
  • Save whyrusleeping/10611308 to your computer and use it in GitHub Desktop.
Save whyrusleeping/10611308 to your computer and use it in GitHub Desktop.
Quick assembly demo
int myFunc(int x, int y) {
return x + y
}
int main() {
int x = 1;
int y = 2;
int z = myFunc(x,y);
}
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