summaryrefslogtreecommitdiff
path: root/jefs.fs
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-02-22 21:35:25 +1100
committerkitty <nepeta@canaglie.net>2026-02-22 21:35:25 +1100
commit5eac185f15817e6011b5ffd4e6b30098d8911f79 (patch)
tree32cca4d2077fc0c43e15e204e3787da59e8c5b3a /jefs.fs
parent18c92540a18cca417d4c276ce424a8e2828dfd99 (diff)
move assembler below branching, ?dup
Diffstat (limited to 'jefs.fs')
-rw-r--r--jefs.fs44
1 files changed, 23 insertions, 21 deletions
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 @ ;
+: <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 - ;