我要在组装中执行的操作:
facing_x = math.cos(Pitch) * math.cos(Yaw)
我该怎么做:
fld qword [Pitch]
fcos
fst [cos]
fld qword [Yaw]
fcos
fst [cos2]
movss xmm5,[cos]
movss xmm7,[cos2]
mulss xmm5,xmm7
movss [facing_x],xmm5
我总能得到: 1
无论两个输入如何, faceing_x
的结果总是为1或0。我在做什么错?我的意思是肯定有些不明白的东西!
答案 0 :(得分:0)
旧线程,但我想提出答案。
改进的代码:
finit
fld dword [Pitch]
mov dword [Math],0x42652EE1 //57.29577951308232
fld dword [Math]
fdivp st(1),st(0)
fcos
fld dword [Yaw]
fld dword [Math]
fdivp st(1),st(0)
fcos
fmulp st(1),st(0)
fstp dword [result]
旧代码:
finit
fld dword [Pitch]
mov dword [Math],0x42652EE1 //57.29577951308232
fld dword [Math]
fdivp st(1),st(0)
fcos
fld dword [Yaw]
mov dword [Math],0x42652EE1 //57.29577951308232
fld dword [Math]
fdivp st(1),st(0)
fcos
fmulp st(1),st(0)
fld dword [facingX]
fxch
fcomip st(1)
fstp dword [Math]
jne l611786
fld1
jmp l412411
l611786:
fldz
l412411:
fstp dword [result]