|[interactive fiction] [programming]||[all tags] [all pages] [home]|
Damn. I should know better than to say things like that.
About a year later, after several false starts, I had successfully written a back end for Volker Barthelmann's VBCC C compiler that targeted the Z-machine. It does varargs, 32-bit ints, signed and unsigned variables, everything. It will, basically, compile ordinary ANSI C into Z-machine assembler ready for including in your game. It doesn't do floating point support (but I have an idea about that), and there is no libc, so you have to do everything from scratch.
You can get it here.
Note that because of the licensing restrictions on vbcc (which is really neat, by the way; it's got excellent global optimisations, an easy-to-understand back end interface, is small and incredibly fast; if you're interested in compilers for embedded systems, take a look) I can't distribute it with my changes. What I can do is to distribute the original source code plus a patch containing all my alterations, so that's what you get here.
These links, by the way, are hosted on Interactive Fiction Archive, because it's got way more bandwidth than I do. Check it out.
The original unmodified source.
Once the patch is applied the compiler should build relatively straightforwardly.
Debian users should note that you can get a prebuilt version on my Debian repository. I'm working on getting it included in the main Debian archive.
For an example of a complicated project that uses it, see my game Silicon Castles which is written in a combination of Inform and C. It also contains a stripped down libc I stole from the ELKS Embedded Linux project.
Now, remember I said earlier about there being a few false starts? Well, on the way I had several interesting and entertaining encounters with some compilers...
Firstly, lcc. lcc is a freeish retargetable ANSI C compiler for several systems, including Windows. Before I discovered vbcc, lcc was my best bet. However, the lcc back end interface is pretty naff and is only partially documented, so I never finished anything. Interested parties might want to look at my code.
zcom.tar.gz (10.1 kB)
The final version of the lcc Z-machine code generator. Does not work.
glulx.c.gz (3.2 kB)
Before doing the Z-machine code generator, I had a look at Andrew Plotkin's Glulx virtual machine instead. This is a code generator for Glulx. Does not work, but works a lot better than the zcom code generator; you can actually compile a reasonable number of programs with this. You'll need the Glulxa assembler to compile the output.
|Page last updated: 2015 January 25||© 2008-2013 David Given, unless specified otherwise|