PROWAREtech
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
![](/img/wait2.gif)
x64 Assembly: strlen Procedure
Find ASCII string length using x86-64 (64-bit) assembly.
Use MASM for Visual C++ Express Edition 2005 to compile this procedure.
This 64-bit procedure, strlen_asm_x64
, returns the length of a C-string.
TITLE 'extern "C" unsigned long long strlen_asm_x64(const char *string);'
PUBLIC strlen_asm_x64
_TEXT SEGMENT
strlen_asm_x64 PROC
push rdi
mov rdi, rcx ; *string
mov rcx, 0FFFFFFFFFFFFFFFFh
xor rax, rax
cld
repne scasb
xor rcx, 0FFFFFFFFFFFFFFFFh
dec rcx
mov rax, rcx
pop rdi
ret
strlen_asm_x64 ENDP
_TEXT ENDS
END
Comment![](/img/comment-white.svg)