gpt4 book ai didi

delphi - 将 FindScanline 汇编代码转换为 purepascal

转载 作者:行者123 更新时间:2023-12-03 15:49:56 26 4
gpt4 key购买 nike

我正在尝试将一些 Delphi 5 代码转换为 Delphi XE7-x64,但我陷入了以下代码:

function FindScanline(Source : Pointer; MaxLen : Cardinal;
Value : Cardinal) : Cardinal; assembler;
asm
PUSH ECX
MOV ECX,EDX
MOV EDX,EDI
MOV EDI,EAX
POP EAX
REPE SCASB
MOV EAX,ECX
MOV EDI,EDX
end;

据我了解,正在发生以下事情:

push the contents of ECX register(Value) onto the stackmove contents of EDX register(MaxLen) into ECX register. now ECX holds (MaxLen)move contents of EDI register into EDX register. now EDX holds (EDI) move contents of EAX register into EDI register. now EDI holds (Source)pop ECX into EDX. now EDX holds (Value). Was (EDI) lost?repeat while equal ?decrement ECX for each char?move contents of ECX register into EAX registermove contents of EDX register into EDI register

引用函数FindScanline用于函数 GetCursorHeightMargin

任何翻译上述内容的帮助将不胜感激。

最佳答案

这是直译:

function FindScanline(Source: Pointer; MaxLen: Cardinal; Value: Cardinal): Cardinal;
var
Ptr: PByte;
begin
Result := MaxLen;
if Result > 0 then
dec(Result);
Ptr := Source;
while (Result > 0) and (Ptr^ = Value) do
begin
inc(Ptr);
dec(Result);
end;
end;

不幸的是,处理边缘情况相当困惑。

关于delphi - 将 FindScanline 汇编代码转换为 purepascal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28341435/

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