我正在尝试将一些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 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
任何有关翻译的帮助都将受到赞赏。
答案 0 :(得分:5)
以下是字面翻译:
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;
遗憾的是,处理边缘案件相当混乱。