I have an assembly program that doesn't work:
.data
.LC0:
.string "%f%f"
b:
.long 1085066445
a:
.long 1078774989
.text
.globl main
main:
pxor %xmm0, %xmm0
pxor %xmm1, %xmm1
movl $.LC0, %edi
movl $2, %eax # %eax magic
cvtss2sd a(%rip), %xmm0
cvtss2sd b(%rip), %xmm1
call printf
xorl %eax, %eax
ret
The problem is in printf. In fact, when I comment out that line, the program ends normally. Then, I inspected the assembly output of the same program written in C and I saw that the compiler first subtracts 8 to rsp, and then, after printf, it adds 8 again. What is going on? This is the corresponding C program
float a = 3.2, b = 5.4;
int main() { printf("%f%f", a, b); }