-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlen.s
35 lines (30 loc) · 1.39 KB
/
ft_strlen.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
; **************************************************************************** ;
; ;
; ::: :::::::: ;
; ft_strlen.s :+: :+: :+: ;
; +:+ +:+ +:+ ;
; By: apuchill <[email protected]> +#+ +:+ +#+ ;
; +#+#+#+#+#+ +#+ ;
; #+# #+# ;
; ### ########.fr ;
; ;
; **************************************************************************** ;
; ------------------------------------------------------------------------------
; FUNCTION PROTOTYPE (man 3 strlen)
; size_t ft_strlen(const char *s)
;
; INPUT
; 1st argument: rdi -> const char *s
;
; OUTPUT
; return: rax -> size_t len
; ------------------------------------------------------------------------------
global ft_strlen
section .text
ft_strlen:
mov rax, -1 ; i = -1
.while_loop:
inc rax ; i++
cmp byte [rdi + rax], 0
jne .while_loop ; while (s[i] != 0)
ret ; return (i)