From: Jonas Hvid Date: Sun, 8 Mar 2020 18:32:16 +0000 (+0100) Subject: Finish implementing embedded sys.f X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=7677dbbdce584a64e63946b39879f5edd114f36a;p=rrq%2Fjonasforth.git Finish implementing embedded sys.f 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! --- diff --git a/bootstrap.asm b/bootstrap.asm index bd0cc15..1b8b658 100644 --- a/bootstrap.asm +++ b/bootstrap.asm @@ -111,11 +111,13 @@ forth INTERPRET_STRING, 'INTERPRET-STRING' ;; 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 diff --git a/impl.asm b/impl.asm index 070ad2a..f6a25cf 100644 --- a/impl.asm +++ b/impl.asm @@ -177,6 +177,9 @@ pop_word: jmp .read_alpha .end: + ;; Finally, we want to skip one whitespace character after the word. + inc rsi + dec rcx ret diff --git a/main.asm b/main.asm index 4e1a05f..a670b34 100644 --- a/main.asm +++ b/main.asm @@ -452,10 +452,6 @@ read_string_buffer: ;; 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] diff --git a/sys.f b/sys.f index 6b13ff9..0815e0f 100644 --- a/sys.f +++ b/sys.f @@ -83,5 +83,7 @@ EXIT [ ( Read a number from standard input. ) : READ-NUMBER READ-WORD PARSE-NUMBER ; +S" Ready." TELL NEWLINE + ( vim: syntax=forth )