2.1 Assembling MIXAL Programs.

The simplest way to assemble a MIXAL program is to give it as an argument to mixal:

 
$ mixal hello.mix

The mixal utility assembles the program, and prints the resulting object code on the standard output. The object code is formatted as a card deck, as described in TAOCP, 1.3.1, p.141, ex. 26, therefore in this book we use the terms object file and deck file as synonyms.

Each line in the deck file corresponds to a single punch card. First two cards are always the same — they contain a loader routine, responsible for loading of the entire deck into MIX memory and passing control to the program entry point. The following lines, up to the last one, contain the program code, formatted as described in the following table:

Column Meaning
1–5 Ignored.
6 Number of consecutive words to be loaded on this card (between 1 and 7, inclusive).
7–10 The location of word 1 (always greater than 100).
11–20 Word 1.
21–30 Word 2.
31–40 Word 3.
41–50 Word 4.
51–60 Word 5.
61–70 Word 6.
71–80 Word 7.

For example, the card:

 
HELLO63000078721962107866953300000000133013558254406879733950219152384

contains 6 words to be loaded starting from address 3000. These words are:

Address Word
3000 0787219621
3001 0786695330
3002 0000000133
3003 0135582544
3004 0687973395
3005 0219152384

The deck ends with a special transfer card, which contains information in format ‘TRANS0nnnn’, where nnnn is the address of the program entry point. For example, ‘TRANS03000’ means “start execution from address 3000”.

To illustrate this, here is the deck file produced for ‘hello.mix’ (the first two cards are omitted):

 
HELLO63000078721962107866953300000000133013558254406879733950219152384
TRANS03000

The card deck, produced by mixal can be executed by the MIX simulator, as described in mixsimMIX Simulator.. In the simplest case, you can directly feed the deck to the standard input of mixsim:

 
$ mixal hello.mix | mixsim

However, for more complex programs, it is common to store the produced card deck in a file for further use by mixsim. To do so, use ‘--output’ (‘-o’) command line option, as shown in the example below:

 
$ mixal --output=hello.deck hello.mix