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
qquit the interpreterdo_colonperform a colon worddo_exitexit from a colon wordbyequit the interpreter, exit code is taken from data stack toplastload the pointer to the last word defined on data stackstateload the state i.e compiler or interpreter mode on data stack
.Pops off an integer from stack top, and prints it.SPrint all data stack contentskeyread a one byte from stdin to data stack ( -- c)emitwrite a byte to stdout from data stack (c -- )numberread a signed 64-bit integer from stdin ( -- N)wordread a word (in ascii) from stdin and store it at addr, also store word length on data stack (addr -- len)printsprint a string, pointer to string is taken from data stackcountcount the number of characters in a null-terminated string
Nany integer, is pushed to the data stack+-*/%
=pop two arguments, compares them, writes1on equality, otherwise 0notcomplement of top argument on the data stack (should be 0 or 1)andlogical and, writes 1 if both condition satisfy, oterhwise 0orlogical or<less than>greater than<=less than and equals>=greater than and equalsfalsychecks if value is falsy. Anything non-zero is a truthy value. writes 1 if truthy, otherwise 0
rotmoves 3rd element to top, pushes down the first two (a b c -- b c a)swapswaps the top two elements on the data stackdupduplicates the element on data stack top (a -- a a)dropdrops the top element on data stack (a -- )
memstore 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.