blob: 51bad717725ddc86bd107870241a955d4746eb63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# sanctuary forth (working title)
sanctuary forth is a 64-bit subroutine threaded forth system
for amd64 linux systems.
## stack effect notation
- `a`: memory address
- `c`: one byte value
- `n`: signed integer
- `u`: unsigned integer
- `?`: boolean flag
- `""`: string in input buffer
## Glossary
the following is a list of words available in this forth.
### `#tib ( -- a )`
variable containing the amount of characters in the input buffer.
### `>in ( -- a )`
variable containing the index of the first unparsed character
in the input buffer.
### `brk@ ( -- a )`
yields current program break.
### `bye ( -- )`
exits the forth system.
### `dp ( -- a )`
a variable that contains the lowest free byte of memory in user memory.
### `dp0 ( -- )`
a variable that contains the first byte of user memory.
### `dp$ ( -- )`
a variable that contains the last available byte of user memory.
### `executable ( u a -- )`
marks the u bytes starting at address a as executable.
this is used primarily to mark the program break,
which is used as the user memory space.
### `grow ( u -- )`
grows the user memory space by u bytes.
### `here ( -- a )`
yields the address of the first available byte in user memory.
### `latest ( -- a )`
a variable containing the execution token of
the most recently created word.
### `parse ( "<ws>name<ws>" c -- a u )`
parse one word from the input buffer,
separated by a newline or the character c,
and return as a string.
### `parse-name ( "<ws>name<ws>" -- a u )`
parse one whitespace-separated word from the input buffer,
and return as a string.
tabs (ascii 0x09), newlines (ascii 0x10), and spaces (ascii 0x20)
are considered whitespace.
### `state ( -- a )`
a variable containing a boolean value.
if 0 (false), the system is in interpreting mode,
if -1 (true), the system is in compiling mode.
### `tib ( -- a )`
a variable containing the address of the current input buffer.
### `type ( u a -- )`
write u characters at a to output.
## dictionary format
note that the string length of one byte limits a word's name to 255 characters.
| field | size |
| :---- | :--- |
| link to previous word | 8 bytes |
| flag field | 1 byte |
| string length | 1 byte |
| string | <256 bytes |
| code | variable length |
## reserved registers
the register `r15` is reserved for the parameter stack pointer.
|