gpt4 book ai didi

assembly - GCC 在转换 unsigned int 时如何使用 fildll?

转载 作者:行者123 更新时间:2023-12-02 22:34:14 24 4
gpt4 key购买 nike

英特尔指令集引用声明(强调我的):

Converts the signed-integer source operand into double extended-precision floating- point format and pushes the value onto the FPU register stack. The source operand can be a word, doubleword, or quadword integer. It is loaded without rounding errors. The sign of the source operand is preserved. This instruction’s operation is the same in non-64-bit modes and 64-bit mode.

在这里你可以看到我的测试用例:

% cat stackoverflow.c       
float uint2float(unsigned int a) {
return a;
}
% gcc -c stackoverflow.c
% objdump -d stackoverflow.o

stackoverflow.o: file format elf32-i386


Disassembly of section .text:

00000000 <uint2float>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 08 sub $0x8,%esp
6: 8b 45 08 mov 0x8(%ebp),%eax
9: ba 00 00 00 00 mov $0x0,%edx
e: 89 45 f8 mov %eax,-0x8(%ebp)
11: 89 55 fc mov %edx,-0x4(%ebp)
14: df 6d f8 fildll -0x8(%ebp)
17: c9 leave
18: c3 ret
% gcc --version
gcc-4.6.real (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

最佳答案

啊哈! “ll”后缀将使用指令的 64 位输入变体! GCC 将高 32 位初始化为 0,因此输入是否签名无关紧要。

关于assembly - GCC 在转换 unsigned int 时如何使用 fildll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11714238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com