diff options
| -rw-r--r-- | jefs.fs | 44 |
1 files changed, 23 insertions, 21 deletions
@@ -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 @ ; +: <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 +: while 0branch >mark ; immediate +: repeat branch swap <resolve >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 @ ; -: <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 -: while 0branch >mark ; immediate -: repeat branch swap <resolve >resolve ; immediate - : / /mod swap drop ; : mod /mod drop ; : negate 0 swap - ; |
