From 89a89b9892804084146903c5eb8cc01d32542bba Mon Sep 17 00:00:00 2001 From: kitty Date: Tue, 10 Mar 2026 02:46:57 +1100 Subject: EXIT (finally) it's immediate unlike in ANS forth, because it literally just puts a C3 into the current definition. --- jefs.fs | 8 +++++--- readme.md | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jefs.fs b/jefs.fs index e8dfd99..567b3aa 100644 --- a/jefs.fs +++ b/jefs.fs @@ -148,6 +148,8 @@ decimal rex.w r14, r14 8 d) lea, r11 call, ] ; +: exit ret, ; immediate + : ?comp state @ 0<> if 3 error ! handler execute then ; : ?intr state @ if 4 error ! handler execute then ; @@ -315,7 +317,7 @@ stdin buffers-fd ! : buffer-refill ( u|0 ) cbuffer /buffer cbuffer-fd @ read-file 0<> if 0 then 0 cbuffer->in ! dup cbuffer-used ! ; \ returns zero on error or nothing read. : buffer-empty? cbuffer->in @ cbuffer-used @ >= ; -: buffer-key ( key|-1 ) buffer-empty? if buffer-refill 0= if -1 [ ret, ] then then +: buffer-key ( key|-1 ) buffer-empty? if buffer-refill 0= if -1 exit then then cbuffer cbuffer->in @ + c@ cbuffer->in @ 1+ cbuffer->in ! ; \ this is profoundly horrible and ugly @@ -335,9 +337,9 @@ hide truncate-(accept-n) 2048 constant line-buffer-length make line-buffer line-buffer-length allot -: refill ( -- ? ) source-id 0< if false [ ret, ] then +: refill ( -- ? ) source-id 0< if false exit then 0 >in ! line-buffer tib ! line-buffer line-buffer-length accept - 0= if dup 0= if #tib ! false [ ret, ] then then #tib ! true ; + 0= if dup 0= if #tib ! false exit then then #tib ! true ; \ todo?: reset retstack : quit 0 to source-id [compile] [ begin refill while interpret ." ok" cr repeat ; diff --git a/readme.md b/readme.md index 4b9a52f..2760c75 100644 --- a/readme.md +++ b/readme.md @@ -25,6 +25,7 @@ this does not follow any standards. here are some things to keep in mind - `create` can't be used for arrays and stuff. use `make` instead - `:noname` is called `:>` (based on duskos). it also just creates a word called `_` and pushes its xt to the stack - an `include` discards the rest of the input line +- `exit` is immediate (it compiles a `ret` into the definition) ## the one reserved register -- cgit v1.2.3