转换unsigned int时,GCC如何使用fildll?

Jan*_*sen 2 floating-point x86 assembly unsigned x87

英特尔指令集参考声明(强调我的):

将有符号整数源操作数转换为双扩展精度浮点格式,并将该值压入FPU寄存器堆栈.源操作数可以是字,双字或四字整数.加载时没有舍入错误.源操作数的符号被保留.该指令的操作在非64位模式和64位模式下是相同的.

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

% 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
Run Code Online (Sandbox Code Playgroud)

Jan*_*sen 5

啊啊!"ll"后缀将使用指令的64位输入变体!GCC将高32位初始化为0,因此输入是否有符号无关紧要.