gpt4 book ai didi

delphi - 调用汇编语言函数导致 "floating point stack check"异常

转载 作者:行者123 更新时间:2023-12-03 14:57:01 30 4
gpt4 key购买 nike

执行以下代码:

function ABCD32(Value: Cardinal): Single; register;
asm
BSWAP EAX
end;

function HexToFloat(hexValue: string; fmt: THexFloatFormat): Single;
var
c: Cardinal;
Err: Integer;
begin
Result := NaN;
c := HexToCardinal(hexValue, Err); //DCBA format
if Err <> 0 then Exit();
case fmt of
hfABCD: Result := ABCD32(c); //Here, after return from ABCD32
hfBADC: Result := BADC32(c);
hfCDAB: Result := CDAB32(c);
hfDCBA: Result := DCBA32(c);
end;
end;

导致运行时错误:

Project HexFloat.exe raised exception class $C0000092 with message 'floating point stack check at 0x004e9903'.

这是什么以及如何处理?

更新

这是 CPU 窗口输出:

HexFloat.dpr.162: hfABCD: Result := ABCD32(c);
004E98F8 8B45F0 mov eax,[ebp-$10]
004E98FB E894FFFFFF call ABCD32
004E9900 D95DF4 fstp dword ptr [ebp-$0c] //WTF?
004E9903 9B wait //Exception happens here
004E9904 EB28 jmp $004e992e

最佳答案

您的函数不遵守 ABI。浮点值应在 x87 单元上的 ST(0) 中返回。

function ABCD32(Value: Cardinal): Single; register;
asm
BSWAP EAX
PUSH EAX
FLD [ESP]
ADD ESP,4
end;

关于delphi - 调用汇编语言函数导致 "floating point stack check"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52256215/

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