#### 2.2.1 Basic program structure ¶

The MIX assembler reads MIXAL files line by line, producing, when required, a binary instruction, which is associated to a predefined memory address. To keep track of the current address, the assembler maintains an internal location counter which is incremented each time an instruction is compiled. In addition to MIX instructions, you can include in MIXAL file assembly directives (or pseudoinstructions) addressed at the assembler itself (for instance, telling it where the program starts and ends, or to reposition the location counter; see below).

MIX instructions and assembler directives6 are written in MIXAL (one per source file line) according to the following pattern:

    [LABEL]   MNEMONIC  [OPERAND]   [COMMENT]

where ‘`OPERAND`’ is of the form

    [ADDRESS][,INDEX][(MOD)]

Items between square brackets are optional, and

`LABEL`

  is an alphanumeric identifier (a symbol) which gets the current value of the location counter, and can be used in subsequent expressions,

`MNEMONIC`

  is a literal denoting the operation code of the instruction (e.g. `LDA`, `STA`; see see MIX instruction set) or an assembly pseudoinstruction (e.g. `ORIG`, `EQU`),

`ADDRESS`

  is an expression evaluating to the address subfield of the instruction,

`INDEX`

  is an expression evaluating to the index subfield of the instruction, which defaults to 0 (i.e., no use of indexing) and can only be used when `ADDRESS` is present,

`MOD`

  is an expression evaluating to the mod subfield of the instruction. Its default value, when omitted, depends on `OPCODE`,

`COMMENT`

  any number of spaces after the operand mark the beginning of a comment, i.e. any text separated by white space from the operand is ignored by the assembler (note that spaces are not allowed within the ‘`OPERAND`’ field).

Note that spaces are not allowed between the `ADDRESS`, `INDEX` and `MOD` fields if they are present. White space is used to separate the label, operation code and operand parts of the instruction7.

We have already listed the mnemonics associated with each MIX instruction; sample MIXAL instructions representing MIX instructions are:

    HERE     LDA  2000         HERE represents the current location counter
             LDX  HERE,2(1:3)  this is a comment
             JMP  1234