Implement line reading

This commit is contained in:
Camden Dixie O'Brien 2024-11-08 15:58:55 +00:00
parent 7487f22ea6
commit 2796f62735

View File

@ -1,7 +1,32 @@
.text
.global _start
_start:
mov $buf, %rsi
readloop:
## Read character in.
mov $0, %rax
mov $0, %rdi
mov $1, %rdx
syscall
## Check return value; exit if not equal to one.
cmp $1, %rax
jne exit
## Move read character into RAX and increment buffer position.
movzx (%rsi), %rax
inc %rsi
## Loop if read character wasn't a line feed.
cmp $0x0a, %rax
jne readloop
exit:
## Exit with code 0
mov $60, %rax
mov $0, %rdi
syscall
.bss
buf:
.skip 100