Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, 68000, PDP-11.
Forth Makefile Emacs Lisp Shell C Batchfile Other
Permalink
Failed to load latest commit information.
contrib Run some benchmarks from Gforth. Jul 12, 2016
doc Add Atari GEMDOS Reference Manual. Jan 18, 2016
experiments Simple cooperative multitasking. Jun 7, 2016
lib Fix SAVE-IMAGE, and add a test for it. Sep 26, 2016
lisp @ 6fa133a Fix bug when host cell size is not same as target. Aug 22, 2016
src 64-bit cells need wider output in DUMP. Sep 29, 2016
targets Document key bindings. Sep 23, 2016
test Update some files from Gerry Jackson's Forth 2012 test suite. Oct 6, 2016
.drone.yml Build x86 Linux target in continuous integration services. Dec 29, 2015
.gdbinit Update .gdbinit for the new x86 word header structure. Feb 2, 2016
.gitattributes OPEN-FILE file name doesn't have to be NUL-terminated. Nov 23, 2015
.gitignore Add a simple configure script. Feb 4, 2016
.gitlab-ci.yml Automatic build and test with GitLab CI. Oct 4, 2016
.gitmodules Move Lisp metacompiler to separate submodule. Sep 30, 2013
.magnum.yml Build x86 Linux target in continuous integration services. Dec 29, 2015
.scrutinizer.yml Build x86 Linux target in continuous integration services. Dec 29, 2015
.travis.yml Test PDP-11 target in Travis. Aug 23, 2016
INSTALL Improve build instructions. May 31, 2016
LICENSE GPL3 May 19, 2015
Makefile Include targets subdirectory in installation. Sep 29, 2016
README.md Document key bindings. Sep 23, 2016
appharbor.sln Make AppVeyor do both x32 and x64 builds. Oct 22, 2015
appveyor.yml Update Cygwin to 2.2.1. Nov 4, 2015
build.md Automatic build and test with GitLab CI. Oct 4, 2016
build.vcxproj Build x86 Windows target in continuous integration services. Dec 29, 2015
check.mk Fix SAVE-IMAGE, and add a test for it. Sep 26, 2016
circle.yml Build x86 Linux target in continuous integration services. Dec 29, 2015
configure Fixes to build with an ARM host. Jul 21, 2016
install-deps.sh Automatic build and test with GitLab CI. Oct 4, 2016
packages.config Update Cygwin to 2.2.1. Nov 4, 2015
wercker.yml Build x86 Linux target in continuous integration services. Dec 29, 2015

README.md

( Subset of Forth94 )

This is a self-hosted implementation of Forth, which can regenerate itself from Forth source code. The bootstrapping process uses a metacompiler written in Lisp to target a small inner interpreter and a handful of code words written in C. A new metacompiler written in Forth generates an x86 executable using using assembly language code words.

There are also ARM, Motorola 68000, and PDP-11 targets, and target assemblers for 6502, AVR, MSP430, and Emacs bytecodes.

( Continuous integration )

The code is continuously built and tested in Linux, MacOS X, and Windows using several cloud-based continuous integration services. This is documented in build.md.

( Further reading )

INSTALL \ How to build.
doc \ Classic (and recent) texts not related to this project.
lib/README \ Information about libraries.
targets/README.md \ Information about current and possibly future targets.

( Implementation guide )

The Forth kernel contains everything needed to read and compile the rest of the system from source code, and not much else. It's composed of two parts: a target-specific file nucleus.fth containing all primitive CODE words, and a target-independent kernel.fth. These two are compiled by the metacompiler.

The C target nucleus used for bootstrapping has only twelve proper primitives. There is also the COLD word which compiles to main(), and four I/O words.

When the kernel starts, it jumps to the word called WARM. This is responsible for loading the rest of the system and entering the text interpreter. The first file loaded by WARM is core.fth, which implements the CORE wordset. Because the kernel only has a bare minimum of words, the start of core.fth looks a little strange.