-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_read.s
More file actions
28 lines (25 loc) · 1.28 KB
/
ft_read.s
File metadata and controls
28 lines (25 loc) · 1.28 KB
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
; **************************************************************************** ;
; ;
; ::: :::::::: ;
; ft_read.s :+: :+: :+: ;
; +:+ +:+ +:+ ;
; By: lrocca <marvin@42.fr> +;+ +:+ +;+ ;
; +;+;+;+;+;+ +;+ ;
; Created: 2021/04/03 15:14:17 by lrocca ;+; ;+; ;
; Updated: 2021/04/03 15:14:19 by lrocca ;;; ;;;;;;;;.fr ;
; ;
; **************************************************************************** ;
section .text
global _ft_read
extern ___error
_ft_read:
mov rax, 0x02000003 ; set system call for read
syscall ; invoke operating system
jc error ; if carry flag exists, there was an err
ret ; if everything went well, rax was set automatically
error:
push rax ; save errno
call ___error ; set rax to errno pointer
pop qword [rax] ; set errno
mov rax, -1 ; set ret to -1
ret