-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_strlen.s
26 lines (22 loc) · 1.22 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
; **************************************************************************** #
; #
; ::: :::::::: #
; ft_strlen.s :+: :+: :+: #
; +:+ +:+ +:+ #
; By: ebourdit <marvin@42.fr> +#+ +:+ +#+ #
; +#+#+#+#+#+ +#+ #
; Created: 2021/01/04 11:25:01 by ebourdit #+# #+# #
; Updated: 2021/01/04 11:33:34 by ebourdit ### ########.fr #
; #
; **************************************************************************** #
global ft_strlen
ft_strlen:
xor rcx, rcx ; on copie 0 dans rcx
loop:
cmp byte [rdi + rcx], 0 ; si rsi[rcx] == '\0' --> ZF = 1
jz return ; si ZF = 1 on va à return
inc rcx ; sinon on incremente rcx
jmp loop ; boucler loop
return:
mov rax, rcx ; on copie rcx dans rax car c'est rax qu'on renvoie
ret ; return rax