summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-23 02:22:28 +1100
committerkitty <nepeta@canaglie.net>2026-03-23 02:22:28 +1100
commit3d319290a949768b312e8464b0e5cc0c9a32ae50 (patch)
tree8fb9756628afb4b340563de859c0a520c0caa95c
parent4d9ef994097166a21febb181682c73985089eddd (diff)
fix broken allot, variable
-rw-r--r--readme.md12
-rw-r--r--sanctuary.fs6
2 files changed, 17 insertions, 1 deletions
diff --git a/readme.md b/readme.md
index d21df82..07cb0b6 100644
--- a/readme.md
+++ b/readme.md
@@ -239,6 +239,15 @@ store the 8 bit value u into the memory address a.
### `c@ ( a -- c )`
fetch the 8 bit value at memory address a.
+### `cell+ ( u -- u' )`
+increment u by the size of one cell.
+
+### `cell- ( u -- u' )`
+decrement u by the size of one cell.
+
+### `cells ( u -- u' )`
+transform an amount of cells into an amount of bytes.
+
### `char ( "c" -- c )`
yield the value of the first character of the next word in the input stream.
@@ -429,6 +438,9 @@ write u characters at a to output.
### `until ( ? -- ) IMMEDIATE`
if the given flag is true, loop back to `begin`.
+### `variable ( "name" -- )`
+create a variable word, which yields an address that can be written and read.
+
### `while ( ? -- ) IMMEDIATE`
if given flag is true, continue the current begin-while-repeat loop,
otherwise branch to after.
diff --git a/sanctuary.fs b/sanctuary.fs
index eea702f..f73f052 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -22,7 +22,7 @@
: ?dup dup 0<> if dup then ;
-: allot here swap dp +! ;
+: allot dp +! ;
: ?find ?dup if find 0= if 2drop abort then else abort then ;
: 'h parse-name ?find ;
@@ -32,6 +32,9 @@
: postpone 'h ( word ) dup immediate? if >body compile,
else >body [compile] literal ['] compile, compile, then ; immediate
+: cells 8 * ;
+: cell+ 8 + ;
+: cell- 8 - ;
: create parse-name (header) latest ! ['] (create) compile, 0 , ;
: does> latest @ >body 2 + ['] (does>) over ! \ replace call loc
( replace destination ) 11 + r> swap ! ;
@@ -39,4 +42,5 @@
( but it is actually compiled into the definition and is jumped to )
( by a create does> made word )
: constant create , does> @ ;
+: variable create 1 cells allot ;
bye