PROWAREtech

articles » current » assembly » x86 » procedures » wcslen

x86 Assembly: wcslen Procedure

Find wide-char string length.

Use MASM for Visual C++ Express Edition 2005 to compile this procedure.

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

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

.386P

.model FLAT

PUBLIC	_wcslen_asm

_TEXT	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
_TEXT	ENDS
END

PROWAREtech

Hello there! How can I help you today?
Ask any question

PROWAREtech

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.
ACCEPT REJECT