25 lines
358 B
NASM
25 lines
358 B
NASM
extern __errno_location
|
|
|
|
section .text
|
|
global ft_read
|
|
ft_read:
|
|
|
|
xor rax, rax
|
|
|
|
syscall
|
|
|
|
cmp rax, 0
|
|
jne syscall_failed
|
|
|
|
ret
|
|
|
|
syscall_failed:
|
|
|
|
neg rax
|
|
mov rbx, rax
|
|
|
|
call __errno_location wrt ..plt
|
|
|
|
mov [rax], rbx
|
|
mov rax, -1
|
|
ret |