From 5eac185f15817e6011b5ffd4e6b30098d8911f79 Mon Sep 17 00:00:00 2001 From: kitty Date: Sun, 22 Feb 2026 21:35:25 +1100 Subject: move assembler below branching, ?dup --- jefs.fs | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'jefs.fs') diff --git a/jefs.fs b/jefs.fs index 2e80721..faf96ae 100644 --- a/jefs.fs +++ b/jefs.fs @@ -23,6 +23,29 @@ hex : ret, c3 c, ; decimal : constant create [compile] lit ret, ; : variable 1 cells allot create [compile] lit ret, ; +\ TODO interpret mode strings? +: s" [ char " ] literal 1 >in +! ( skip spc ) [compile] litstring ; immediate +: ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another " + +\ jump helpers from 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 +: while 0branch >mark ; immediate +: repeat branch swap resolve ; immediate + +: ?dup dup 0<> if dup then ; + \ https://wiki.osdev.org/X86-64_Instruction_Encoding \ see dusk os asm/x86.fs \ my idea is that operands are given in the reverse order that @@ -91,27 +114,6 @@ decimal \ mod r/m reg /2 r/m 1.011 (r11) decimal ] ; -\ TODO interpret mode strings? -: s" [ char " ] literal 1 >in +! ( skip spc ) [compile] litstring ; immediate -: ." [compile] s" ' say compile, ; immediate \ lol this word breaks the highlighting, here have another " - -\ jump helpers from 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 -: while 0branch >mark ; immediate -: repeat branch swap resolve ; immediate - : / /mod swap drop ; : mod /mod drop ; : negate 0 swap - ; -- cgit v1.2.3