summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-20 01:20:19 +1100
committerkitty <nepeta@canaglie.net>2026-03-20 01:20:19 +1100
commit3e8972d7ce7859234d13be9e1949295901ac4806 (patch)
treec33d1759fc1b360ab8efbef0c1a588d2a3ecea95
parenta654a2e0418b0f143cb4d6c55776c844e7254e22 (diff)
char, immediate, and ( bracket comments )
-rw-r--r--readme.md11
-rw-r--r--sanctuary.fs2
-rw-r--r--sanctuary.s18
3 files changed, 30 insertions, 1 deletions
diff --git a/readme.md b/readme.md
index c168abe..f799132 100644
--- a/readme.md
+++ b/readme.md
@@ -28,6 +28,11 @@ create a dictionary header for a word named the provided string.
this word does not set the code field.
this word returns an incompleted xt and does not update latest.
+### `( ( -- ) IMMEDIATE`
+start a comment which lasts until the next closed bracket.
+if the unclosed bracket in the description above bothers you,
+have a closing bracket: ).
+
### `* ( u1 u2 -- u)`
multiply u1 and u2.
@@ -112,6 +117,9 @@ store the 8 bit value u into the memory address a.
### `c@ ( a -- c )`
fetch the 8 bit value at memory address a.
+### `char ( "c" -- c )`
+yield the value of the first character of the next word in the input stream.
+
### `cmove ( a1 a2 u -- )`
copy u bytes of memory from a1 to a2.
bytes are copied in low memory to high memory order.
@@ -152,6 +160,9 @@ grows, and marks as executable, the user memory space by u bytes.
### `here ( -- a )`
yields the address of the first available byte in user memory.
+### `immediate ( -- )`
+mark the most recently defined word as immediate.
+
### `immediate? ( xt -- ? )`
true if xt is marked immediate, false otherwise.
diff --git a/sanctuary.fs b/sanctuary.fs
index 8b13789..a69d973 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -1 +1 @@
-
+: ( [ char ) ] literal parse 2drop ; immediate ( test )
diff --git a/sanctuary.s b/sanctuary.s
index 1b9fd0f..6e5707a 100644
--- a/sanctuary.s
+++ b/sanctuary.s
@@ -484,6 +484,24 @@ defcode "smudge", smudge, 0
mov byte [r12], r13b
ret
+defcode "immediate", immediate, 0
+ mov r12, [latest]
+ add r12, 8
+ mov r13b, [r12]
+ mov r14b, immediate_mask
+ or r13b, r14b
+ mov byte [r12], r13b
+ ret
+
+defcode "char", char, 0
+ call parse_name
+ call drop
+ pspop r12
+ xor r11, r11
+ mov r11b, [r12]
+ pspush r11
+ ret
+
; number {{{
defcode "number", number, 0 ; ( c-addr u -- ?n flag )
pspop r11 ; u