I defined an assembly function which takes three parameters (int, double, double) which should add two putted double value and return the result of this addition. And I don't know why the below code doesn't work:
extern double ftaylor(unsigned int n, double x, double y);
int main()
{
double z = 14;
z = ftaylor(30, 13.45, 7);
printf("%f", z);
return 0;
}
And the assembly function:
.globl ftaylor
ftaylor:
.lcomm state, 8
.lcomm state2, 8
push %rbp
mov %rsp, %rbp
push %rax
mov %rdi, %rax
movsd %xmm0, state
movsd %xmm1, state2
finit
fld state
fld state2
fadd %st(1), %st(0)
fstp state
fstp state2
movsd state, %xmm0
pop %rax
mov %rbp, %rsp
pop %rbp
ret
The result printed on the terminal is 13.45
. It looks like the processor doesn't perform the addition. I don't know why.