summaryrefslogtreecommitdiff
path: root/readme.md
diff options
context:
space:
mode:
Diffstat (limited to 'readme.md')
-rw-r--r--readme.md78
1 files changed, 73 insertions, 5 deletions
diff --git a/readme.md b/readme.md
index a13df97..7b813cd 100644
--- a/readme.md
+++ b/readme.md
@@ -3,6 +3,8 @@
sanctuary is a 64-bit subroutine threaded forth for amd64 linux systems.
## stack effect notation
+labels outside of the ones listed here are specific to a certain word's
+documentation and will be obvious or documented in the description.
- `a`: memory address
- `c`: one byte value
@@ -59,6 +61,9 @@ create a dictionary header for a word named the provided string.
this word does not set the code field.
this word does not update latest.
+### `(hide) ( ht -- )`
+set the smudge bit on the header ht.
+
### `* ( u1 u2 -- u )`
multiply u1 and u2.
@@ -354,6 +359,9 @@ yields the address of the first available byte in user memory.
### `hex ( -- )`
set current base to hexadecimal.
+### `hide ( "word" -- )`
+set the smudge bit on the given word.
+
### `hijacks ( xt "word" -- )`
'hijack' an existing definition to perform the action of xt.
this word *will* corrupt the dictionary if used outside
@@ -385,6 +393,12 @@ the most recently created word.
### `literal ( n -- ) IMMEDIATE COMPILE-ONLY`
compile a push of the literal value n into the currently compiling word.
+### `mmap ( offset fd flags prot u a -- u ) `
+perform a mmap(2) system call.
+
+### `munmap ( u a -- u ) `
+perform a munmap(2) system call.
+
### `nip ( u1 u2 -- u2 )`
drop the second-highest value from the stack.
@@ -419,6 +433,17 @@ if the word is immediate, that will execute the word at runtime
(like `[compile]`).
if the word is not immediate, this will compile code that compiles that word.
+### `private{ ( -- )`
+mark the start of a private section closed by `}private`
+and activated with `privatise`.
+
+### `}private ( -- )`
+mark the end of a private section opened by `private{`
+and activated with `privatise`.
+
+### `privatise ( -- )`
+activate a private section.
+
### `r> ( -- u ) ( R: u -- )`
move a value from the return stack to the working stack.
@@ -448,6 +473,11 @@ converted to a null-terminated string.
### `smudge ( -- )`
toggles the smudge bit on the xt in latest.
+### `sp ( -- a )`
+yield the address of the stack pointer.
+note that the address points to the stack *before*
+this value is pushed.
+
### `state ( -- a )`
a variable containing a boolean value.
if 0 (false), the system is in interpreting mode,
@@ -456,17 +486,25 @@ if -1 (true), the system is in compiling mode.
### `stderr ( -- 2 )`
push the file descriptor of stderr to the stack.
-### `sp ( -- a )`
-yield the address of the stack pointer.
-note that the address points to the stack *before*
-this value is pushed.
+### `stdin ( -- 0 )`
+push the file descriptor of stdin to the stack.
### `stdout ( -- 1 )`
push the file descriptor of stdout to the stack.
-### `swap ( u1 u2 -- u2 u1 )`
+### `swap ( u1 u2 -- u2 u1 )`
swap the two topmost values on the stack.
+### `sys-read ( u a fd -- n )`
+perform a `read(2)` system call, reading into the buffer `u a`
+from file descriptor `fd`.
+n is the resulting value of the register `rax`.
+
+### `sys-write ( u a fd -- n )`
+perform a `write(2)` system call, writing the string `u a`
+to file descriptor `fd`.
+n is the resulting value of the register `rax`.
+
### `syscall0 ( rax -- u )`
perform the syscall with the id in `rax`,
and push the value of the `rax` register to the stack.
@@ -486,6 +524,21 @@ perform the syscall with the id in `rax`,
taking three parameters placed in `rdi`, `rsi` and `rdx`,
and push the value of the `rax` register to the stack.
+### `syscall4 ( r10 rdx rsi rdi rax -- u )`
+perform the syscall with the id in `rax`,
+taking four parameters placed in `rdi`, `rsi`, `rdx` and `r10`,
+and push the value of the `rax` register to the stack.
+
+### `syscall5 ( r8 r10 rdx rsi rdi rax -- u )`
+perform the syscall with the id in `rax`,
+taking five parameters placed in `rdi`, `rsi`, `rdx`, `r10` and `r8`,
+and push the value of the `rax` register to the stack.
+
+### `syscall6 ( r9 r8 r10 rdx rsi rdi rax -- u )`
+perform the syscall with the id in `rax`,
+taking six parameters placed in `rdi`, `rsi`, `rdx`, `r10`, `r8` and `r9`,
+and push the value of the `rax` register to the stack.
+
### `then ( -- ) IMMEDIATE COMPILE-ONLY`
conclude an if statement.
@@ -506,6 +559,21 @@ below the second highest value on the stack.
### `type ( a u -- )`
write u characters at a to output.
+### `u< ( u1 u2 -- ? )`
+return true if u1 is less than u2.
+
+### `u<= ( u1 u2 -- ? )`
+return true if u1 is less than or equal to u2.
+
+### `u<> ( u1 u2 -- ? )`
+return true if u1 and u2 are not equal.
+
+### `u> ( u1 u2 -- ? )`
+return true if u1 is greater than u2.
+
+### `u>= ( u1 u2 -- ? )`
+return true if u1 is greater than or equal to u2.
+
### `until ( ? -- ) IMMEDIATE COMPILE-ONLY`
if the given flag is true, loop back to `begin`.