[英]How can I move an 80-bit floating point number with double precision from memory to XMM0 in AT&T assembly
I've written an AT&T assembly function to calculate an integral. 我已经编写了一个AT&T组装函数来计算积分。 I need to pass it as a return value as it's called by code written in C. I've successfully managed to return it as a single precision float
and a double precision double
. 我需要将其作为用C编写的代码调用的返回值传递。我已经成功地设法将其作为单精度float
和双精度double
。 But I know I can calculate it in 80-bit double extended precision and I'd love to pass it to C. 但我知道我可以80位双精度扩展精度来计算它,我很想将其传递给C。
Let's assume the value I want to pass is pointed to in an FPU register pointed by TOP. 假设要传递的值在TOP指向的FPU寄存器中指向。 Here's how I call functions. 这就是我所谓的函数。
For float: 对于浮点数:
//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
For double: 对于双:
//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
My question is now: how can I complete following code, so that C can read long double
from the %XMM0
register. 现在的问题是:我该如何完成以下代码,以便C可以从%XMM0
寄存器读取long double
。
For long double: 对于长双:
//C
long double integ_lo=integ_asm_fpu_lo();
#asm
...
fstpt max # FPU Store and Pop exTended <- extended for 80-bit
What should I do after that? 之后我该怎么办? How would I move 80 bits from max
to %XMM0
? 我如何将80位从max
移到%XMM0
?
Your premise is wrong: 您的前提是错误的:
how can I complete following code, so that C can read long double from the %XMM0 register. 我如何完成以下代码,以便C可以从%XMM0寄存器读取long double。
The sysv abi does not return long double
in xmm0
register, but st0
. sysv abi在xmm0
寄存器中不返回long double
,而是在st0
。 The relevant part of the 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. long double类型的参数的64位尾数属于X87类,16位指数加上6个字节的填充属于X87UP类。
If the class is X87UP, the value is returned together with the previous X87 value in %st0. 如果类是X87UP,则将值与%st0中的先前X87值一起返回。
Apparently you already have the value in st0
so you don't have to do anything just leave it there, meaning delete the fstpt
in your example. 显然,您已经在st0
拥有了值,因此您无需执行任何操作即可将其保留在那里,这意味着在示例中删除fstpt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.