I've got this really simple functions in ASM and C. I want to call ASM function from C code for double. I think return value from ASM should be stored in XMM0, but what actually happen is that my return value is taken from rax or if rax isn't set, I get 1.
C code:
#include <stdio.h>
int main() {
double a = 3.14;
double b = add(a);
printf("%lf\n", b);
return 0;
}
ASM function:
.type add, @function
.globl add
add:
#movq $1, %rax
addsd %XMM0, %XMM0
ret
What's wrong with it? Appreciate all hints.