Another PosEx Entry
From: Eric W. Carman (ewcarman_at_)
Date: 03/17/05
- Next message: Dennis Landi: "Re: FastCode MM validations"
- Previous message: danny heijl: "Re: FastCode MM validations"
- Next in thread: Dennis: "Re: Another PosEx Entry"
- Reply: Dennis: "Re: Another PosEx Entry"
- Reply: Eric W. Carman: "Re: Another PosEx Entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 17 Mar 2005 08:19:08 -0500
Hello All,
This is my contribution to the efforts. Not the fastest to be sure, but not
the slowest either....
Also, in the B&V tool I noticed the following:
- The text for validate 1 reads "Running Validate 16"
- Can we add a generic PosEx to the Main Unit with IFDEFs to allow it to
compile for D6. D6 doesn't have one of its own.
Here it is:
function PosEx_EWC_IA32(const SubStr, S: string; Offset: Integer = 1):
Integer;
//Pattern = edi
//Source = esi
//SourceOffset/LoopVar = ecx
//PatternLength = edx
//Result = eax
asm
test eax, eax
jz @NotFound
test edx, edx
jz @NotFound
cmp ecx, 0
jle @NotFound
push esi
push edi
mov edi,eax
sub ecx, 1 //Make Offset relative to zero
lea esi,[edx+ecx] //Load esi with starting addr of source string
mov eax,[edx-$04] //Get String Source Length
push eax
mov edx,[edi-$04] //Get String Pattern Length
test eax, eax
jz @NotFoundPop
test edx, edx
jz @NotFoundPop
//Calculate Number of Loops to execute
sub eax,ecx // Subtract the Offset from the Length of the String
sub eax,edx // Backoff the Length of the Pattern
lea ecx,[eax+1] // Add 1 and move the result to the LoopVar
test ecx,ecx //If Pattern is longer than the remaining Source
jle @NotFoundPop // Pattern was not found.
jmp @BeginLoop
@NextSourceChar:
lea esi, [esi+1] //Advance to next Source character
@BeginLoop:
mov al,[edi] //Get Pattern Character
cmp al,[esi] //Compare to Source Character
jnz @NextSource //If no match, break loop
@BeginPattern:
push edx //Save Pattern Length
@PatternLoop:
sub edx, 1 //Make Pattern Count an Offset/Dec Loop Counter
jle @Found //If end of Pattern then must be found
mov al, [edi+edx] //Get Pattern Char
cmp al, [esi+edx] //Compare to Source Char
je @PatternLoop //if Pattern Char Matches
pop edx //Restore Pattern Count if not found
@NextSource:
sub ecx, 1
jnz @NextSourceChar
@NotFoundPop:
pop eax
pop edi
pop esi
@NotFound:
xor eax, eax
jmp @Done
@Found:
pop edx
pop eax //Length of Source String
pop edi
pop esi
sub eax, ecx //Subtract Number of Iterations Left
sub eax, edx //Add the Length of the Pattern
lea eax,[eax+2]
@Done:
end;
- Next message: Dennis Landi: "Re: FastCode MM validations"
- Previous message: danny heijl: "Re: FastCode MM validations"
- Next in thread: Dennis: "Re: Another PosEx Entry"
- Reply: Dennis: "Re: Another PosEx Entry"
- Reply: Eric W. Carman: "Re: Another PosEx Entry"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|