-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strchr.s
52 lines (44 loc) · 1.35 KB
/
ft_strchr.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# **************************************************************************** #
# #
# ::: :::::::: #
# ft_strchr.s :+: :+: :+: #
# +:+ +:+ +:+ #
# By: edelangh <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/03/27 15:21:34 by edelangh #+# #+# #
# Updated: 2015/03/27 15:37:54 by edelangh ### ########.fr #
# #
# **************************************************************************** #
section .text
global _ft_strchr
extern _ft_strlen
; rdi sil
; s, c
error:
mov rax, 0
jmp end
_ft_strchr:
enter 16, 0
mov qword [rbp - 8], rdi
mov qword [rbp - 16], 0
cmp rdi, 0
je error
; len untill
mov al, sil
mov rcx, 0
sub rcx, 1
cld
repne scasb
not rcx
sub rcx, 1
checklen:
mov qword [rbp - 16], rcx
mov rdi, qword [rbp - 8]
call _ft_strlen
cmp rax, qword [rbp - 16]
jl error
mov rax, qword [rbp - 16]
add rax, qword [rbp - 8]
end:
leave
ret