diff options
| author | kitty <nepeta@canaglie.net> | 2026-02-20 23:27:50 +1100 |
|---|---|---|
| committer | kitty <nepeta@canaglie.net> | 2026-02-20 23:27:50 +1100 |
| commit | 32b694376327dbbdf3fda8c74e21bf69148884e1 (patch) | |
| tree | 8e9c459b4b22d6900b1f0e9b20a52eb6fc7f995f | |
| parent | 1cd7946e3842f365017764104a6d2164de1fb037 (diff) | |
forth83 fwd+backwrd MARK and RESOLVE
| -rw-r--r-- | jefs.fs | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -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 |
