Last active
May 23, 2017 18:22
-
-
Save DmitrySoshnikov/8eb0cc0b4ec116c906307302aebc493d to your computer and use it in GitHub Desktop.
stack-params.c
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
// https://godbolt.org/g/2xOK3B | |
int foo(int x) { | |
int y = 20; | |
return x + y; | |
} | |
int main() { | |
foo(10); | |
return 0; | |
} | |
/* asm | |
foo(int): # @foo(int) | |
pushq %rbp | |
movq %rsp, %rbp | |
movl %edi, -4(%rbp) | |
movl $20, -8(%rbp) | |
movl -4(%rbp), %edi | |
addl -8(%rbp), %edi | |
movl %edi, %eax | |
popq %rbp | |
retq | |
main: # @main | |
pushq %rbp | |
movq %rsp, %rbp | |
subq $16, %rsp | |
movl $10, %edi | |
movl $0, -4(%rbp) | |
callq foo(int) | |
xorl %edi, %edi | |
movl %eax, -8(%rbp) # 4-byte Spill | |
movl %edi, %eax | |
addq $16, %rsp | |
popq %rbp | |
retq | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment