summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-20 12:10:36 +1100
committerkitty <nepeta@canaglie.net>2026-03-20 12:10:36 +1100
commit29bec09ee2dfe8d29a32c605daca50d5d7661f0e (patch)
treeae69a95e9db927ec923ce41c48fea4e1ea2fc8a1
parent5b62e6f31c9bb2a67672e20af2e6f130251bf0c5 (diff)
base words
-rw-r--r--readme.md16
-rw-r--r--sanctuary.fs5
2 files changed, 21 insertions, 0 deletions
diff --git a/readme.md b/readme.md
index 4280da6..9257664 100644
--- a/readme.md
+++ b/readme.md
@@ -146,6 +146,13 @@ duplicate the two topmost values on the stack.
### `and ( u1 u2 -- u )`
perform bitwise AND on u1 and u2.
+### `base ( -- a )`
+a variable containing the current numeric input/output base.
+by default this is 10.
+
+### `binary ( -- )`
+set current base to binary.
+
### `branch ( -- )`
compile into user memory an incomplete branch.
a 32 bit branch offset must be written immediately after.
@@ -179,6 +186,9 @@ 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.
+### `decimal ( -- )`
+set current base to decimal.
+
### `dp ( -- a )`
a variable that contains the lowest free byte of memory in user memory.
@@ -211,6 +221,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.
+### `hex ( -- )`
+set current base to hexadecimal.
+
### `immediate ( -- )`
mark the most recently defined word as immediate.
@@ -295,6 +308,9 @@ a variable containing the address of the current input buffer.
### `type ( a u -- )`
write u characters at a to output.
+### `octal ( -- )`
+set current base to octal.
+
### `over ( u1 u2 -- u1 u2 u1 )`
copy the second-highest value on the stack and move it to the top of the stack.
diff --git a/sanctuary.fs b/sanctuary.fs
index e40527c..9ed0e61 100644
--- a/sanctuary.fs
+++ b/sanctuary.fs
@@ -1,3 +1,8 @@
: \ 10 parse 2drop ; immediate \ test
: ( [ char ) ] literal parse 2drop ; immediate ( test )
+
+: binary 2 base ! ;
+: octal 8 base ! ;
+: decimal 10 base ! ;
+: hex 16 base ! ;
bye