From 2796f62735fbdcd3e1a9ec04c477a87d1b12ea08 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Fri, 8 Nov 2024 15:58:55 +0000 Subject: [PATCH] Implement line reading --- postfix.s | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/postfix.s b/postfix.s index c06901f..be2316e 100644 --- a/postfix.s +++ b/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