OK, this works... barely!
We have to omit the final newline in sys.f for it to work. We should probably
take another look at that.
But, it does technically work: We can now run just ./main, and the sys.f file
will be run automatically from inside the program. Very cool!
;; Check if the buffer is-non-empty
;; [TODO] This probably won't work for strings with whitespace at the end.
dq INPUT_LENGTH, GET
- dq ZBRANCH, 8 * 7 ; to EXIT
+ dq ZBRANCH, 8 * 5 ; to EXIT
dq READ_WORD
dq INTERPRET_WORD
dq BRANCH, -8 * 7 ; to INPUT-LENGTH @
+ dq LIT, 0, INPUT_BUFFER, PUT
+
dq EXIT
jmp .read_alpha
.end:
+ ;; Finally, we want to skip one whitespace character after the word.
+ inc rsi
+ dec rcx
ret
;; We borrow READ_STRING's buffer. They won't mind.
mov [READ_STRING.length], 0
- ;; Skip space ([TODO]: Shouldn't we do this while parsing instead?)
- inc [input_buffer]
- dec [input_buffer_length]
-
.read_char:
mov rbx, [input_buffer]
mov al, [rbx]
( Read a number from standard input. )
: READ-NUMBER READ-WORD PARSE-NUMBER ;
+S" Ready." TELL NEWLINE
+
( vim: syntax=forth
)