简体   繁体   English

如何在AT&T程序集中以双精度将80位浮点数从内存移动到XMM0

[英]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.

相关问题 从双精度参数开始的80位扩展精度计算的属性 - Properties of 80-bit extended precision computations starting from double precision arguments 在C89中,如何截断并将双精度浮点数拆分为两个32位字? - In C89, how can I truncate and split a double precision floating point into two 32-bit words? GCC 内联汇编 - 调用前将浮点数移动到 XMM0 - GCC inline assembly - Move float to XMM0 before call 如何定义80位大小的变量 - How to define a 80-bit size variable 如何在x86-64上获取80位长双精度数的尾数作为int - How to get the mantissa of an 80-bit long double as an int on x86-64 在不支持双精度的C编译器上将64位双精度浮点数据转换为Uint32 - Convert 64-bit double precision floating point data to Uint32 on a C compiler that doesn't support double precision 如何在Double中检查浮点精度 - How to check for floating point precision in Double 如何将 DEC 64 位双精度浮点数转换为 IEEE-754(DEC 不是十进制) - How to convert DEC 64bit double precision floating point to IEEE-754 (DEC is not decimal) 浮点数精度 - floating point number precision 如何将 64 位浮点数添加到特定索引处的 unsigned char 数组(C++) - How can I add a 64 bit floating point number to an unsigned char array at specific indexes (C++)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM