From 42ec5e62e965dd33949f90f818fa5e660d767f0e Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 9 Dec 2025 12:34:32 +0100 Subject: [PATCH] docs(strlen): adding the strlen documentation - This comment is here to explain each etape. The main goal of this is for all people never made assembly can understand --- src/ft_strlen.s | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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