Re: asm grep




"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

.



Relevant Pages

  • Re: misc: a few operations (long long division?...)
    ... eax, ecx, edx, ebx, ebp, esi, and edi. ...
    (alt.lang.asm)
  • Re: Fastcode Int64Div
    ... push esi // Save ESI as per calling convention. ... push edi // Save EDI as per calling convention. ... mov esi, ecx // divisor_hi ... mov edi, edx // dividend_hi ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode Int64Div
    ... mov edx, ... push esi // Save ESI as per calling convention. ... push edi // Save EDI as per calling convention. ... mov esi, ecx // divisor_hi ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... mov ecx, ... mov edi, ecx ... mov esi, ...
    (borland.public.delphi.language.basm)
  • Re: I need the fastest routine
    ... mov ecx, ... mov edi, ecx ... mov esi, ...
    (borland.public.delphi.language.basm)