-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_puts.s
63 lines (52 loc) · 1.42 KB
/
ft_puts.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
57
58
59
60
61
62
63
# **************************************************************************** #
# #
# ::: :::::::: #
# ft_puts.s :+: :+: :+: #
# +:+ +:+ +:+ #
# By: edelangh <edelangh@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/03/23 18:52:04 by edelangh #+# #+# #
# Updated: 2015/03/24 15:16:01 by edelangh ### ########.fr #
# #
# **************************************************************************** #
%define SYSCALL(n) 0x2000000 | n
%define WRITE 4
section .data
nl db 10
null db "(null)", 0
section .text
global _ft_puts
extern _ft_strlen
; rdi rsi rdx
; edi esi edx
_ft_puts:
push rbp
mov rbp, rsp
cmp rdi, 0
jne print
mov rdi, null
print:
push rdi
call _ft_strlen
pop rdi
mov r8, rdi
push rdi
push rsi
push rbx
mov rdi, 1
mov rsi, r8
mov rdx, rax
mov rax, SYSCALL(WRITE)
syscall
printnl:
mov rdi, 1
mov rsi, nl
mov rdx, 1
mov rax, SYSCALL(WRITE)
syscall
pop rdi
pop rbx
pop rsi
mov rax, 10
pop rbp
ret