一个恒定值添加到一个x86的XMM寄存器 [英] Add a constant value to a xmm register in x86
本文介绍了一个恒定值添加到一个x86的XMM寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何添加 1
或 2
来登记 XMM0
(双)?
我能做到这样,但肯定必须有一个更简单的方法:
MOVSD XMM0,[ECX]XOR EAX,EAX
INC EAX
cvtsi2sd将xmm1,EAX
addsd XMM0,xmm1中MOVSD [ECX],XMM0
此外,才有可能与浮点指令的x87做到这一点?
这不为我工作:
FLD DWORD PTR [ECX]
FLD1
FADDP
FSTP DWORD PTR [ECX]
解决方案
您可以保持恒定在内存或另一个寄存器:
_1 DQ 1.0
和
addsd将xmm1,[_ 1]
或
MOVSD XMM0,[_ 1]
addsd将xmm1,XMM0
如果你是在x64上,你可以这样做:
MOV RAX,1.0
MOVQ XMM0,RAX
addsd将xmm1,XMM0
或使用堆栈如果类型不匹配困扰你:
MOV RAX,1.0
推RAX
MOVSD XMM0,[RSP]
流行RAX
addsd将xmm1,XMM0
对于使用x87 code,双击
是四字节
,而不是双字
。
How would I add 1
or 2
to the register xmm0
(double)?
I can do it like this, but sure there must be an easier way:
movsd xmm0, [ecx] xor eax, eax inc eax cvtsi2sd xmm1, eax addsd xmm0, xmm1 movsd [ecx], xmm0
Also would it be possible to do this with the floating point x87 instructions?
This doesn't work for me:
fld dword ptr [ecx] fld1 faddp fstp dword ptr [ecx]
解决方案
You can keep a constant in memory or in another register:
_1 dq 1.0
and
addsd xmm1,[_1]
or
movsd xmm0,[_1]
addsd xmm1,xmm0
If you are on x64, you can do this:
mov rax,1.0
movq xmm0,rax
addsd xmm1,xmm0
or use the stack if the type mismatch bothers you:
mov rax,1.0
push rax
movsd xmm0,[rsp]
pop rax
addsd xmm1,xmm0
As for the x87 code, double
s are qwords
, not dwords
.
这篇关于一个恒定值添加到一个x86的XMM寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文