Implement number parsing
This commit is contained in:
parent
4ba2bd48bc
commit
9b7ac43643
19
postfix.s
19
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user