From 04a6784de4827b1617dbe0650345b0b737253124 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 25 Mar 2020 08:39:44 -0400 Subject: [PATCH] forth: Forth-ify "(sysv)" --- forth/core.fs | 13 +++++++++++++ forth/forth.asm | 43 +++++++++---------------------------------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/forth/core.fs b/forth/core.fs index 746ace4..a6a0ed1 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -71,3 +71,16 @@ COMPILE R> COMPILE DROP COMPILE R> COMPILE DROP ; IMMEDIATE +( WARNING: there are no limit checks. We must be cautious, in + core code, not to create more than SYSV_BUFSIZE/2 sys vars. + Also: SYSV shouldn't be used during runtime: SYSVNXT won't + point at the right place. It should only be used during + stage1 compilation. This is why this word is not documented + in dictionary.txt ) + +: (sysv) + (entry) + ROUTINE Y [LITN] , + SYSVNXT @ , + 2 SYSVNXT +! +; diff --git a/forth/forth.asm b/forth/forth.asm index c4e1952..8fc7cdc 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -1269,41 +1269,9 @@ ENTRYHEAD: jp next -; WARNING: there are no limit checks. We must be cautious, in core code, not -; to create more than SYSV_BUFSIZE/2 sys vars. -; Also: SYSV shouldn't be used during runtime: SYSVNXT won't point at the -; right place. It should only be used during stage1 compilation. This is why -; this word is not documented in dictionary.txt - .db "(sysv)" - .fill 1 - .dw $-ENTRYHEAD - .db 0 -SYSV: - .dw compiledWord - .dw ENTRYHEAD - .dw NUMBER - .dw sysvarWord - .dw WR - .dw NUMBER - .dw SYSVNXT - .dw FETCH - .dw WR - ; word written, now let's INC SYSVNXT - .dw NUMBER ; a - .dw SYSVNXT - .dw DUP ; a a - .dw FETCH ; a a@ - .dw NUMBER ; a a@ 2 - .dw 2 - .dw PLUS ; a a@+2 - .dw SWAP ; a@+2 a - .dw STORE - .dw EXIT - - .db "HERE" .fill 3 - .dw $-SYSV + .dw $-ENTRYHEAD .db 0 HERE_: ; Caution: conflicts with actual variable name .dw sysvarWord @@ -1331,10 +1299,17 @@ FLAGS_: .dw sysvarWord .dw FLAGS + .db "SYSVNXT" + .dw $-FLAGS_ + .db 0 +SYSVNXT_: + .dw sysvarWord + .dw SYSVNXT + ; ( n a -- ) .db "!" .fill 6 - .dw $-FLAGS_ + .dw $-SYSVNXT_ .db 0 STORE: .dw nativeWord