Say I have a function foo defined as:
def foo(x,y):
return x + y
and say I have function call:
foo(2,3)
which corresponds to the x86-64:
movq $2 %rdi
movq $3 %rsi
call foo
I am aware that if the function foo
has a return value it will be stored in the register %rax
. but what does this mean exactly?
the assembly would be something like:
movq $2 %rdi
movq $3 %rsi
call foo
foo:
movq -8(%rsb) %rax
addq -16(%rsb) %rax
can you please finish the definition of foo in assembly? does it use %rax
? how does it use %rax
?
My question is how %rax is used to get the return value of a function and how this value in %rax
gets passed between the caller and callee. thanks