From 9b7ac43643d4d1e55ec5bfa6905199e0064aebeb Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Fri, 8 Nov 2024 16:52:44 +0000 Subject: [PATCH] Implement number parsing --- postfix.s | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/postfix.s b/postfix.s index f33339a..8ee2c57 100644 --- a/postfix.s +++ b/postfix.s @@ -39,6 +39,25 @@ wordloop: jmp wordloop doword: + mov $0, %rax + mov $0, %rcx +numloop: + ## Multiply current value by ten + imul $10, %rax + + ## Add numeric value of digit + movzx (%rsi, %rcx), %rbx + sub $0x30, %rbx + add %rbx, %rax + + ## Increment index and loop if not at end of word + inc %rcx + cmp %rcx, %rdx + jg numloop + + push %rax + +endword: ## Go back to start if the terminating character (which is in R8) ## of the word was a line feed cmp $0x0a, %r8