PROWAREtech
x86 Assembly: wcsicmp Procedure
Compare two wide-char strings, ignore case.
Use MASM for Visual C++ Express Edition 2005 to compile this procedure.
This procedure, wcsicmp_asm
, compares two wchar_t
(16-bit) strings without regard to case. See also wcscmp_asm
.
The return value is:
less than zero if wcs1 is less than wcs2
equal to zero if wcs1 is equal to wcs2
greater than zero if wcs1 is greater than wcs2
TITLE 'extern "C" int wcsicmp_asm(const wchar_t *wcs1, const wchar_t *wcs2);'
.386P
.model FLAT
PUBLIC _wcsicmp_asm
_TEXT SEGMENT
_wcsicmp_asm PROC NEAR
mov edx, DWORD PTR [esp+4] ; wcs1
push esi
mov esi, DWORD PTR [esp+12] ; wcs2
label1:
xor eax, eax
mov ax, WORD PTR [edx]
cmp ax, 90 ; 'Z'
ja SHORT label2
cmp ax, 65 ; 'A'
jb SHORT label2
add eax, 32 ; 'a' - 'A' = 32
label2:
xor ecx, ecx
mov cx, WORD PTR [esi]
cmp cx, 90 ; 'Z'
ja SHORT label3
cmp cx, 65 ; 'A'
jb SHORT label3
add ecx, 32 ; 'a' - 'A' = 32
label3:
add edx, 2
add esi, 2
test ax, ax
je SHORT label4
cmp ax, cx
je SHORT label1
label4:
and ecx, 0000ffffH
and eax, 0000ffffH
sub eax, ecx
pop esi
ret 0
_wcsicmp_asm ENDP
_TEXT ENDS
END
Comment