Here's a routine to match a string (case-sensitive) like "comrade" against a mask like "co*de":
match proc pszMask:PTR BYTE, pszString:PTR BYTE

push esi
push edi
push ebx
mov esi, [pszMask]
mov edi, [pszString]
xor ebx, ebx
jmp @@chkz
@@next: movzx eax, byte ptr [esi]
cmp eax, "*"
jne @@cmp1
inc ebx
inc esi
jmp @@chkz
@@cmp1: test ebx, ebx
jz @@nowc
mov edx, esi
mov ecx, edi
@@cmp2: movzx eax, byte ptr [edx]
cmp eax, "*"
je @@cmp3
test eax, eax
jz @@cmp3
cmp eax, "?"
je @@sc
cmp al, [ecx]
jne @@cmp3
@@sc: inc edx
inc ecx
jmp @@cmp2
@@cmp3: je @@cmp4
inc edi
cmp byte ptr [edi], 0
jnz @@next
xor eax, eax
jmp @@quit
@@cmp4: xor ebx, ebx
jmp @@mtch
@@nowc: cmp eax, "?"
je @@mtch
cmp al, [edi]
je @@mtch
xor eax, eax
jmp @@quit
@@mtch: xor ebx, ebx
inc esi
inc edi
@@chkz: cmp byte ptr [esi], 0
jne @@next
xor eax, eax
inc eax
cmp byte ptr [edi], 0
je @@quit
mov eax, ebx
@@quit: pop ebx
pop edi
pop esi
ret
match endp


Attached is a working example using this function. I've done little testing and fear this routine is buggy.
Posted on 2002-07-12 23:06:35 by comrade
   .data

temp1 db "?",0
temp2 db 0

.code
invoke match, OFFSET temp1, OFFSET temp2
Not that this is likely, but an error. I will look for more.

having looked at your sample - I see you can't
have a NULL string passed to routine.
Posted on 2002-07-12 23:51:16 by bitRAKE
Null pointer? I think you mean null string?
Posted on 2002-07-13 01:16:55 by comrade
Yes, null string.
Posted on 2002-07-13 11:04:12 by bitRAKE
bitRAKE, i am look for errors in following code ;)


;<esi-mask
;<edi-string
;>eax=0 - ok
proc CompareStringWithMask
xor edx,edx
xor eax,eax
xor ecx,ecx
@@lpn: mov dl,[edi]
@@lp: lodsb
test al,al
je @@bkch
cmp al,'*'
je @@sub
test dl,dl
je @@ret
cmp al,'?'
je @@skip
cmp al,dl
jne @@back
@@skip: inc edi
jmp @@lpn
@@sub: inc ecx
@@sb0: push esi edi
jmp @@lp
@@bkch: or al,[edi]
je @@ret
cmp [byte esi-2],'*'
je @@ret
@@back: jecxz @@ret
@@bkup: pop edi esi
inc edi
mov dl,[edi]
test dl,dl
jne @@sb0
dec ecx
jne @@bkup
@@ret: lea esp,[esp+8*ecx]
ret
endp
Posted on 2002-07-15 10:26:25 by Nexo