What is muforth?

muforth is a small, simple, fast, indirect-threaded code (ITC) Forth intended for use as a cross-compiler for microcontrollers and other embedded devices. It is written in C and its core is very portable. Because of its Forth nature, it is naturally extensible, scriptable, and customizable.

It is very well-suited to interactive coding, debugging, and exploration, and is a great tool for bringing up new hardware.

It has support – in varying degrees of completeness – for the following architectures:

Why yet another Forth?

I initially wrote muforth because I wanted to try out some implementation ideas. Today there is very little that distinguishes muforth from fig-FORTH – but the differences go rather deep.

Its implementation is no longer the point. Its sole reason for existing is to be a cross/meta/target-compiler for other Forths, and their implementations are in no way tied to muforth’s.

Get the source

The code is hosted at Github. It’s super easy to build; just look at BUILDING.

It’s BSD licensed, so do what you want with it! I’d love to hear about innovative or unusual uses of muforth.

Documentation

The code – both the C code that implements the Forth virtual machine and the muforth code that does everything else – is carefully and in some cases extensively (even obsessively!) commented. Right now your best source of documentation is the code! Luckily for you, there isn’t that much, so reading it is actually possible. That’s part of the point of muforth; I want it to be a convivial tool.

The key to the system is the Forth code that muforth reads when it first starts: startup.mu4. You’ll learn a lot by reading this!

Look in mu/target/ to find a target that interests you. There is generally a mu/target/<target>/build.mu4 that loads the cross-build environment. Use it as an “index” to find the assembler, disassembler, meta-compiler, kernel, and other key pieces of code.

NOTE: The state of muforth’s documentation will get much better! Especially if I hear feedback about how terrible it is. ;-)

News and history

For breaking news, follow @muforth.

The muforth blog is made up of yearly journal pages. Read them here:

The original README – though outdated in many ways – is a good introduction to why I wrote muforth and what I was trying to achieve. It describes the native-code compiler version of the system. That, and a few other things – notably create/does, the tokeniser, and the lack of tail-recursion in the threaded version – have changed since the README was written, but much of it is still true, applicable, and hopefully of interest.

Talks

In March 2008 I gave a talk about bootstrapping, muforth, and convivial tools.

A warning: I wave my arms around a lot, and the audio isn’t that great, but you might find it amusing.