PROWARE technologies
PROWARE technologies

wcslen in x86 Assembly

This procedure, wcslen_asm, returns the length of a wchar_t string.

TITLE 'extern "C" unsigned wcslen_asm(const wchar_t *string);'
.686

.model FLAT

PUBLIC	_wcslen_asm

_WCSLEN	SEGMENT
_wcslen_asm PROC NEAR

	push edi
	mov  edi, DWORD PTR [esp+8] ; string
	mov  ecx, 0FFFFFFFFh
	xor  eax, eax
	cld
	repne scasw
	xor  ecx, 0FFFFFFFFh
	dec  ecx
	mov  eax, ecx
	pop  edi

	ret  0
	
_wcslen_asm ENDP
_WCSLEN	ENDS
END