Next: Expressions, Previous: Basic structure, Up: MIXAL [Contents][Index]
MIXAL instructions can be either one of the MIX machine instructions (see MIX instruction set) or one of the following assembly pseudoinstructions:
ORIG
Sets the value of the memory address to which following instructions will be allocated after compilation.
EQU
Used to define a symbol’s value, e.g. SYM EQU 2*200/3
.
CON
The value of the given expression is copied directly into the current memory address.
ALF
Takes as operand five characters, constituting the five bytes of a word which is copied directly into the current memory address.
END
Marks the end of the program. Its operand gives the start address for program execution.
The operand of ORIG
, EQU
, CON
and END
can be
any expression evaluating to a constant MIX word, i.e., either a simple
MIXAL expression (composed of numbers, symbols and binary operators,
see Expressions) or a w-expression (see W-expressions).
All MIXAL programs must contain an END
directive, with a twofold
end: first, it marks the end of the assembler job, and, in the second
place, its (mandatory) operand indicates the start address for the
compiled program (that is, the address at which the virtual MIX machine
must begin fetching instructions after loading the program). It is also
very common (although not mandatory) to include at least an ORIG
directive to mark the initial value of the assembler’s location counter
(remember that it stores the address associated with each compiled MIX
instruction). Thus, a minimal MIXAL program would be
ORIG 2000 set the initial compilation address NOP this instruction will be loaded at address 2000 HLT and this one at address 2001 END 2000 end of program; start at address 2000 this line is not parsed by the assembler
The assembler will generate two binary instructions (NOP
(+ 00 00 00 00 00) and HLT
(+ 00 00 02 05)), which will be loaded at
addresses 2000 and 2001. Execution of the program will begin at address
2000. Every MIXAL program should also include a HLT
instruction,
which will mark the end of program execution (but not of program
compilation).
The EQU
directive allows the definition of symbolic names for
specific values. For instance, we could rewrite the above program as
follows:
START EQU 2000 ORIG START NOP HLT END START
which would give rise to the same compiled code. Symbolic constants (or
symbols, for short) can also be implicitly defined placing them in the
LABEL
field of a MIXAL instruction: in this case, the assembler
assigns to the symbol the value of the location counter before compiling
the line. Hence, a third way of writing our trivial program is
ORIG 2000 START NOP HLT END START
The CON
directive allows you to directly specify the contents of
the memory address pointed by the location counter. For instance, when
the assembler encounters the following code snippet
ORIG 1150 CON -1823473
it will assign to the memory cell number 1150 the contents - 00 06 61 11 49 (which corresponds to the decimal value -1823473).
Finally, the ALF
directive lets you specify the memory contents
as a set of five (optionally quoted) characters, which are translated by
the assembler to their byte values, conforming in that way the binary
word that is to be stored in the corresponding memory cell. This
directive comes in handy when you need to store printable messages in a
memory address, as in the following example 8:
OUT MSG MSG is not yet defined here (future reference) MSG ALF "THIS " MSG gets defined here ALF "IS A " ALF "MESSA" ALF "GE. "
The above snippet also shows the use of a future reference, that
is, the usage of a symbol (MSG
in the example) prior of its actual
definition. The MIXAL assembler is able to handle future references
subject to some limitations which are described in the following section
(see Expressions).
Any line starting with an asterisk is treated as a comment and ignored by the assembler.
* This is a comment: this line is ignored. * This line is an error: * must be in column 1.
As noted in the previous section, comments can also be located after the
OPERAND
field of an instruction, separated from it by white
space, as in
LABEL LDA 100 This is also a comment
Next: Expressions, Previous: Basic structure, Up: MIXAL [Contents][Index]