From 32b694376327dbbdf3fda8c74e21bf69148884e1 Mon Sep 17 00:00:00 2001 From: kitty Date: Fri, 20 Feb 2026 23:27:50 +1100 Subject: forth83 fwd+backwrd MARK and RESOLVE --- jefs.fs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'jefs.fs') diff --git a/jefs.fs b/jefs.fs index 656463e..0bc6c99 100644 --- a/jefs.fs +++ b/jefs.fs @@ -31,12 +31,20 @@ decimal : s" [ char " ] literal 1 >in +! ( skip spc ) [compile] litstring ; immediate : ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another " -: begin here @ ; immediate -: again branch here @ 4 + - d, ; immediate \ add 4 to get to beginning of the next instruction -: until 0branch here @ 4 + - d, ; immediate -: if 0branch here @ 0 d, ; immediate ( I: -- a ) -: else branch here @ 0 d, swap dup here @ swap - 4 - swap d! ; immediate -: then dup here @ swap - 4 - swap d! ; immediate +\ forth83 (got them from pforth tho ehehe) +\ < backward jump > forward jump +\ adding/subtracting 4 gets to the next instruction. +: mark here @ 0 d, ; +: >resolve dup here @ swap - 4 - swap d! ; + +: begin mark ; immediate ( I: -- a ) +: else branch >mark swap >resolve ; immediate +: then >resolve ; immediate : / /mod swap drop ; : mod /mod drop ; @@ -59,4 +67,7 @@ variable hld : (.) dup abs <# #s swap sign #> ; : . (.) say space ; + +\ TODO something is leaking its stack (a word address i think) +t bye -- cgit v1.2.3