Re: Fastcode CharPosRev B&V 0.6.2



Hi,

I just made a little flaw in the first three one..

here are the corrections

Regards,
Davy Landman

function CharPosRev_DLA_PAS_14_a(SearchChar: Char; const S: string):
Integer;
var
PStart, PWalk: PChar;
StrLength: Integer;
label
c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16;
begin
StrLength := Length(S);
if StrLength > 0 then
begin
PStart := Pointer(S);
PWalk := Pointer((Cardinal(S) + Cardinal(StrLength)) - 16);
while PWalk >= PStart do
begin
if PWalk[15] = SearchChar then
begin
Result := (PWalk - PStart) + 16;
Exit;
end;
if PWalk[14] = SearchChar then
begin
Result := (PWalk - PStart) + 15;
Exit;
end;
if PWalk[13] = SearchChar then
begin
Result := (PWalk - PStart) + 14;
Exit;
end;
if PWalk[12] = SearchChar then
begin
Result := (PWalk - PStart) + 13;
Exit;
end;
if PWalk[11] = SearchChar then
begin
Result := (PWalk - PStart) + 12;
Exit;
end;
if PWalk[10] = SearchChar then
begin
Result := (PWalk - PStart) + 11;
Exit;
end;
if PWalk[9] = SearchChar then
begin
Result := (PWalk - PStart) + 10;
Exit;
end;
if PWalk[8] = SearchChar then
begin
Result := (PWalk - PStart) + 9;
Exit;
end;
if PWalk[7] = SearchChar then
begin
Result := (PWalk - PStart) + 8;
Exit;
end;
if PWalk[6] = SearchChar then
begin
Result := (PWalk - PStart) + 7;
Exit;
end;
if PWalk[5] = SearchChar then
begin
Result := (PWalk - PStart) + 6;
Exit;
end;
if PWalk[4] = SearchChar then
begin
Result := (PWalk - PStart) + 5;
Exit;
end;
if PWalk[3] = SearchChar then
begin
Result := (PWalk - PStart) + 4;
Exit;
end;
if PWalk[2] = SearchChar then
begin
Result := (PWalk - PStart) + 3;
Exit;
end;
if PWalk[1] = SearchChar then
begin
Result := (PWalk - PStart) + 2;
Exit;
end;
if PWalk[0] = SearchChar then
begin
Result := (PWalk - PStart) + 1;
Exit;
end;
Dec(PWalk, 16);
end;
case 16 - (PStart - PWalk) of
0: goto c0;
1: goto c1;
2: goto c2;
3: goto c3;
4: goto c4;
5: goto c5;
6: goto c6;
7: goto c7;
8: goto c8;
9: goto c9;
10: goto c10;
11: goto c11;
12: goto c12;
13: goto c13;
14: goto c14;
15: goto c15;
16: goto c16;
end;
c16:
if PStart[15] = SearchChar then
begin
Result := 16;
Exit;
end;
c15:
if PStart[14] = SearchChar then
begin
Result := 15;
Exit;
end;
c14:
if PStart[13] = SearchChar then
begin
Result := 14;
Exit;
end;
c13:
if PStart[12] = SearchChar then
begin
Result := 13;
Exit;
end;
c12:
if PStart[11] = SearchChar then
begin
Result := 12;
Exit;
end;
c11:
if PStart[10] = SearchChar then
begin
Result := 11;
Exit;
end;
c10:
if PStart[9] = SearchChar then
begin
Result := 10;
Exit;
end;
c9:
if PStart[8] = SearchChar then
begin
Result := 9;
Exit;
end;
c8:
if PStart[7] = SearchChar then
begin
Result := 8;
Exit;
end;
c7:
if PStart[6] = SearchChar then
begin
Result := 7;
Exit;
end;
c6:
if PStart[5] = SearchChar then
begin
Result := 6;
Exit;
end;
c5:
if PStart[4] = SearchChar then
begin
Result := 5;
Exit;
end;
c4:
if PStart[3] = SearchChar then
begin
Result := 4;
Exit;
end;
c3:
if PStart[2] = SearchChar then
begin
Result := 3;
Exit;
end;
c2:
if PStart[1] = SearchChar then
begin
Result := 2;
Exit;
end;
c1:
if PStart[0] = SearchChar then
begin
Result := 1;
Exit;
end;
end;
c0:
Result := 0;
end;

