Find a file
Koichi Nakamura b32bb02876 add "state"
2021-01-02 10:25:16 +09:00
.gitignore Add .gitignore 2020-12-28 22:11:45 +09:00
core.fs add "state" 2021-01-02 10:25:16 +09:00
helloworld.fs Hello World!!!!!! 2020-12-29 14:51:27 +09:00
LICENSE Modify LICENSE 2020-12-28 22:03:48 +09:00
Makefile Add initial version of planck.xxd 2020-12-28 22:11:20 +09:00
planck.xxd minor fix 2020-12-30 10:09:51 +09:00
README.md fix stack notation 2021-01-02 09:30:51 +09:00

PlanckForth: Bootstrapping Forth from Handwritten Executable

$ git clone https://github.com/nineties/planckforth.git
$ cd planckforth
$ make
$ cat helloworld.fs | ./planck

Builtin Words

code name stack effect semantics
Q quit ( -- ) Exit the process
C cell ( -- n ) The size of Cells
h &here ( -- a-addr ) The address of 'here' cell
l &latest ( -- a-addr ) The address of 'latest' cell
k key ( -- c ) Read character
t type ( c -- ) Print character
j jump ( -- ) Unconditional branch
J 0jump ( n -- ) Jump if a == 0
f find ( c -- xt ) Get execution token of c
x execute ( xt -- ... ) Run the execution token
@ fetch ( a-addr -- w ) Load value from addr
! store ( w a-addr -- ) Store value to addr
? cfetch ( c-addr -- c ) Load byte from addr
$ cstore ( c c-addr -- ) Store byte to addr
d dfetch ( -- a-addr ) Get data stack pointer
D dstore ( a-addr -- ) Set data stack pointer
r rfetch ( -- a-addr ) Get return stack pointer
R rstore ( a-addr -- ) Set return stack pointer
i docol ( -- a-addr ) Get the interpreter function
e exit ( -- ) Exit current function
L lit ( -- n ) Load immediate
S string ( -- c-addr u ) Load string literal
+ 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)
| or ( a b -- c ) c = (a | b)
^ xor ( a b -- c ) c = (a ^ b)
< less ( a b -- c ) c = (a < b)
= equal ( a b -- c ) c = (a == b)