- . (also called DOT) prints the top of the stack as an integer in the current BASE.
-*/
-
- defcode ".",1,,DOT
- pop %eax // Get the number to print into %eax
- call _DOT // Easier to do this recursively ...
- NEXT
-_DOT:
- mov var_BASE,%ecx // Get current BASE
-1:
- cmp %ecx,%eax // %eax < BASE? If so jump to print immediately.
- jb 2f
- xor %edx,%edx // %edx:%eax / %ecx -> quotient %eax, remainder %edx
- idivl %ecx
- pushl %edx // Print quotient (top half) first ...
- call _DOT
- popl %eax // ... then loop to print remainder
- jmp 1b
-2: // %eax < BASE so print immediately.
- movl $digits,%edx
- addl %eax,%edx
- movb (%edx),%al // Note top bits are already zero.
- call _EMIT
- ret
- .section .rodata
-digits: .ascii "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
-/*
- Almost the opposite of DOT (but not quite), SNUMBER parses a numeric string such as one returned
- by WORD and pushes the number on the parameter stack.
+ As well as reading in words we'll need to read in numbers and for that we are using a function
+ called SNUMBER. This parses a numeric string such as one returned by WORD and pushes the
+ number on the parameter stack.