function CharPosRev_DLA_PAS_15_a(SearchChar: Char; const S: string):
Integer;
var
PStart, PWalk: PChar;
StrLength: Integer;
label
c0, c1, c2, c3, c4, c5, c6, c7, c8;
begin
StrLength := Length(S);
if StrLength > 0 then
begin
PStart := Pointer(S);
PWalk := Pointer((Cardinal(S) + Cardinal(StrLength)) - 8);
while PWalk >= PStart do
begin
if PWalk[7] = SearchChar then
begin
Result := (PWalk - PStart) + 8;
Exit;
end;
if PWalk[6] = SearchChar then
begin
Result := (PWalk - PStart) + 7;
Exit;
end;
if PWalk[5] = SearchChar then
begin
Result := (PWalk - PStart) + 6;
Exit;
end;
if PWalk[4] = SearchChar then
begin
Result := (PWalk - PStart) + 5;
Exit;
end;
if PWalk[3] = SearchChar then
begin
Result := (PWalk - PStart) + 4;
Exit;
end;
if PWalk[2] = SearchChar then
begin
Result := (PWalk - PStart) + 3;
Exit;
end;
if PWalk[1] = SearchChar then
begin
Result := (PWalk - PStart) + 2;
Exit;
end;
if PWalk[0] = SearchChar then
begin
Result := (PWalk - PStart) + 1;
Exit;
end;
Dec(PWalk, 8);
end;
case 8 - (PStart - PWalk) of
0: goto c0;
1: goto c1;
2: goto c2;
3: goto c3;
4: goto c4;
5: goto c5;
6: goto c6;
7: goto c7;
8: goto c8;
end;
c8:
if PStart[7] = SearchChar then
begin
Result := 8;
Exit;
end;
c7:
if PStart[6] = SearchChar then
begin
Result := 7;
Exit;
end;
c6:
if PStart[5] = SearchChar then
begin
Result := 6;
Exit;
end;
c5:
if PStart[4] = SearchChar then
begin
Result := 5;
Exit;
end;
c4:
if PStart[3] = SearchChar then
begin
Result := 4;
Exit;
end;
c3:
if PStart[2] = SearchChar then
begin
Result := 3;
Exit;
end;
c2:
if PStart[1] = SearchChar then
begin
Result := 2;
Exit;
end;
c1:
if PStart[0] = SearchChar then
begin
Result := 1;
Exit;
end;
end;
c0:
Result := 0;
end;

function CharPosRev_DLA_PAS_16_a(SearchChar: Char; const S: string):
Integer;
var
PStart, PWalk: PChar;
StrLength: Integer;
label
c0, c1, c2, c3, c4;
begin
StrLength := Length(S);
if StrLength > 0 then
begin
PStart := Pointer(S);
PWalk := Pointer((Cardinal(S) + Cardinal(StrLength)) - 4);
while PWalk >= PStart do
begin
if PWalk[3] = SearchChar then
begin
Result := (PWalk - PStart) + 4;
Exit;
end;
if PWalk[2] = SearchChar then
begin
Result := (PWalk - PStart) + 3;
Exit;
end;
if PWalk[1] = SearchChar then
begin
Result := (PWalk - PStart) + 2;
Exit;
end;
if PWalk[0] = SearchChar then
begin
Result := (PWalk - PStart) + 1;
Exit;
end;
Dec(PWalk, 4);
end;
case 4 - (PStart - PWalk) of
0: goto c0;
1: goto c1;
2: goto c2;
3: goto c3;
4: goto c4;
end;
c4:
if PStart[3] = SearchChar then
begin
Result := 4;
Exit;
end;
c3:
if PStart[2] = SearchChar then
begin
Result := 3;
Exit;
end;
c2:
if PStart[1] = SearchChar then
begin
Result := 2;
Exit;
end;
c1:
if PStart[0] = SearchChar then
begin
Result := 1;
Exit;
end;
end;
c0:
Result := 0;
end;


.



Relevant Pages

  • Re: Fastcode CharPosRev B&V 0.6.2
    ... PStart:= Pointer; ... if PWalk= SearchChar then ... PWalk:= PStart; ... 0: goto c0; ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode CharPosRev B&V 0.6.2
    ... PStart:= Pointer; ... while PWalk>= PStart do ... if PWalk= SearchChar then ... 0: goto c16; ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode CharPosIEx B&V 1.0.2
    ... StrLength:= Length; ... LowerSearchChar:= SearchChar; ... UpperSearchChar:= char- 32) ...
    (borland.public.delphi.language.basm)