Re: Fastcode CompareMem B&V 1.0



Hi Dennis,

Here is Pascal version.

--
regards
Aleksandr

{$UNDEF SaveQ} {$IFOPT Q+} {$Q-} {$DEFINE SaveQ} {$ENDIF}
{$UNDEF SaveR} {$IFOPT R+} {$R-} {$DEFINE SaveR} {$ENDIF}
function CompareMem_Sha_Pas_1_a(p1, p2: pointer; length: integer): boolean;
var
q1, q2: pIntegerArray;
c: cardinal;
label
Ret0;
begin;
c:=length;
c:=c+cardinal(p1)-8;
q1:=p1;
q2:=p2;
if c>=cardinal(q1) then begin;;
if q1[0]<>q2[0] then goto Ret0;
inc(cardinal(q1),4);
inc(cardinal(q2),4);
dec(cardinal(q2),cardinal(q1));
cardinal(q1):=cardinal(q1) and -4;
inc(cardinal(q2),cardinal(q1));
if c>=cardinal(q1) then repeat;
if q1[0]<>q2[0] then goto Ret0;
if q1[1]<>q2[1] then goto Ret0;
inc(cardinal(q1),8);
inc(cardinal(q2),8);
until c<cardinal(q1);
end;
c:=c-cardinal(q1)+8;
if c>=4 then begin;
if q1[0]<>q2[0] then goto Ret0;
inc(cardinal(q1),4);
inc(cardinal(q2),4);
end;
if c and 2<>0 then begin;
if pword(q1)^<>pword(q2)^ then goto Ret0;
inc(cardinal(q1),2);
inc(cardinal(q2),2);
end;
if c and 1<>0 then if pchar(q1)^<>pchar(q2)^ then goto Ret0;
Result:=true;
exit;
Ret0:
Result:=false;
end;
{$IFDEF SaveQ} {$Q+} {$UNDEF SaveQ} {$ENDIF}
{$IFDEF SaveR} {$R+} {$UNDEF SaveR} {$ENDIF}



.



Relevant Pages

  • Re: Fastcode CompareMem B&V 1.0
    ... compiler creates a copy of cardinalfor statement ... if pchar>=q1 then repeat; ... if pword^pword^ then goto Ret0; ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode CompareMem B&V 1.0
    ... q1, q2: pIntegerArray; ... if c>=cardinalthen repeat; ... if pword^pword^ then goto Ret0; ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode CompareMem B&V 1.0
    ... Aleksandr ... q1, q2: pIntegerArray; ... if pword^pword^ then goto Ret0; ...
    (borland.public.delphi.language.basm)