【发布时间】:2020-06-06 18:32:14
【问题描述】:
所以我正在尝试让处理器计算下面的x*log_2(y) 是我当前的汇编代码(nasm 语法)。我在XMM0 寄存器中有 y 的输入值,X 将是 10 的常数。
MOVSD QWORD [RSP], XMM0 ;Copy result of prev calculation to the stack
FLD QWORD [RSP] ;Load the float from XMM0 to the fpu stack
;Load number 10 to the fpu stack
MOV RAX, 10
PUSH RAX
FLD QWORD [RSP] ;ST(0)
POP RAX
;Do the math y = xmm0, x=10 X*LOG2(Y)
FYL2X ;ST(1) = OUT
FSTP ;just remove ST(0), no need to preserve
FSTP QWORD [RSP];Pop the result from the logarithm to the stack
MOV RDI, QWORD [RSP]
call printfcallfloat
我在 XMM0 寄存器中使用 2.0 的值进行了测试,但我总是得到纯零。我在这里做错了什么?
【问题讨论】:
-
您确定
printfcallfloat需要 RDI 中的浮点参数,而不是 XMM0 中的浮点参数吗? -
@prl 是的,这是我自己编写函数时的情况
标签: assembly floating-point x86-64 logarithm