summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-02-14 19:34:57 +1100
committerkitty <nepeta@canaglie.net>2026-02-14 19:34:57 +1100
commit8f339f837f5a6a38d47691327f32d1f5a3675930 (patch)
tree04314bc795808c934e526dbc88cf434f5fd9d05f
parent6d671bbc2c014357c23e5ff7a61311abf2663d7b (diff)
branch!!
-rw-r--r--jefs.fs6
-rw-r--r--jefs.s24
-rw-r--r--readme.md2
3 files changed, 29 insertions, 3 deletions
diff --git a/jefs.fs b/jefs.fs
index 345d31a..38c2c5f 100644
--- a/jefs.fs
+++ b/jefs.fs
@@ -1,6 +1,12 @@
+: begin here @ ; immediate
+: again branch here @ 4 + - d, ; immediate
+
: / /mod swap drop ;
: mod /mod drop ;
: syswrite ( u c-addr fd -- n ) 1 syscall3 ;
: say ( c-addr u -- ) swap 1 syswrite drop ;
+\ : saying begin TESTSTR say again ;
+HEREDUMP
+\ saying bye
TESTSTR say bye
diff --git a/jefs.s b/jefs.s
index 71854b4..05598a0 100644
--- a/jefs.s
+++ b/jefs.s
@@ -117,6 +117,14 @@ defword ",", comma, 0
mov qword [here], r12
ret
+defword "d,", d_comma, 0
+ pspop r11
+ mov r12, [here]
+ mov dword [r12], r11d
+ add r12, 4
+ mov qword [here], r12
+ ret
+
defword "w,", w_comma, 0
pspop r11
mov r12, [here]
@@ -543,8 +551,8 @@ defword "+", plus, 0
defword "-", minus, 0
pspop r11
pspop r12
- sub r11, r12
- pspush r11
+ sub r12, r11
+ pspush r12
ret
defword "*", _times, 0
@@ -616,6 +624,18 @@ defword "immediate", immediate, 0
mov byte [r12], r13b
ret
+; e9 [00 00 00 00] relative 32 bit immediate, relative to *instruction after jump*!
+; note: the dummy value must be provided *by the calling word*
+defword "branch", branch, 0
+ mov r12, [here]
+ mov byte [r12], 0xe9
+ inc r12
+ mov qword [here], r12
+ ret
+
+; defword "0branch", zerobranch, 0
+; ret
+
; TEMPORARY HORRIBLE DEBUGGING BULLSHIT {{{
; debugging word; outputs raw bytes so needs to be piped through `x(x)d`
; terrible and awful
diff --git a/readme.md b/readme.md
index 252e909..dc3d234 100644
--- a/readme.md
+++ b/readme.md
@@ -20,7 +20,7 @@ the dictionary follows a fairly standard format.
## the one reserved register
the working stack pointer is `r14`.
-the other registers are used as general purpose registers
+the other registers are used as general purpose registers;
`r11` in particular is the standard register used in
compiling calls.