PROWAREtech
x86 Assembly: strlen Procedure
Find ASCII string length.
Use MASM for Visual C++ Express Edition 2005 to compile this procedure.
This procedure, strlen_asm
, returns the length of a C-string. For Unicode strings see wcslen_asm
.
TITLE 'extern "C" unsigned strlen_asm(const char *string);'
.386P
.model FLAT
PUBLIC _strlen_asm
_TEXT SEGMENT
_strlen_asm PROC NEAR
push edi
mov edi, DWORD PTR [esp+8] ; *string
mov ecx, 0FFFFFFFFh
xor eax, eax
cld
repne scasb
xor ecx, 0FFFFFFFFh
dec ecx
mov eax, ecx
pop edi
ret 0
_strlen_asm ENDP
_TEXT ENDS
END
Comment