;; Read user input until next " character is found. Push a string containing the
;; input on the stack as (buffer length). Note that the buffer is only valid
-;; until the next call to S" and that no more than 255 character can be read.
+;; until the next call to S" and that no more than 255 characters can be read.
+;;
+;; [TODO] We want to be able to use this when reading from buffers (e.g. in
+;; INTERPRET-STRING) too!
forth_asm READ_STRING, 'S"'
push rsi
next
forth MAIN, 'MAIN'
+ dq SYSCODE
+ dq INTERPRET_STRING
dq INTERPRET
dq BRANCH, -8 * 2
dq TERMINATE
dq LIT, sysf.len
dq EXIT
+forth INPUT_BUFFER, 'INPUT-BUFFER'
+ dq LIT, input_buffer
+ dq EXIT
+
+forth INPUT_LENGTH, 'INPUT-LENGTH'
+ dq LIT, input_buffer_length
+ dq EXIT
+
segment readable writable
;; The LATEST variable holds a pointer to the word that was last added to the
here dq here_top
here_top rq $4000
+;; Pointer to input buffer and its length. Used as local variable in
+;; INTERPRET-STRING (see bootstrap.asm). [TODO] The code organization is a bit
+;; awkward here.
+input_buffer dq ?
+input_buffer_length dq ?
+
;; Return stack
rq $2000
return_stack_top: