summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-20 12:04:09 +1100
committerkitty <nepeta@canaglie.net>2026-03-20 12:04:09 +1100
commit5b62e6f31c9bb2a67672e20af2e6f130251bf0c5 (patch)
tree07368dc989aad9ef8b57420fa4b0872bd456dca8
parente3f99796bc5825f2b2e895960d30cb8c3cce5abd (diff)
d,, branch, ?branch
-rw-r--r--readme.md12
-rw-r--r--sanctuary.s25
2 files changed, 37 insertions, 0 deletions
diff --git a/readme.md b/readme.md
index e4c544f..4280da6 100644
--- a/readme.md
+++ b/readme.md
@@ -108,6 +108,11 @@ in the input buffer.
### `>r ( u -- ) ( R: -- u )`
move a value from the working stack to the return stack.
+### `?branch ( -- )`
+compile into user memory an incomplete conditional branch.
+if the value on the stack is zero the branch is taken.
+a 32 bit branch offset must be written immediately after.
+
### `0= ( n -- ? )`
return true if n is equal to zero.
@@ -141,6 +146,10 @@ duplicate the two topmost values on the stack.
### `and ( u1 u2 -- u )`
perform bitwise AND on u1 and u2.
+### `branch ( -- )`
+compile into user memory an incomplete branch.
+a 32 bit branch offset must be written immediately after.
+
### `brk@ ( -- a )`
yields current program break.
@@ -167,6 +176,9 @@ bytes are copied in low memory to high memory order.
copy u bytes of memory from a1 to a2.
bytes are copied in high memory to low memory order.
+### `d, ( n -- )`
+write a 32 bit value to user memory and increment the user memory pointer.
+
### `dp ( -- a )`
a variable that contains the lowest free byte of memory in user memory.
diff --git a/sanctuary.s b/sanctuary.s
index ec6949b..0d35337 100644
--- a/sanctuary.s
+++ b/sanctuary.s
@@ -725,6 +725,14 @@ defcode ",", comma, 0
mov qword [here], r12
ret
+defcode "d,", d_comma, 0
+ pspop r11
+ mov r12, [here]
+ mov dword [r12], r11d
+ inc r12
+ mov qword [here], r12
+ ret
+
defcode "c,", c_comma, 0
pspop r11
mov r12, [here]
@@ -940,6 +948,23 @@ defcode "0>=", zero_greatereq, 0
ret
; }}}
+defcode "branch", branch, 0
+ mov r12, [here]
+ mov byte [r12], 0xe9
+ inc r12
+ mov qword [here], r12
+ ret
+
+defcode "?branch", q_branch, 0
+ mov r12, [here]
+ mov r11, 0x4d08768d4d1e8b4d ; pspop r11, first bit of test r11, r11
+ mov qword [r12], r11
+ add r12, 8
+ mov dword [r12], 0x840fdb85 ; rest of ^, je
+ add r12, 4
+ mov qword [here], r12
+ ret
+
; TEMPORARY WONKY DEBUGGING FUNCTIONS {{{
; .s {{{
defcode ".s", dots, 0