add: ft_read
This commit is contained in:
parent
a05124885e
commit
174a587414
@ -8,3 +8,4 @@ size_t ft_strlen(const char *str);
|
|||||||
int ft_strcmp( const char *first, const char *second);
|
int ft_strcmp( const char *first, const char *second);
|
||||||
ssize_t ft_write(int fd, const void *buf, size_t count);
|
ssize_t ft_write(int fd, const void *buf, size_t count);
|
||||||
char *ft_strdup(const char *s);
|
char *ft_strdup(const char *s);
|
||||||
|
ssize_t ft_read(int fildes, void *buf, size_t nbyte);
|
25
src/ft_read.asm
Normal file
25
src/ft_read.asm
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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
|
Loading…
Reference in New Issue
Block a user