所以,我有以下函数来读取 EXTENDED(扩展双精度,80 位精度双精度)并作为普通 INT 输出
int read_ld( int addr )
{
int result;
asm volatile
(
"mov eax, %[addr];"
"fld qword ptr [eax];"
"fistp dword ptr %[result]"
: [addr] "=m" (addr)
: [result] "m" (result)
);
return result;
}
Wich 由另一个函数(任何函数)调用,但我将在此处放置出现错误的实际代码
extern "C" __declspec(dllexport) void funca()
{
if( key(VK_PRIOR) ) //Fast
fps_control( 0 );
else if( key(VK_NEXT) ) //Slow
fps_control( fps * 2 );
else
fps_control( fps ); //Normal
char a[255];
if( key(VK_HOME) )
{
int k = read_ld( 0x5080EC ); //This is just for testing <<
}
}
这个用 mingw 编译的 EXACT 代码,没有特殊标志,在 funca() 处为我提供了以下程序集
SUB ESP, 2C
MOV DWORD PTR SS:[ESP], 21
CALL nakaeru.6FF01540 << Notice these are calls to key(), normal
TEST EAX, EAX
JE L017
MOV DWORD PTR SS:[ESP], 0
CALL nakaeru.6FF014E0 << Notice these are calls to key(), normal
L007:
MOV DWORD PTR SS:[ESP], 24
CALL nakaeru.6FF01540 << Notice these are calls to key(), normal
TEST EAX, EAX
JE L014
MOV EAX, DWORD PTR SS:[ESP+18] <<| This is my code and it is not a call
FLD QWORD PTR DS:[EAX] |
FISTP DWORD PTR SS:[ESP+1C] |
L014:
ADD ESP, 2C
RETN
LEA ESI, DWORD PTR DS:[ESI]
L017:
MOV DWORD PTR SS:[ESP], 22
CALL nakaeru.6FF01540
TEST EAX, EAX
MOV EAX, DWORD PTR DS:[6FF08000]
JE L026
ADD EAX, EAX
MOV DWORD PTR SS:[ESP], EAX
CALL nakaeru.6FF014E0
JMP L007
L026:
MOV DWORD PTR SS:[ESP], EAX
CALL nakaeru.6FF014E0
JMP L007
我想知道为什么编译器会这样做...可能是某种优化或我可能缺少的某些选项吗?
提前致谢