Files
libasm/srcs/ft_write.s

23 lines
380 B
ArmAsm

global ft_write
extern __errno_location
section .text
ft_write:
mov rax, 1 ;syscall number for write, args are already set at the right place
syscall
cmp rax, 0 ; if return is < 0, it's an error in negative
jge .success
neg rax ; inv errno, and set errno
mov edi, eax
sub rsp, 8
call __errno_location wrt ..plt
add rsp, 8
mov [rax], edi
mov rax, -1
.success:
ret