planckforth/README.md

38 lines
1.7 KiB
Markdown
Raw Normal View History

2020-12-28 14:11:20 +01:00
# PlanckForth: Bootstrapping Forth from Handwritten Binary
```
$ 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 08:01:10 +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 |
| k | key | ( -- n ) | Read character |
| t | type | ( n -- ) | Print character |
| 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 |
2020-12-29 08:17:00 +01:00
| r | rfetch | ( -- addr ) | Get return stack pointer |
| R | rstore | ( addr -- ) | Set return stack pointer |
2020-12-29 08:44:54 +01:00
| { | dtor | ( a -- R:a ) | Push value to return stack |
| } | rtod | ( R: -- a ) | Pop value from return stack |
2020-12-29 09:29:12 +01:00
| i | docol | ( -- addr ) | Get the interpreter function |
2020-12-29 09:33:30 +01:00
| e | exit | ( -- ) | Exit current function |