42-archive/libftasm/srcs/ft_cat.s
Jack Halford 8e29c2c26b bugger
2017-09-03 11:55:53 +02:00

35 lines
536 B
ArmAsm

global _ft_cat
global ft_cat
extern ft_putchar
%define STDOUT 1
%define BUFF_SIZE 10
section .bss
buf: resb BUFF_SIZE
section .text
_ft_cat: ; void ft_cat(int fd)
ft_cat:
push rdi
lea rsi, [rel buf]
mov rdx, BUFF_SIZE
mov rax, READ ; int read(int fd, void *buf, size_t count)
syscall
cmp rax, 0
jle end
mov rdi, STDOUT
mov rdx, rax
mov rax, WRITE ; int write(int fd, const void *buf, size_t count)
syscall
cmp rax, 0
jl end
pop rdi
jmp ft_cat
end:
pop rax
ret