mirror of
https://github.com/Noratrieb/asm-coreutils.git
synced 2026-01-15 02:05:03 +01:00
cat works
This commit is contained in:
parent
7a02913e36
commit
5e9b9783de
1 changed files with 5 additions and 5 deletions
10
src/cat.asm
10
src/cat.asm
|
|
@ -1,4 +1,5 @@
|
||||||
extern open_file_arg
|
extern open_file_arg
|
||||||
|
extern println_num
|
||||||
|
|
||||||
global _start
|
global _start
|
||||||
|
|
||||||
|
|
@ -29,23 +30,22 @@ _start:
|
||||||
cmp rax, 0
|
cmp rax, 0
|
||||||
jl file_not_found
|
jl file_not_found
|
||||||
|
|
||||||
mov rdi, rax
|
mov r12, rax
|
||||||
jmp init
|
jmp init
|
||||||
|
|
||||||
stdin_init:
|
stdin_init:
|
||||||
mov rdi, STDIN_FD
|
mov r12, STDIN_FD
|
||||||
|
|
||||||
init:
|
init:
|
||||||
; the input fd is in rdi at this point
|
; the input fd is in r12 at this point
|
||||||
xor r13, r13
|
|
||||||
process:
|
process:
|
||||||
; read in from the file
|
; read in from the file
|
||||||
|
mov rdi, r12
|
||||||
mov rax, 0
|
mov rax, 0
|
||||||
mov rsi, io_buf
|
mov rsi, io_buf
|
||||||
mov rdx, IO_BUF_SIZE
|
mov rdx, IO_BUF_SIZE
|
||||||
syscall
|
syscall
|
||||||
|
|
||||||
; test whether it is finished
|
|
||||||
cmp rax, 0
|
cmp rax, 0
|
||||||
jz finish
|
jz finish
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue