Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
Clone or download
Permalink
Failed to load latest commit information.
contrib Run some benchmarks from Gforth. Jul 12, 2016
doc Document the metacompiling build process. Nov 20, 2017
experiments Some hash functions. Nov 23, 2017
lib Hooks for compiler targets. Nov 20, 2017
lisp @ 40b99c0 Fix problems bootstrapping with CLISP. Mar 28, 2017
src Move definition of h-[defined]. Dec 14, 2017
targets fix Nov 20, 2017
test fix Nov 20, 2017
.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 Makefile target for generating web files. Apr 25, 2017
.gitlab-ci.yml Move test-related files to test directory. Jul 31, 2017
.gitmodules Fix Lisp metacompiler submodule URL. Apr 25, 2017
.scrutinizer.yml Move test-related files to test directory. Jul 31, 2017
.travis.yml Move test-related files to test directory. Jul 31, 2017
INSTALL Improve build instructions. May 31, 2016
LICENSE GPL3 May 19, 2015
Makefile Split off kernel-specific code from metacompiler. Nov 20, 2017
PITCHME.md Add information about the cross compiler. Sep 29, 2017
README.md Add information about the cross compiler. Sep 29, 2017
appharbor.sln Make AppVeyor do both x32 and x64 builds. Oct 22, 2015
appveyor.yml Update Cygwin to 2.2.1. Nov 4, 2015
bitrise.yml Move Bitrise configuration to a file. Aug 1, 2017
build.md Move Bitrise configuration to a file. Aug 1, 2017
build.vcxproj AppVeyor build workarounds: Apr 5, 2017
circle.yml Move test-related files to test directory. Jul 31, 2017
configure Fixes to build with an ARM host. Jul 21, 2016
packages.config Update Cygwin to 2.2.1. Nov 4, 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, RISC-V, Motorola 68000, PDP-11, and asm.js targets. There is a cross compiler for 6502, 8051, AVR, Cortex-M, MSP430, PDP-8, PIC, and STM8.

( 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.