Edit this page

Build herkforth from source files

"Source code in files. How quaint." -- Kent Beck

This page describes how to build herkforth from source files. see herkforth bootstrapping for how herkforth recompiles itself.

herkforth is written in herkforth. This is very cool and everything, but it's a bit tricky to get started.

kernel.s contains asm code for the source token interpreter, and just a few words that were needed to get herkforth to start compiling itself.

The files blocks/* contain forth source in a text format very similar to conventional forths. These files include code for the herkforth assembler, many basic forth words and the herkforth interface. These files also include code to completely compile a new version of the forth system and write it to a new ELF file.

build.c parses blocks/* and creates a herkforth dictionary, a data section, and a bunch of herkforth source tokens. (Exactly what the interpreter runs on.) Then merges these into the binary compiled from kernel.s (kernel.s.o) to create a nice big elf file (herkforth000).

When you run herkforth000, the forth kernel from kernel.s executes/compiles the source we had in blocks/* (which was parsed and inserted into the ELF by build.c.) The forth code compiles a new forth kernel and writes it out to a new ELF file herkforth001 along with all the source code we have in the current ELF file. Then it starts executing the new version just as though you had executed herkforth001.

See Also:

herkforth bootstrapping

herkforth add core word

how herkforth works

herkforth docs

herkforth

Edit this page · home ·