double x = 3.14159;
x = -x;
How can I negate a number in an xmm register?
I put x in an SSE register using the low 64 bits. I have just to toggle bit
63 obviously.
I wouldn't want to use a general register (eax-edx), since they are in
scarce supply.
I can't use the FPU FCHS instruction, that does that, since there is no path
from the SSE registers to the FPU.
The code I use now does it by substracting from zero:
subl $8,%esp ; Make place in the stack
movlpd %xmm0,(%esp) ; Move the number to the stack
xorpd %xmm0,%xmm0 ; Clear the register to zero
subsd (%esp),%xmm0 ; substract the number in stack from zero
addl $8,%esp ; adjust the stack
This looks horrible to me. Too much for such a simple operation!
Does anyone here have a better idea?
Thanks in advance.