MMIXware: A RISC Computer for the Third Millennium

by Donald E. Knuth (Heidelberg: Springer-Verlag, 1999), viii+550pp.
(Lecture Notes in Computer Science, no. 1750.)
ISBN 978-3-540-66938-8
e-ISBN 978-3-540-46611-6
DOI 10.1007/3-540-46611-8

(A Japanese translation by Tooru Takizawa was published in 2002 by SiBaccess Co. Ltd.)

MMIX is a RISC computer designed by the author to illustrate machine-level aspects of programming. In the next editions of his books The Art of Computer Programming, MMIX will replace the 1960s-style machine MIX. A particular goal in the design of MMIX was to keep its machine language simple, elegant, and easy to learn. At the same time, all of the complexities needed to achieve high performance in practice were also taken into account, so that MMIX could in principle be built and even be competitive with some of the fastest general-purpose machines on the market. All in all, MMIX is a clean, complete, and well-documented machine-independent machine ideally suited as a testbed for long-term research projects of lasting value, even as real computers continue to change rapidly.

This book is a collection of programs written in CWEB that make MMIX a virtual reality. Among other utilities, an assembler converting MMIX symbolic files to MMIX objects and two simulators executing the programs in given object files are provided. Of particular interest is the MMMIX meta-simulator, which is able to do dynamic scheduling of a complex pipeline, allowing superscalar execution with any number of functional units and with many varieties of caching and branch prediction, etc., including a detailed implementation of both hard and soft interrupts.

The main purpose of this book is to provide a complete documentation of the MMIX computer and its assembly language, together with all necessary low-level details such as the format of MMIX object files. A secondary purpose is to provide literate programs of interest in their own right. For example, a full implementation of IEEE standard floating point arithmetic is developed in terms of 32-bit integer arithmetic, including new routines for floating point input and output that deliver the maximum possible accuracy. The meta-simulator includes a tutorial presentation about pipelines, comparing the processing to the activities in a high-tech automobile repair shop.

All programs of this book are in the public domain, and their final versions can be downloaded together with dozens of example programs from The Art of Computer Programming. The right-hand pages of this book contain exclusive mini-indexes, which greatly facilitate reading the programs at one’s desk or in a comfortable chair. There also is a general master index covering the entire book.

Available from the publisher, Springer Verlag, Inc..

ONLINE VERSION (pdf format)

Errata

A thoroughly revised printing was issued by the publisher in 2014. It corrected numerous errors and infelicities of the original printing of 1999, thanks to the sharp eyes and wits of many volunteers who checked everything carefully.

The revised printing precisely matches MMIX Version 1.0, as documented in the master software dated 17 October 2013, so it is 100% bug-free by definition. Anything in Version 1.0 that isn't really right should be regarded as a "feature" of this frozen version, to be worked-around as necessary but never to be corrected.

(Well, actually a few bugs have been found in the sources of version 1.0; and they aren't hard to patch, so I've installed them on the version that I use at home:

page 78, line $-3$ of section 35
change 100000 to 800000
page 83. line 8 of section 49
change $2^{54}+2^{53}-1$ to $2^{54}+2^{53}-4$
page 83, line 12 of section 49
change $d>53$ to $d>54$
page 115, lines 13 and 15
delete these lines (which declare buffer and buf_pointer)
page 116, insert two lines after line 6
static char buffer[BUF_SIZE]; /* input lines go here */
static char *buf_pointer=buffer; /* this is our current position */
page 133, line 3
change bus_words to mem_bus_bytes (twice)
page 150, line 5
change mmix_pipe.h to mmix-pipe.h
page 176, line 7
change "23–27." to "23–27, followed by rG (19) and rA (21) packed into eight bytes."
page 238, in section 203 before startup
insert c->outbuf.rank=c->bb; /* this many valid bytes */
page 239, line 9 of section 205
change c->tagmask to -c->bb
page 244, line 15
change Scache->bb-c->bb to Scache->bb-c->outbuf.rank
page 244, second line of case 3 should become three lines
if (block_diff) @<Copy |Scache->inbuf| to slot |p| 220@>
else for (j=0;j<Scache->bb>>3;j++) d->data[j]=c->outbuf.data[j];
for (j=0;j<Scache->bb>>Scache->g;j++) p->dirty[j]=false;
page 252, lines 2, 22, 32; also page 264, line 18
change (j=get_reader(Dcache)<0) to (j=get_reader(Dcache))<0
page 264, just before if (Dcache->flusher.next)
insert the following two lines (copied from section 261):
if (Dcache->filler.next) goto write_restart;
if ((Scache&&Scache->lock)||(!Scache&&mem_lock)) goto write_restart;
page 264, just before set_lock(self,wbuf_lock)
insert the following new line:
Dcache->outbuf.rank=Dcache->gg; /* this many valid bytes */
page 271, line 1
change "four positions" to "five positions"
page 296, line 23
change "flags[internal_op[hot->op]]" to "flags[hot->op]"
page 334, line 26
change "equivalent to g22" to "equivalent to g21"
page 396, line 6 from the bottom
change (g[rU].h&0x7fff==0) to ((g[rU].h&0x7fff)==0)
page 452, lines 7 and 8 of the assemble routine become seven lines
if (spec_mode) {
   l=spec_mode_loc;
   if (l&(k-1)) {
     if (held_bits==1 && k==2) spec_mode_loc=l=l+1,hold_buf[1]=0,held_bits=3;
     else spec_mode_loc=l=(l+k)&-k,mmo_clear();
   }
} else {
page 486, in case ESPEC
insert   if (held_bits) mmo_clear();   before goto bypass
page 500, lines 15 and 16
change 90 to f0
page 519, line 14
replace this line by four lines:
if (listing) {
  time_t t=tet;
  printf("File was created %s",asctime(localtime(&t)));
}

I don't really like to use software that contains known bugs, even if they are "frozen". Click here to download the version of 25 Nov 2023 that I use at home.)

Henceforth I must devote full time to The Art of Computer Programming. However, further developments are being undertaken by an excellent group of volunteers in Germany, who have organized up-to-date MMIX home pages.

Special Offer (While Supplies Last)!

Anybody who discovers a genuine bug in the MMIX software, representing a contribution to Versions 2 or higher, will receive an MMIX T-shirt, courtesy of Addison-Wesley Publishing Company. Multiple bugs entitle you to multiple T-shirts. (You should send bug reports to Germany, as mentioned above, not to me. The people there will dispense one or more T-shirts, if they accept your contribution.) Please specify whether you prefer size L or XL.

Don Knuth’s home page

Don Knuth’s other books

Valid HTML 4.01 Transitional