Created
January 7, 2013 21:44
-
-
Save tuttlem/4478792 to your computer and use it in GitHub Desktop.
strlen - nasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_strlen: | |
push rcx ; save and clear out counter | |
xor rcx, rcx | |
_strlen_next: | |
cmp [rdi], byte 0 ; null byte yet? | |
jz _strlen_null ; yes, get out | |
inc rcx ; char is ok, count it | |
inc rdi ; move to next char | |
jmp _strlen_next ; process again | |
_strlen_null: | |
mov rax, rcx ; rcx = the length (put in rax) | |
pop rcx ; restore rcx | |
ret ; get out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment