Next: , Previous: , Up: Getting started   [Contents][Index]

3.1 Writing a source file

MIXAL programs can be written as ASCII files with your editor of choice. Here you have the mandatory hello world as written in the MIXAL assembly language:

*                                                        (1)
* hello.mixal: say 'hello world' in MIXAL                (2)
*                                                        (3)
* label ins    operand     comment                       (4)
TERM    EQU    19          the MIX console device number (5)
        ORIG   3000        start address                 (6)
START   OUT    MSG(TERM)   output data at address MSG    (7)
        HLT                halt execution                (8)
MSG     ALF    "MIXAL"                                   (9)
        ALF    " HELL"                                   (10)
        ALF    "O WOR"                                   (11)
        ALF    "LD   "                                   (12)
        END    START       end of the program            (13)

MIXAL source files should have the extension .mixal when used with the MDK utilities. As you can see in the above sample, each line in a MIXAL file can be divided into four fields separated by an arbitrary amount of whitespace characters (blanks and or tabs). While in Knuth’s definition of MIXAL each field must start at a fixed pre-defined column number, the MDK assembler loosens this requirement and lets you format the file as you see fit. The only restrictions retained are for comment lines (like 1-4) which must begin with an asterisk (*) placed at column 1, and for the label field (see below) which, if present, must also start at column 1. The four fields in each non-comment line are:

Lines 9-12 of the hello.mixal file above also show the second (and last) difference between Knuth’s MIXAL definition and ours: the operand of the ALF pseudoinstruction (a word of five characters) must be quoted using ""11.

The workings of this sample program should be straightforward if you are familiar with MIXAL. See TAOCP vol. 1 for a thorough definition or MIX and MIXAL tutorial, for a tutorial.

Next: , Previous: , Up: Getting started   [Contents][Index]