frth
frth copied to clipboard
Frth is a subroutine threaded Forth system written in Forth itself for the targets x86, x64 and 68k on Linux and macOS among others.
Frth
Frth is a subroutine threaded Forth system written in Forth itself for the targets x86, x64 and 68k on Linux, macOS, Atari ST and Amiga 500. All targets are self-relocating and can therefore load into memory at any address.
Targets
System | Processor |
---|---|
Linux | x86, x64 |
macOS | x86, x64 |
Atari ST | 68k |
Amiga 500 | 68k |
Options
Usage: frth [option]... [input]...
Options:
--help Display this help and exit.
-v, --verbose Print verbously.
-e, --evaluate <expr> Evaluate Forth expression.
-t, --target <target> Compile for given target.
-o, --output <file> Compile to output image.
Compiling to an output image requires a target. Providing a target
without giving an output image has no effect. Valid targets are:
linux/x64 linux/x86
macos/x64 macos/x86
atari/68k amiga/68k
Compiling
Since Frth is written in Forth, another Forth system, for example Gforth, is needed to compile Frth the first time. Once Frth has been compiled, it can recompile or cross-compile itself for any target. To compile Frth for Linux/x64 one can for example do
% gforth -e "fpath+ $PWD" contrib/gforth.fth -e bye -- -o frth-linux-x64 --target linux/x64
where the arguments after --
are forwarded to the Frth emulation. After
this first compilation Frth can recompile itself, for example to macOS/x64:
% ./frth-linux-x64 -o frth-macos-x64 --target macos/x64
Testing
There is a test suite with 460 tests, many of them based on the
Forth 2012 Standard. These can
be run by giving test/test.fth
as a command input argument, or by giving
include test/test.fth
at the Forth prompt.
Licence
Copyright © 2017 Fredrik Noring. See the LICENCE file.