muFORTH

Home

I wrote muFORTH to explore some implementation techniques (a simple native code compiler for the x86, tail recursion), and the idea of building a small kernel, with just enough bits in it to bootstrap itself, by loading more Forth code from source.

I started working on it in 2002; in 2005, after unsuccessfully trying to “port” the simple compiler to the PowerPC, so a friend with a Mac could try the system, I rewrote the core to be an odd hybrid of C code and indirect-threaded Forth. Now it is (hopefully) completely portable.

The MuforthReadme – though outdated in some 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 MuforthReadme was written, but much of it is still true, applicable, and hopefully of interest.

In addition to the stated goal of exploring implementations, one of the primary reasons for writing muFORTH was to replace the very unportable Linux-specific Forth – dforth – that I had been using to do target compilation (for embedded control applications). I’m very interested in writing target compilers, hosted on muFORTH, for the ARM and AVR architectures. I’ve done some of the work already; both are in the master branch of the git repo; see target/ARM/ and target/AVR/. I'm about to launch into writing some support for Freescale's HCS08 as well.

Getting the code

The code is hosted on github - one of several options for HostingGitRepositories. It is possible to browse it there, or (better by far!) to clone the github repo by first installing a local copy of git, and then executing the command:

   git clone git://github.com/nimblemachines/muforth.git

This will create a local directory called muforth/, which, because of git's distributed nature, contains not only the latest checkout of the master branch, but also muFORTH's entire development history. I kept a development diary for a while, but now the best annotated history is the git commit comments, which you can browse (on github), or read (from your cloned repo) using git log or git log -p (if you want to see diffs).

Using git takes some getting used to, but for following muFORTH's development it's pretty much trivial. When you feel like it (or when you see on github that new changes are available) simply cd into muforth/ and do

   git pull

This will do two things:

  • fetch the latest commits from github's master branch and put them into your local repo in refs/remotes/origin/master; and
  • merge refs/remotes/origin/master into your master branch

Git keeps branches that follow remote branches (like refs/remotes/origin/master) separate from branches (like master) that you could do local development in. It sounds complicated, but it makes sense and keeps things much cleaner.

I heartily recommend using git on projects where you have a choice. Having gone from CVS to Subversion to git, I couldn't be happier, and will never go back. Because conversion is a bit tricky, I wrote a page about UsingGitSvn to get code out of Subversion and into git.

Enjoy muFORTH and git!

I gave a talk!

In March 2008 I gave a talk about bootstrapping, muFORTH, and ConvivialTools.

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


Recent posts

  • A "new" muFORTH blog? So, I tried an experiment. It was painful and awful and mostly a failure. But it's not completely over. It could turn out rosy and beautiful.I created a ...
    Posted 14 Jan 2009 23:17 by Xenotrash Firemonster
  • Deep in a multi-stage bootstrap I'm trying something slightly crazy, and progress is going slowly.I want to get Forth and a simple USB bootloader running on Freescale's S08JM parts. But instead of ...
    Posted 14 Jan 2009 17:02 by Xenotrash Firemonster
  • I missed an historic moment I'm working on porting Forth to Freescale's 908 and 9S08 parts. I got my first samples in 2006, got discouraged, and stopped working on the project. For mostly ...
    Posted 24 Dec 2008 19:49 by Xenotrash Firemonster
  • Why am I bothering with Freescale's HCS08? If I had any sense, I would be using Atmel AVR parts. Why do I say this? there are a bunch of folks in dorkbotpdx using Atmel AVR, including building ...
    Posted 19 Dec 2008 17:56 by Xenotrash Firemonster
  • Freescale USB parts are on their way My samples of the S08JM16 and S08JM32 parts are on their way. Sadly I don't have a way, when they arrive, of doing anything with them. I lack the ...
    Posted 24 Dec 2008 19:42 by Xenotrash Firemonster
  • Great minds think alike Once I finally understood what a Benito board was, I started thinking "well, that's pretty neat, but it lacks any ADC on-chip; otherwise it would make a nice ...
    Posted 14 Dec 2008 11:18 by Xenotrash Firemonster
  • I'm supposed to be working on muFORTH But it seems I'm spending time, instead, farting around with this silly site, and silly Sites. I discovered that I can subvert, to some degree, the lack of an ...
    Posted 12 Dec 2008 20:00 by Xenotrash Firemonster
  • I am already pretty disillusioned with Google Sites But, hey, the site is up, and it might be a useful resource for people, for now.I have three major beefs with Sites:their HTML is awful, and posting ...
    Posted 14 Jan 2009 13:51 by Xenotrash Firemonster
  • Changes coming I'm doing all this - enduring the pain of understanding how Sites work and trying to make the best of it - so that I can start working on muFORTH again ...
    Posted 11 Dec 2008 01:15 by Xenotrash Firemonster
  • Created this goofy place to host a few pages about muFORTH I needed a place to put an introduction to muFORTH so I could modify the git sources to point there instead of ... nowhere, which is currently where they point.I ...
    Posted 11 Dec 2008 01:28 by Xenotrash Firemonster
Showing posts 1 - 10of 10. View more »