diff options
Diffstat (limited to 'ft_read.s')
| -rw-r--r-- | ft_read.s | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -12,8 +12,36 @@ global ft_read +%define F_GETFD 1 +%define SYSCALL_READ 0x2000003 +%define SYSCALL_FCNTL 0x200005c + ; int ft_read(int, void*, size_t); ft_read: - mov rax, 0x2000003 + cmp rdx, 0 + je FT_READ_NO_SIZE + cmp rdi, 0 + jl FT_READ_ERROR + cmp rsi, 0 + je FT_READ_ERROR + + push rdx + push rsi + xor rsi, rsi + mov esi, F_GETFD + mov rax, SYSCALL_FCNTL + syscall + pop rsi + pop rdx + cmp eax, 0 + jne FT_READ_ERROR + + mov rax, SYSCALL_READ syscall ret +FT_READ_ERROR: + mov rax, -1 + ret +FT_READ_NO_SIZE: + xor rax, rax + ret |
