anyone know what algo was the fastest way to comparing string/byte?
Posted on 2002-08-15 21:25:45 by dion
The one that you write after having a good look at the source code forum at what has been posted there over the last few months.

A string compare is not a hard procedure to write so just have a good look at the source code forum and you should be able to write your own.

Regards,

hutch@movsd.com
Posted on 2002-08-15 21:39:44 by hutch--
dion, this is such a common operation that the processor has special instructions for string comparision! There is no complete answer to your question, but you can narrow the possiblities by defining the environment of the string comparison. Generally in optimization we take advantage of consistancies in the problem to obtain greater speed or smaller size. For a string comparison this means creating a model of the likely data we will be processing and designing an algorithm to exploit consistancies in that model.
Posted on 2002-08-15 22:53:12 by bitRAKE
heres one i made


long equ <:DWORD>
;---------------------------;---------------------------;---------------------------
;PStrCmp . compares a string
;---------------------------;---------------------------;---------------------------
PStrCmp Proc stdcall public, PTRstring long,PTRstring2find long
;Local strlenght1 long
push ecx
push ebx
push edx
push esi
mov ecx,PTRstring
;Invoke StringLen,ecx
;cmp eax,0
;je @ret0attrrcmp
mov ebx,PTRstring2find
Invoke StringLen,ebx
;cmp eax,0
;je @ret0attrrcmp
mov esi,eax
dec esi
xor eax,eax
xor edx,eax
mov dl, BYTE PTR [ebx+eax]
cmp dl, BYTE PTR [ecx+eax]
jne @ret0attrrcmp
;inc eax
@@:
cmp eax,esi
je @ret1attrrcmp
inc eax
mov dl, BYTE PTR [ebx+eax]
cmp dl, BYTE PTR [ecx+eax]
je @B
jne @ret0attrrcmp
@ret1attrrcmp:
xor eax,eax
inc eax;return 1 if found!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@popptrecmp:
pop esi
pop edx
pop ebx
pop ecx
ret
@ret0attrrcmp:
xor eax,eax
pop esi
pop edx
pop ebx
pop ecx
ret
PStrCmp EndP
;---------------------------;---------------------------;---------------------------
;StringLen1. Finds a lenght of the string passed. must have 0 at end.
;---------------------------;---------------------------;---------------------------
StringLen Proc stdcall public,ptrSTRING1:DWORD;duh
push esi
push ebx
mov esi,ptrSTRING1
xor ebx,ebx
xor eax,eax
cmp BYTE PTR [esi+eax],0
jne @F
pop ebx
pop esi
ret
@@:
;mov dl,BYTE PTR [esi+eax]
inc eax
;cmp dl,0
cmp BYTE PTR [esi+eax],0
jne @B
;dec eax
pop ebx
pop esi
ret
StringLen EndP
Posted on 2002-08-16 22:52:46 by Qages
wee.... thanks for all ur reply, i'll try to write my own one.
Posted on 2002-08-18 21:24:57 by dion