X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=bootstrap.asm;h=1b8b65862947102c2c9117ae73eaf2890219d322;hb=1878070fedd3dec11082913df12a57f97b69cb12;hp=dd72ed9e85e8f53ec96830962457f2f4cd6d8d04;hpb=0cc647dd09fd4a942c1133755e096868d1bd84ff;p=rrq%2Fjonasforth.git diff --git a/bootstrap.asm b/bootstrap.asm index dd72ed9..1b8b658 100644 --- a/bootstrap.asm +++ b/bootstrap.asm @@ -100,3 +100,24 @@ forth INTERPRET, 'INTERPRET' dq READ_WORD dq INTERPRET_WORD dq EXIT + +;; INTERPRET_STRING is a variant of INTERPRET that reads from a string instead +;; of from the user. It takes a string as a (buffer, length) pair on the stack +;; and interprets the entire string, even if the string has more than one word. +forth INTERPRET_STRING, 'INTERPRET-STRING' + dq INPUT_LENGTH, PUT + dq INPUT_BUFFER, PUT + + ;; 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 * 5 ; to EXIT + + dq READ_WORD + + dq INTERPRET_WORD + dq BRANCH, -8 * 7 ; to INPUT-LENGTH @ + + dq LIT, 0, INPUT_BUFFER, PUT + + dq EXIT