planckforth/README.md

48 lines
2.4 KiB
Markdown
Raw Normal View History

2020-12-29 15:05:33 +01:00
# PlanckForth: Bootstrapping Forth from Handwritten Executable
2020-12-28 14:11:20 +01:00
```
$ make
```
2020-12-28 18:16:46 +01:00
2020-12-29 06:51:27 +01:00
```
$ cat helloworld.fs | ./plank
```
2020-12-28 18:16:46 +01:00
# Builtin Words
2020-12-29 09:48:40 +01:00
| code | name | stack effect | semantics |
|:----:|:---------|:---------------|:-----------------------------|
| Q | quit | ( -- ) | Exit the process |
| C | cell | ( -- n ) | The size of Cells |
| h | here | ( -- addr ) | The address of 'here' cell |
| l | latest | ( -- addr ) | The address of 'latest' cell |
2020-12-29 19:18:28 +01:00
| k | key | ( -- c ) | Read character |
| t | type | ( c -- ) | Print character |
2020-12-29 09:48:40 +01:00
| j | jump | ( -- ) | Unconditional branch. |
| J | 0jump | ( a -- ) | Jump if a == 0. |
| f | find | ( c -- xt ) | Get execution token of c |
| x | execute | ( xt -- ... ) | Run the execution token |
| @ | fetch | ( addr -- a ) | Load value from addr |
| ! | store | ( a addr -- ) | Store value to addr |
| ? | cfetch | ( addr -- c ) | Load byte from addr |
| $ | cstore | ( c addr -- ) | Store byte to addr |
| d | dfetch | ( -- addr ) | Get data stack pointer |
| D | dstore | ( addr -- ) | Set data stack pointer |
| r | rfetch | ( -- addr ) | Get return stack pointer |
| R | rstore | ( addr -- ) | Set return stack pointer |
| i | docol | ( -- addr ) | Get the interpreter function |
| e | exit | ( -- ) | Exit current function |
| L | lit | ( -- a ) | Load immediate |
| S | string | ( -- addr len) | Load string literal |
2020-12-29 14:02:40 +01:00
| + | add | ( a b -- c ) | c = (a + b) |
| - | sub | ( a b -- c ) | c = (a - b) |
| * | mul | ( a b -- c ) | c = (a * b) |
| / | div | ( a b -- c ) | c = (a / b) |
| % | mod | ( a b -- c ) | c = (a % b) |
| & | and | ( a b -- c ) | c = (a & b) |
2020-12-29 14:04:19 +01:00
| \| | or | ( a b -- c ) | c = (a \| b) |
2020-12-29 14:02:40 +01:00
| ^ | xor | ( a b -- c ) | c = (a ^ b) |
| < | less | ( a b -- c ) | c = (a < b) |
| = | equal | ( a b -- c ) | c = (a == b) |