libasm/ft_write.s

20 lines
498 B
ArmAsm
Raw Permalink Normal View History

2024-03-11 16:30:24 +00:00
global ft_write
2024-02-26 04:47:24 +00:00
extern __errno_location
ft_write:
mov rax, 1 ; syscall write, other arguments should be good accord to calling convention
syscall
cmp eax, -1 ; linux syscalls errors are always in the range -4095 to -1
jg .done
cmp eax, -4095
jl .done
2024-03-11 16:30:24 +00:00
mov rcx, rax ; save return value of syscall
2024-03-10 19:07:02 +00:00
call __errno_location WRT ..plt ; put address of errno in rax
2024-03-11 16:30:24 +00:00
neg rcx ; errno should be positive
mov [rax], rcx ; set errno
2024-02-26 04:47:24 +00:00
mov rax, -1 ; set return value of ft_write to -1
ret
.done:
ret