summaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-03-19 18:52:59 +1100
committerkitty <nepeta@canaglie.net>2026-03-19 18:52:59 +1100
commitae2bb07e11ce6582cc9c7d45d1b8137c355e9db7 (patch)
tree7d97c829a1b6e50737119996a3545f2f9293a91c /readme.md
parente8d44270cde4c9e3149cde0ab9ae6bf58cd05578 (diff)
math stuff
Diffstat (limited to 'readme.md')
-rw-r--r--readme.md39
1 files changed, 33 insertions, 6 deletions
diff --git a/readme.md b/readme.md
index 43b0da8..7e93f2f 100644
--- a/readme.md
+++ b/readme.md
@@ -1,7 +1,6 @@
# sanctuary (working title)
-sanctuary is a 64-bit subroutine threaded forth system
-for amd64 linux systems.
+sanctuary is a 64-bit subroutine threaded forth for amd64 linux systems.
## stack effect notation
@@ -26,6 +25,26 @@ 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.
+### `* ( u1 u2 -- u)`
+multiply u1 and u2.
+
+### `*/mod ( n1 n2 n3 -- n4 n5 )`
+multiply n1 and n2, divide the result by n3.
+remainder is in n3, result is in n4
+
+### `+ ( u1 u2 -- u )`
+add u2 to u1.
+
+### `- ( u1 u2 -- u )`
+subtract u2 from u1.
+
+### `-rot ( u1 u2 u3 -- u3 u1 u2 )`
+rotate the three topmost values on the stack so that the topmost value
+is moved to the third highest.
+
+### `/mod ( u1 u2 -- u3 u4 )`
+divide u1 by u2. result is in u4, remainder is in u3.
+
### `[ ( -- ) IMMEDIATE`
set the system to interpret mode.
@@ -38,10 +57,6 @@ start compilation of the word 'name'.
### `; ( -- ) IMMEDIATE`
end compilation of the currently compiling word.
-### `-rot ( u1 u2 u3 -- u3 u1 u2 )`
-rotate the three topmost values on the stack so that the topmost value
-is moved to the third highest.
-
### `>body ( xt -- a )`
yield the code field of xt.
@@ -58,6 +73,9 @@ remove the two topmost values from the stack.
### `2dup ( u1 u2 -- u1 u2 u1 u2 )`
duplicate the two topmost values on the stack.
+### `and ( u1 u2 -- u )`
+perform bitwise AND on u1 and u2.
+
### `brk@ ( -- a )`
yields current program break.
@@ -103,6 +121,9 @@ true if xt is marked immediate, false otherwise.
interprets the contents of the terminal input buffer
until it runs out.
+### `invert ( u -- u')`
+invert all bytes in u.
+
### `latest ( -- a )`
a variable containing the execution token of
the most recently created word.
@@ -115,6 +136,9 @@ convert given string into a number along with a flag.
if parsing a number fails then 0 (false) is returned
and no number is provided.
+### `or ( u1 u2 -- u )`
+perform bitwise OR on u1 and u2.
+
### `parse ( "name<c>" c -- a u )`
parse one word from the input buffer,
separated by a newline or the character c,
@@ -174,6 +198,9 @@ write u characters at a to output.
### `over ( u1 u2 -- u1 u2 u1 )`
copy the second-highest value on the stack and move it to the top of the stack.
+### `xor ( u1 u2 -- u )`
+perform bitwise XOR on u1 and u2.
+
## dictionary format
note that the string length of one byte limits a word's name to 255 characters.