Here's the Day-9 Stuff
Here's the content relating to my Day-9 programming language and
the attendant compiler(s) and library code. Visit the main page
for compiler-related links.
New in August 2003: Uploaded a reasonably complete manual for the
Day-9 language. Doesn't cover the compiler, just the language. Find
it here.
Overview
Compiler |
Libraries
Zip Picker
Changelog
OVERVIEW
The Day-9 Compiler is something I've been working on off and on
for almost two (three? I don't know anymore) years now; I estimate
about three solid months of actual work went into the creation of
the original compiler, and several more into the various updates
since then. (Its name refers to its position in a nine-day
"tutorial" I started work on in summer 2001; day 1 was Turing
machines, day 3 was complex RPN interpreters, and day 9 was a
bootstrapped compiler system.)
Find a reference for the language here.
The compiler system itself consists of several parts, developed
pretty much in tandem:
- The preprocessor, PREP, written in C.
- The assembler, ASM90, written in C.
- The original compiler, NEW1, written in C.
- The original bootstrap, NEW2, written in antique Day-9.
- The development compiler, GECKO, written in Day-9.
- Library code for user programs, written in Day-9.
- Optional modules to extend the language, written in assembler.
Covering each part of the system in turn:
- PREP is simply a retarded version of the standard Unix
CPP. There is really no reason to use it, except that I
wrote it myself.
- ASM90 is a table-driven assembler for any 8- or 16-bit
processor, which translates opcodes using a user-supplied table
("RET"->C3 and so on). It also has limited support for compile-
time constant expressions, which are exploited by the compiler. The
output of the compiler is tailored to this assembler, although a bit
of hacking could easily allow a different assembler to be used.
- NEW1 is an antique Day-9 compiler, written in C. If you're
unsure of what a certain construct is supposed to do, you may be
better off looking at NEW1's source code. It produces the
same output as NEW2, with a few trivial differences. [Note: the
official development compiler is now "Gecko", which is substantially
different from NEW1 in many respects. However, "Gecko" accepts
a superset of the antique language accepted by "New1", rather than an
entirely different language.]
- NEW2 is the actual bootstrap compiler, written entirely
in the Day-9 language itself. NEW1 will compile NEW2,
and NEW2 will compile itself. The translation from C to
Day-9 was done pretty much mechanically, so you'll be able to trace
the logic fairly easily. [Note: NEW2 will compile
GECKO.NEW, and "Gecko" will compile GECKO.D9;
however, this functionality may disappear in the future.]
- The Day-9 project's libraries, written in Day-9, are free source.
Every routine in the libraries was coded by yours truly, although I
believe the random-number algorithm is due to someone else. These
libraries are required to compile NEW2: stdlib,
stdio, string, files.
- The Day-9 project's "module" capability was something I added at
the last minute; I haven't worked out all its applications yet.
Essentially, including an assembler module pastes a chunk of assembler
code at the very beginning of your program, which is executed every
time your program runs. Currently, there is a module that parses
command-line arguments, a module that replaces the rand
library, and a module that replicates the DOS file functions
findfirst and findnext. The argv and
findf libraries are required to compile NEW2
properly; although no warning is produced if you don't include them,
the program will not run properly without them.
THE COMPILER
Here is where you can download the compiler system itself.
To make updating this site easier, I've put everything up in
pieces. For instance, there's an ASM90 zip, a NEWSRC
zip, and a NEWLIB zip, all of which need to be downloaded
to compile the compiler itself. (And you may want CSRC
or PREP, too.) To compile the C sources, I use Turbo C 2.0;
I believe DJGPP should work for most of them, though.
Here are the distributions, which list what they assume you have:
- Download PREP.ZIP, the useless preprocessor.
Contains C source [DJGPP, TCC] and binary.
- Download ASM90.ZIP, the new and improved
assembler, and its 80x86 opcode tables. Contains C source
[TCC], binary, and tables.
- Download CSRC.ZIP, the C source to
NEW1.
Contains C source [DJGPP, TCC] and binary.
- Download NEWLIB.ZIP, the Day-9 library
source code and the existing assembler modules for NEW2.
- Download NEWSRC.ZIP, the Day-9 source
to NEW2. Contains Day-9 source and bootstrapped binary.
- Download GECKOSRC.ZIP, the "Gecko"
Day-9 compiler. The "Gecko" compiler extends the antique language by
allowing almost every form of assignment statement that C does, plus
pre- and post-increment and -decrement operators. The internal code
generation is much better, and a memory bug in the code has been fixed.
Contains NEW2-compatible source, "Gecko"-compatible source,
and bootstrapped binaries.
- Download GECKOLIB.ZIP, the
"Gecko"-compatible library source code and the same assembler modules
as NEWLIB.ZIP. You don't need these libraries if you have
NEWLIB.ZIP already, but some of them do compile to smaller
executable code.
THE LIBRARIES
You can also view the online code to the Day-9 libraries.
Unfortunately, Geocities
is stupid, so you'll just have to pretend that the files have
extensions .D9 and .INC, respectively.
ZIP PICKER
So you want to start using Day-9, but you don't know how to start?
Here's what you need to download in order to...
Bootstrap the entire Day-9 project
- 1. Compile the CSRC version using an ANSI C
compiler.
- 2. Compile the NEWSRC version using PREP,
CSRC, and the NEWLIB package.
- 3. Assemble the NEWSRC version using ASM90
and the included HEX2BIN utility.
- 4. Compile the first GECKOSRC version using the
NEWSRC compiler. Assemble it the same way.
- 5. Compile the second GECKOSRC version using the
first GECKOSRC version. Assemble it.
- 6. Congratulate yourself!
If you are a relatively experienced assembly programmer
and want some interesting work, why not send me some more
library code? Even better, I'd like to see what other
people can do with "Day-9" itself. Perhaps someone could
extend the language in new directions, add floating-point
support (while preserving the typelessness of the language
-- that's a challenge!), or something else entirely.
[I'd like to see user-defined structures (a la C's structs)
added to the language, but at the moment I don't see how
they'd fit in.]
Have fun, whatever you do.
Back to the main page
Back to Top
This page last updated
22 Aug 2003
All code and documentation related to the Day-9
Compiler Project is freely redistributable.
Information Longs to be Free.