summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-02-20 23:27:50 +1100
committerkitty <nepeta@canaglie.net>2026-02-20 23:27:50 +1100
commit32b694376327dbbdf3fda8c74e21bf69148884e1 (patch)
tree8e9c459b4b22d6900b1f0e9b20a52eb6fc7f995f
parent1cd7946e3842f365017764104a6d2164de1fb037 (diff)
forth83 fwd+backwrd MARK and RESOLVE
-rw-r--r--jefs.fs23
1 files changed, 17 insertions, 6 deletions
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 @ ;
+: <resolve here @ 4 + - d, ;
+: >mark here @ 0 d, ;
+: >resolve dup here @ swap - 4 - swap d! ;
+
+: begin <mark ; immediate
+: again branch <resolve ; immediate \ add 4 to get to beginning of the next instruction
+: until 0branch <resolve ; immediate
+: if 0branch >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