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