Re: asm grep
- From: "Rod Pemberton" <do_not_have@xxxxxxxxxxxxx>
- Date: Wed, 26 Dec 2007 12:01:24 -0500
"Frank Kotler" <fbkotler@xxxxxxxxxxx> wrote in message
news:cKhcj.6973$yC6.4200@xxxxxxxxxxx
;very dumb but short strstr
;
;esi - haystack
;edi - needle
strstr:
push esi
push edi
xor eax,eax
cmp [esi],byte 0
jz .rets
astrlen ecx, edi
Is the overhead of astrlen really needed here? He just needs the length of
string at edi, correct? If edi is byte 0 terminated, I'd try a repz scasb.
or ecx,ecx
jz .return
.next:
xor eax,eax
push ecx
push edi
repz cmpsb
It seems like this is doing extra work because it's checking a small section
at a time for the edi string... esi only gets incremented by the few
characters that aren't in edi, the increment is limited to ecx, so the rep
loop never gains any "momentum" since it keeps terminating.
Stop-go-stop-go-stop...i.e., it's not checking a potentially large section
of characters before it terminates and repeats. Wouldn't you want to use
repne scas to find the first (or last) char of edi - i.e., check and
potentially eliminate very large sections of text, and then use repz cmpsb
to check that the entire string is there? Repeat if not.
Oh, where does the direction flag get set?
Rod Pemberton
.
- Follow-Ups:
- Re: asm grep
- From: Frank Kotler
- Re: asm grep
- References:
- asm grep
- From: Frank Kotler
- asm grep
- Prev by Date: Re: Which assembler (or compiler) to start with? (newbie question)
- Next by Date: Re: Which assembler (or compiler) to start with? (newbie question)
- Previous by thread: asm grep
- Next by thread: Re: asm grep
- Index(es):
Relevant Pages
|