Douglas Laing (dlaing@telkomsa.net) 2003/12/20


This page is obsolete. For more recent material please go to Donald Knuth's The Art of Computer Programming (TAOCP) and follow the links under MIXware.

A Simulator and Assembler for the MIX computer as described in 'The Art of Computer Programming', Volume 1 by Donald E. Knuth


Click here to download the compressed tar file  mix.tar.gz

  1. The Assembler - mixal
    mixal reads from the file named as an argument or from stdin if no filename is given and writes a load deck to stdout. The load deck consists of a two card loading routine followed by instruction cards and a transfer card. (See TAOCP 1.3.1 exercise 26.) Any error messages generated are written to stderr. mixal accepts two flags, -V which reports the version number and -l which causes the assembled instructions to be written to a file mixal.obj and formatted source code to mixal.lst. mixal.obj includes the source line numbers and is aligned so that pasting mixal.obj to mixal.lst results in a listing with the generated instructions to the left of the corresponding mixal statements. The -l flag will also write the symbol table used during assembly to stderr.

  2. The simulator - mixsim
    mixsim reads a load deck from sysin, prints to sysout and writes any error messages to stderr. On completion a dump of the machine state is written to stderr. If mixal is interrupted during execution, the machine state will be dumped to stderr. The machine is shipped without a papertape unit and without the floating point feature. The card reader is connected to sysin, the printer to sysout and the card punch to stderr. The tape units use files tape0 to tape7 and the disk units use files disk8 to disk15 in the current directory. The disks are always opened for update without truncation so that old data is not destroyed until it is overwritten. Note that big disk files will never shrink unless they are deleted.

  3. Installation.
    Extract the files with:
      tar -zxvf mix.tar.gz

    mixsim.c comprises the entire simulator and should compile as is. i.e.
      make mixal
    will create the mixal executable.

    mixal consists of files mixal.h, mixal.y, lex.l and symbol.c.
    I have included Makefiles which make mixal under AIX and linux.
      make
    for linux or
      make -f makefile_aix
    for AIX.

  4. Execution
    To assemble and execute a source file p, issue the command:
      mixal p | mixsim 2>dump
    The file dump will contain the final state of the machine.

    To create a listing with a copy of the symbol table:
      mixal -l p 2>symbols | mixsim 2>dump
      paste mixal.obj mixal.lst > listing
      cat symbols >> listing

    The shell script mixrun does this for you.

 Please send bug reports and suggestions to me at dlaing@telkomsa.net