AEo*_*nAX 3 delphi assembly delphi-5 delphi-xe7
我试图将一些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;
Run Code Online (Sandbox Code Playgroud)
据我所知,发生了以下事情:
push the contents of ECX register(Value) onto the stack move 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 register move 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;
Run Code Online (Sandbox Code Playgroud)
不幸的是,处理边缘情况相当混乱.