I am dabbling my feet in x86_64 assembly. Right now I am exploring floating point math with SSE instructions. I load some values from memory into the xmm registers using movapd, which works perfectly. I then do some math without any problems. After that I try to move the result of my calculations, which is in xmm0 back into memory, also using movapd, but that isn't doing anything. Here is my gdb output:
20 movapd [result], xmm0
(gdb) i ad result
Symbol "result" is at 0x7ffff7f9de40 in a file compiled without debugging.
(gdb) x/2fg 0x7ffff7f9de40
0x7ffff7f9de40 <result>: 0 0
(gdb) p $xmm0.v2_double
$1 = {-1, 0}
(gdb) s
21 movss xmm0, [result]
(gdb) x/2fg 0x7ffff7f9de40
0x7ffff7f9de40 <result>: 0 0
To me it seems it is executing movadp without a crash or something (result is 16 byte aligned), but result isn't changing value. Did I misunderstand the movapd instruction? I have no idea what is causing this.
section .data
i dq 0.0, 1.0
align 16
section .bss
result resq 2
section .text
global main
main:
movapd xmm0, [i]
movapd xmm1, [i]
call vmul
movapd [result], xmm0
Here is some context code (nasm), the error occures in the last line.
UPDATE
If I try it like this:
movsd [result], xmm0
movhlps xmm0, xmm0
movsd [result + 8], xmm0
it works like I would expect. So it doen't seem to be an wrong access problem?