Implement line reading
This commit is contained in:
parent
7487f22ea6
commit
2796f62735
25
postfix.s
25
postfix.s
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user