Mini 0.3: A Simple Single-Pass Compiler

Peter Froehlich <>
13 May 2005 17:59:53 -0400

          From comp.compilers

Related articles
Mini 0.3: A Simple Single-Pass Compiler (Peter Froehlich) (2005-05-13)
| List of all articles for this month |

From: Peter Froehlich <>
Newsgroups: comp.compilers
Date: 13 May 2005 17:59:53 -0400
Organization: Compilers Central
Keywords: available
Posted-Date: 13 May 2005 17:59:53 EDT

Hi all,

I really have no good excuse for this project, but since I thought it
might be helpful for people who are trying to (a) learn how compilers
work or (b) learn the basics of a certain machine, I decided to post
this anyway. :-)

Over the past few weeks, I have written a very simple single-pass
compiler for a very simple imperative programming language called
"Mini" (see link below).

Mini was designed in 1992 by Fridtjof Siebert (of real-time garbage
collection fame) for an introductory article on compiler construction
that he published in a German computer magazine. The language has
integer variables, assignments, expressions with addition and
subtraction, while loops, and (of course) a print instruction. Told
you it's simple. :-)

Fridtjof's original compiler was written in Oberon and generated
Motorola 68000 code for the Commodore Amiga. My implementation is
written in Python and the first version generated code for MIPS (using
SPIM). Since then I have added (very naive) backends for LC-3, MMIX,
PowerPC (under Mac OS X), and Intel IA-32 (under Linux).

Aside from wasting your bandwidth with this announcement, the only real
motivation for this project was to show students in my compiler course
that writing a simple backend is not that hard. As a side effect, I
finally learned Intel assembly myself, something I should have done
years ago but never had the patience for. And I found out that MMIX is
really nice while LC-3 is really crappy. :-)

The project is available for download on my website:

Please scroll to the bottom of that page. The package includes (most
of) the sources and some basic documentation. Let me warn you that both
code and documentation are full of "TODO" notes since I am still in the
middle of working on this. :-)

Feel free to email me your suggestions/patches/flames/examples etc. At
this point I have covered most of the architectures I set out to cover,
but I still expect to add a few more before the year is over.

Peter H. Froehlich <><><><><><>
OpenPGP: ABC2 9BCC 1445 86E9 4D59 F532 A8B2 BFAE 342B E9D9

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.