Implement number parsing

This commit is contained in:
Camden Dixie O'Brien 2024-11-08 16:52:44 +00:00
parent 4ba2bd48bc
commit 9b7ac43643

View File

@ -39,6 +39,25 @@ wordloop:
jmp wordloop jmp wordloop
doword: 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) ## Go back to start if the terminating character (which is in R8)
## of the word was a line feed ## of the word was a line feed
cmp $0x0a, %r8 cmp $0x0a, %r8