-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_atoi.s
56 lines (47 loc) · 1.33 KB
/
ft_atoi.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
53
54
55
56
# **************************************************************************** #
# #
# ::: :::::::: #
# ft_atoi.s :+: :+: :+: #
# +:+ +:+ +:+ #
# By: edelangh <edelangh@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/03/26 14:01:28 by edelangh #+# #+# #
# Updated: 2015/03/27 18:18:47 by edelangh ### ########.fr #
# #
# **************************************************************************** #
section .text
global _ft_atoi
;rdi rsi rdx
isneg:
mov rcx, 1
inc rbx
jmp while
_ft_atoi:
enter 0, 0
mov rax, 0
test rdi, rdi
jz end
push rbx
mov rbx, 0
cmp byte [rdi + rbx], '-'
je isneg
mov rcx, 0
while:
cmp byte [rdi + rbx], '9'
jg endwhile
cmp byte [rdi + rbx], '0'
jl endwhile
imul rax, 10
add al, [rdi + rbx]
sub al, '0'
inc rbx
jmp while
endwhile:
cmp rcx, 0
je signed
neg rax
signed:
pop rbx
end:
leave
ret