FORTH86 is an implementation of forthress, a FORTH dialect as described in Igor Zhirkov's Low Level Programming. This implementation is currently a work in progress, which I hopefully will finish by the end of January 2023.
the interpreter's done. doesn't have colon words.
Please report any bugs that you find, the interpreter is still in its early/alpha stage.
Happy hacking! 😁
Have git
, make
and nasm
installed on your machine (At&T syntax with as
compilation soon mayhaps?)
$ git clone https://github.com/icebarf/FORTH86
$ cd FORTH86
$ make newbuild
$ ./forthress
- Cell Size: 8 bytes
- Memory Cells: 65536 bytes
- Input Buffer: 1024 bytes
- Return Address Stack: 1024 * 'Cell Size' bytes
q
quit the interpreterdo_colon
perform a colon worddo_exit
exit from a colon wordbye
quit the interpreter, exit code is taken from data stack toplast
load the pointer to the last word defined on data stackstate
load the state i.e compiler or interpreter mode on data stack
.
Pops off an integer from stack top, and prints it.S
Print all data stack contentskey
read a one byte from stdin to data stack ( -- c)emit
write a byte to stdout from data stack (c -- )number
read a signed 64-bit integer from stdin ( -- N)word
read a word (in ascii) from stdin and store it at addr, also store word length on data stack (addr -- len)prints
print a string, pointer to string is taken from data stackcount
count the number of characters in a null-terminated string
N
any integer, is pushed to the data stack+
-
*
/
%
=
pop two arguments, compares them, writes1
on equality, otherwise 0not
complement of top argument on the data stack (should be 0 or 1)and
logical and, writes 1 if both condition satisfy, oterhwise 0or
logical or<
less than>
greater than<=
less than and equals>=
greater than and equalsfalsy
checks if value is falsy. Anything non-zero is a truthy value. writes 1 if truthy, otherwise 0
rot
moves 3rd element to top, pushes down the first two (a b c -- b c a)swap
swaps the top two elements on the data stackdup
duplicates the element on data stack top (a -- a a)drop
drops the top element on data stack (a -- )
mem
store FORTH machine starting memory address on data stack!
(address data -- ) store data from stack starting at addressc!
(address char -- ) store a single byte at address@
(address -- value) read one memory cell and store that value on stackc@
(address -- char ) reads a byte from address and store that value on the stack.
Kinda getting bored, might drop it. Althought I'm still interested in writing the compiler.