如何将双精度的 80 位浮点数从内存移动到 AT&T 程序集中的 XMM0
How can I move an 80-bit floating point number with double precision from memory to XMM0 in AT&T assembly
我编写了一个 AT&T 汇编函数来计算积分。我需要将它作为 return 值传递,因为它是由用 C 编写的代码调用的。我已经成功地 return 它作为单精度 float
和双精度 [=14] =].但我知道我可以用 80 位双扩展精度计算它,我很乐意将它传递给 C。
让我们假设我要传递的值指向 TOP 指向的 FPU 寄存器。这是我调用函数的方式。
对于浮动:
//C
double integ_fo=integ_asm_fpu_fl();
#asm
...
fstps max # Fpu STore and Pop Short <- short for 32-bit
movss max, %xmm0 # MOVe Scalar Single precision
对于双:
//C
double integ_do=integ_asm_fpu_do();
#asm
...
fstpl max # Fpu STore and Pop Long <- long for 64-bit
movsd max, %xmm0 # MOVe Scalar Dingle precision
我现在的问题是:如何完成以下代码,以便 C 可以从 %XMM0
寄存器中读取 long double
。
长双:
//C
long double integ_lo=integ_asm_fpu_lo();
#asm
...
fstpt max # FPU Store and Pop exTended <- extended for 80-bit
之后我应该做什么?我如何将 80 位从 max
移动到 %XMM0
?
你的前提是错误的:
how can I complete following code, so that C can read long double from
the %XMM0 register.
sysv abi 没有return long double
在xmm0
注册,而是st0
。
documentation的相关部分:
The 64-bit mantissa of arguments of type long double belongs to class
X87, the 16-bit exponent plus 6 bytes of padding belongs to class
X87UP.
If the class is X87UP, the value is returned together with the
previous X87 value in %st0.
显然您已经在 st0
中拥有该值,因此您无需执行任何操作,只需将其留在那里,这意味着删除示例中的 fstpt
。
我编写了一个 AT&T 汇编函数来计算积分。我需要将它作为 return 值传递,因为它是由用 C 编写的代码调用的。我已经成功地 return 它作为单精度 float
和双精度 [=14] =].但我知道我可以用 80 位双扩展精度计算它,我很乐意将它传递给 C。
让我们假设我要传递的值指向 TOP 指向的 FPU 寄存器。这是我调用函数的方式。
对于浮动:
//C
double integ_fo=integ_asm_fpu_fl();
#asm
...
fstps max # Fpu STore and Pop Short <- short for 32-bit
movss max, %xmm0 # MOVe Scalar Single precision
对于双:
//C
double integ_do=integ_asm_fpu_do();
#asm
...
fstpl max # Fpu STore and Pop Long <- long for 64-bit
movsd max, %xmm0 # MOVe Scalar Dingle precision
我现在的问题是:如何完成以下代码,以便 C 可以从 %XMM0
寄存器中读取 long double
。
长双:
//C
long double integ_lo=integ_asm_fpu_lo();
#asm
...
fstpt max # FPU Store and Pop exTended <- extended for 80-bit
之后我应该做什么?我如何将 80 位从 max
移动到 %XMM0
?
你的前提是错误的:
how can I complete following code, so that C can read long double from the %XMM0 register.
sysv abi 没有return long double
在xmm0
注册,而是st0
。
documentation的相关部分:
The 64-bit mantissa of arguments of type long double belongs to class X87, the 16-bit exponent plus 6 bytes of padding belongs to class X87UP.
If the class is X87UP, the value is returned together with the previous X87 value in %st0.
显然您已经在 st0
中拥有该值,因此您无需执行任何操作,只需将其留在那里,这意味着删除示例中的 fstpt
。