diff --git a/src/ft_strlen.s b/src/ft_strlen.s index 8b62d8a..1ce9248 100644 --- a/src/ft_strlen.s +++ b/src/ft_strlen.s @@ -4,16 +4,16 @@ section .text global ft_strlen ft_strlen: - xor rax, rax - cmp rdi, 0 - je .exit - jmp .loop + xor rax, rax ; rax = 0 + cmp rdi, 0 ; check rdi is NULL + je .exit ; if rdi NULL exit + jmp .loop ; go to loop .loop: - cmp BYTE [rdi + rax], 0 - je .exit - inc rax - jmp .loop + cmp BYTE [rdi + rax], 0 ; check if the read byte is the end ('\0') + je .exit ; if it's true return to the exit + inc rax ; counter + 1 + jmp .loop ; loop again .exit: - ret + ret ; return rax