这又什么难以理解的?
cvtsi2sd 要求源操作数是带符号数,故当操作数>=$2^31$, cvtsi2sd不能按预期的 ...
__declspec(naked)
DWORD __fastcall iSqrt_SSE41(DWORD n)
{
__asm
{
mov eax, ecx
and eax, 0x80000000
movd xmm0, eax
psllq xmm0, 32
mov eax, 0
cvtsi2sd xmm1, eax
movsd xmm2, qword ptr
blendvpd xmm1, xmm2, xmm0
cvtsi2sd xmm0, ecx
addsd xmm0, xmm1
sqrtsd xmm0, xmm0
cvttsd2si eax, xmm0
ret
}
} mov eax, ecx
and eax, 0x80000000
shr eax, 31
movsd xmm1, qword ptr
cvtsi2sd xmm0, ecx
addsd xmm0, xmm1
sqrtsd xmm0, xmm0
cvttsd2si eax, xmm0
ret push ecx
fld qword ptr
fldz
cmp ecx, 0x8000000
fcmovnb st, st(1)
fild dword ptr
faddpst(1),st
fsqrt
faddqword ptr
fistpdword ptr
fstpst
pop eax
ret
但为什么用2^53实测不行
页:
1
[2]