Delphi 将FindScanline汇编代码转换为purepascal

Delphi 将FindScanline汇编代码转换为purepascal,delphi,assembly,delphi-5,delphi-xe7,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,E

我正在尝试将一些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 将ECX寄存器(值)的内容推送到堆栈上 将EDX寄存器(MaxLen)的内容移动到ECX寄存器中。现在ECX有效(MaxLen) 将EDI寄存器的内容移到EDX寄存器中。现在EDX持有(EDI) 将EAX寄存器的内容移动到EDI寄存器中。现在EDI有效(来源) 将ECX插入EDX。现在EDX持有(价值)。(EDI)丢失了吗? 当每个字符的ECX值相等时重复此操作? 将ECX寄存器的内容移到EAX寄存器中 将EDX寄存器的内容移到EDI寄存器中 函数中使用了“作为参考”函数


如果您能帮助翻译以上内容,我们将不胜感激。

以下是直译:

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;

不幸的是,处理边缘情况相当麻烦。

先生,您很好