[Lazarus] RE : RE : Convert assembler to Pascal

Ludo Brands ludo.brands at free.fr
Tue Sep 13 16:59:56 CEST 2011


> Ludo, I did a quick comparison of the results against the 
> Delphi 7 counterpart and the doesn't match.
> 
> Also, I tried to compile this in Delphi and I got "Ordinal 
> type required" on "p1 := P1 + 4". How can avoid this issue?.
> 

Should have told it was for delphi also:

Procedure XorMemPrim(var Mem1;  const Mem2;  Count : Cardinal); Var
i:integer;
  p1,p2:pointer;
Begin
p1:=@Mem1;
p2:=@Mem2;
for i:=1 to count div 4 do
  begin
  pdword(p1)^:=pdword(p1)^ xor pdword(p2)^;
  p1:=pointer(cardinal(p1)+4);
  p2:=pointer(cardinal(p2)+4);
  end;
For i:=1 to count mod 4 do
  begin
  pbyte(p1)^:=pbyte(p1)^ xor pbyte(p2)^;
  p1:=pointer(cardinal(p1)+1);
  p2:=pointer(cardinal(p2)+1);
  end;
End;

I compared the original and above in D6 and the result is the same. The
simplistic test program used:

procedure TForm1.FormCreate(Sender: TObject);
var s,s2,s3:string;
i:integer;
begin
  s:='abcdefghij';
  s2:='bcdefghijk';
  XorMemPrim2(s[1],s2[1],length(s2));
  s3:='';
  for i:=1 to length(s2) do
    s3:=s3+inttohex(ord(s[i]),2);
  label1.Caption:=s3;
  s:='abcdefghij';
  s2:='bcdefghijk';
  XorMemPrim(s[1],s2[1],length(s2));
  s3:='';
  for i:=1 to length(s2) do
    s3:=s3+inttohex(ord(s[i]),2);
  label2.Caption:=s3;
end;





More information about the Lazarus mailing list