Published on

My notes of MIX computer

MIX Computer Cheatsheet

1. Overview of MIX

it operates in both binary and decimal format.

  • Byte: Basic data unit. Can store values from 0 to 63 (in binary) or up to 99 (in decimal).
  • Word: Composed of 5 bytes + 1 sign bit.
  • Memory: 4000 words of storage, addressed from 0 to 3999.

2. MIX Data Representation

  • Byte Values: 0 to 63 (binary), up to 99 (decimal).
  • Two Bytes: 0 to 4095.
  • Three Bytes: 0 to 262143.
  • Four Bytes: 0 to 16777215.
  • Five Bytes 0 to 1073741823.
  • Sign Bit: Can be either + or -.

3. MIX Registers

  • A (Accumulator): 5 bytes + sign. Used for arithmetic operations.
  • X (Extension): 5 bytes + sign. Works with A for multiplication, division, and shifting.
  • I1 to I6 (Index Registers): 2 bytes + sign each. Used for counting and address modification.
  • J (Jump Register): 2 bytes (sign is always +). Stores the return address for subroutines.

Register Notation

  • rA: Register A
  • rX: Register X
  • rI1 to rI6: Index Registers
  • rJ: Jump Register

4. Memory and Components

  • Memory Cells: 4000, numbered 0 to 3999.
  • Overflow Toggle: Single bit indicating overflow status (on/off).
  • Comparison Indicator: Can be LESS, EQUAL, or GREATER.
  • Input/Output Devices: Card readers, tapes, disks, printers, etc.

5. Word Structure and Field Specifications

Word Layout

0   1   2   3   4   5
±  Byte Byte Byte Byte Byte
  • Sign: Byte 0 (0:0)
  • Bytes: 1 to 5 (1:5)

Field Specifications (L:R)

  • (0:0): Sign only

  • (0:2): Sign and first two bytes

  • (0:5): Whole word

  • (1:5): Bytes 1 to 5 (no sign)

  • (4:5): Last two bytes

  • Field Calculation: 8L + R (fits within one byte)

6. Instruction Format

0   1   2   3   4   5
±  AA  I   F   C
  • C (Opcode): Operation code (e.g., 8 for LDA)
  • F (Field Specifier): Field to operate on (e.g., (1:3))
  • AA (Address): Memory location (0 to 3999)
  • I (Index Specifier): Index register (0-6). If 0, no indexing.

Instruction Example (LDA)

  • LDA 2000,2(1:3): Load accumulator with contents at address 2000, indexed by 2, field (1:3).
  • LDA 2000(0:5): Load accumulator with full word from 2000.

Numerical Representation

+ 2000  2  3  8
- 10000 3000
  • 2000: Address
  • 2: Index register
  • 3: Field (1:3)
  • 8: Opcode (LDA)

7. Key Opcodes

  • LDA (8): Load Accumulator
  • LDX (15): Load Extension Register
  • ADD (1): Add to Accumulator
  • SUB (2): Subtract from Accumulator
  • MUL (3): Multiply
  • DIV (4): Divide
  • STA (24): Store in Memory (Accumulator)
  • STX (31): Store in Memory (Extension Register)
  • CMPA (56): Compare with Accumulator
  • JMP (39): Jump to Address

8. Example Programs

Load and Add Two Numbers

LDA 1000
ADD 1001
STA 1002

Description: Load the value at 1000 into the accumulator, add value from 1001, store result at 1002.

Loop Example (Sum from 1 to N)

LDA 1
STA 2000
LDA 0
STA 2001
LOOP ADD 2000
STA 2001
INC 2000
CMPA N
JLE LOOP

Description: Sum numbers from 1 to N and store result in 2001.

9. Notation Summary

  • OP ADDRESS,I(F): Instruction representation
  • M: Memory address after indexing
  • CONTENTS(M): Value stored at memory location M

MIX Assembly Language Cheatsheet


Loading Operators

  • LDA (Load A)
    Code: C = 8
    Field: F = specified field
    Action: Load the specified field of CONTENTS(M) into register A.
    Notes: The sign is loaded if part of the field, otherwise +. If M contains an instruction word and if F is (0:2), the “±AA” field is loaded as ± 0 0 0 A A . Suppose location 2000 contains the word

  • 80 3 5 4

    InstructionContents of rA after load
    LDA 2000- 80 3 5 4
    LDA 2000(1:5)+ 80 3 5 4
    LDA 2000(3:5)+ 0 0 3 5 4
    LDA 2000(0:3)- 0 0 80 3
    LDA 2000(4:4)+ 0 0 0 0 5
    LDA 2000(0:0)- 0 0 0 0 0
  • LDX (Load X)
    Code: C = 15
    Field: F = specified field

  • LDi (Load i)
    Code: C = 8 + i
    Field: F = specified field
    Note: rIi is a 2-byte register; bytes 1, 2, 3 are zero.

  • LDAN (Load A Negative)
    Code: C = 16
    Field: F = specified field
    Action: LDA but opposite sign.

  • LDXN (Load X Negative)
    Code: C = 23
    Field: F = specified field
    Action: LDX but opposite sign.

  • LDiN (Load i Negative)
    Code: C = 16 + i
    Field: F = specified field
    Action: LDi but opposite sign.


Storing Operators

  • STA (Store A)
    Code: C = 24
    Field: F = specified field
    Action: Store the specified field of rA into CONTENTS(M). The rest of M remains unchanged. Examples: Suppose that location 2000 contains - 1 2 3 4 5 and register A contains + 6 7 8 9 0

    InstructionContents of 2000 after store
    STA 2000+ 6 7 8 9 0
    STA 2000(1:5)- 6 7 8 9 0
    STA 2000(5:5)- 1 2 3 4 0
    STA 2000(2:2)- 1 0 3 4 5
    STA 2000(2:3)- 1 9 0 4 5
    STA 2000(0:1)+ 0 2 3 4 5
  • STX (Store X)
    Code: C = 31
    Field: F = specified field
    Action: stores rX.

  • STi (Store i)
    Code: C = 24 + i
    Field: F = specified field
    Action:stores rIi. Note: rIi has only two significant bytes.

  • STJ (Store J)
    Code: C = 32
    Field: F = specified field
    Action:stores rJ ,sign is +. Note: Default F = (0:2).

  • STZ (Store Zero)
    Code: C = 33
    Field: F = specified field
    Action: Store +0 in the specified field of CONTENTS(M). Other parts remain unchanged.


Notes

  • F (Field) specifies which part of a word is affected:
    • (0:5) = full word
    • (1:5) = all bytes except sign
    • (0:2) = sign and first two bytes
  • Mnemonic Breakdown:
    • L: Load
    • ST: Store
    • A: Accumulator (rA)
    • X: Extension (rX)
    • i: Index Register (rIi)
    • N: Negative

Field Shifting Rules

  • During load operations, the field is shifted to the rightmost part of the register.
  • During store operations, the field is shifted left to match the target field in M.

arithmetic operations

1. ADD (C = 1; F = field)

The value V from the specified field is added to register A. Overflow occurs if the result exceeds the register size.

Example:

Assume Location 2000 contains the word: + 100 200 300 400 500 (5-byte number)

STA 2000      ; Store the contents of register A into memory location 2000
LDA 2000(5:5) ; Load the value 500 (from location 2000)
ADD 2000(4:4) ; Add 400 to register A, resulting in 500 + 400 = 900
ADD 2000(3:3) ; Add 300 to register A, resulting in 900 + 300 = 1200
ADD 2000(2:2) ; Add 200 to register A, resulting in 1200 + 200 = 1400
ADD 2000(1:1) ; Add 100 to register A, resulting in 1400 + 100 = 1500

Result:

  • Final contents of rA = 1500
  • No overflow occurred (assuming 5-byte capacity)

2. SUB (C = 2; F = field)

The value V from the specified field is subtracted from register A.

Example:

Assume Location 2000 contains the word: + 100 200 300 400 500 (5-byte number)

STA 2000      ; Store the contents of register A into memory location 2000
LDA 2000(5:5) ; Load the value 500 (from location 2000)
SUB 2000(4:4) ; Subtract 400 from register A, resulting in 500 - 400 = 100
SUB 2000(3:3) ; Subtract 300 from register A, resulting in 100 - 300 = -200
SUB 2000(2:2) ; Subtract 200 from register A, resulting in -200 - 200 = -400
SUB 2000(1:1) ; Subtract 100 from register A, resulting in -400 - 100 = -500

Result:

  • Final contents of rA = -500
  • No overflow occurred.

3. MUL (C = 3; F = field)

The value V from the specified field is multiplied by register A. The result is stored in registers A and X as a 10-byte product.

Example:

Assume Location 2000 contains the word: + 10 20 30 40 50 (5-byte number)

STA 2000      ; Store the contents of register A into memory location 2000
LDA 2000(5:5) ; Load the value 50 (from location 2000)
MUL 2000(4:4) ; Multiply 50 by 40, resulting in 2000. Store in rA and rX.
MUL 2000(3:3) ; Multiply the product (2000) by 30, resulting in 60000. Store in rA and rX.

Result:

  • The contents of rA and rX would store the 10-byte product of these multiplications.

  • rA: Most significant 5 bytes of the result, rX: Least significant 5 bytes.


4. DIV (C = 4; F = field)

value V from the specified field divides the combined 10-byte number from registers rA and rX. The quotient is stored in rA and the remainder in rX.

Example:

Assume Location 2000 contains the word: + 10 20 30 40 50 (5-byte number), and register rA = 12345, rX = 67890.

STA 2000      ; Store the contents of register A into memory location 2000
LDA 2000(5:5) ; Load 50 into register A
DIV 2000(4:4) ; Divide the value in rAX (combining rA and rX) by 40

Result:

  • rA will contain the quotient: the division of the 10-byte number by 40.
  • rX will contain the remainder.
  • If V = 0 or the quotient exceeds 5 bytes, overflow occurs and registers rA and rX will contain undefined values.

Address Transfer Operators in MIX

1. ENTA (Enter A)

C = 48; F = 2
The value M (address or signed value) is loaded into register rA. similar to LDA (Load A).if M = 0, the sign of the instruction is loaded.

Examples:

  • ENTA 0: Sets rA to zero with a positive sign.
  • ENTA 0,1: Loads the value of rI1 into rA, where the sign of zero is converted to +0.
  • ENTA -0,1: Loads the value of rI1 into rA, where -0 is converted to -0.

2. ENTX (Enter X)

C = 55; F = 2
Similar to ENTA, but it loads the value of M into register rX.

Example:

  • ENTX 0,2: Loads rI2 into rX.

3. ENTi (Enter i)

C = 48 + i; F = 2
This operation loads the value at the address M into index register rIi. It's the same as ENTA but for any index register.

Example:

  • ENT3 0,3: Loads the value from rI3 into rA.

4. ENNA (Enter Negative A)

C = 48; F = 3
The value at address M is loaded into rA, but with the opposite sign. This is the negative of ENTA.

Example:

  • ENNA 0: Loads -0 into rA.

5. ENN X (Enter Negative X)

C = 55; F = 3
This works the same as ENNA but for rX.

Example:

  • ENN X 1: Loads -rI1 into rX.

6. ENNi (Enter Negative i)

C = 48 + i; F = 3
Similar to ENTi, but it loads the negative value into the respective index register rIi.

Example:

  • ENN3 0,3: Replaces rI3 with its negative value, i.e., -rI3.

7. INCA (Increase A)

C = 48; F = 0
Adds the value M to rA. The overflow behavior is the same as the ADD instruction.

Example:

  • INCA 1: Increases rA by 1.

8. INCX (Increase X)

C = 55; F = 0
Adds M to rX. If overflow occurs, the action behaves like ADD, but affects rX and not rA.

Example:

  • INCX 5: Increases rX by 5.

9. INCi (Increase i)

C = 48 + i; F = 0
Adds M to index register rIi. No overflow is allowed; if the result exceeds the capacity, the operation results in undefined behavior.

Example:

  • INC3 10: Increases rI3 by 10.

10. DECA (Decrease A)

C = 48; F = 1
Subtracts the value M from rA. The operation is analogous to INCA, but with subtraction.

Example:

  • DECA 1: Decreases rA by 1.

11. DECX (Decrease X)

C = 55; F = 1
Subtracts M from rX.

Example:

  • DECX 5: Decreases rX by 5.

12. DECi (Decrease i)

C = 48 + i; F = 1
Subtracts M from index register rIi.

Example:

  • DEC3 10: Decreases rI3 by 10.

Comparison Operators in MIX

comparevalue in register to memory

1. CMPA (Compare A)

C = 56; F = field
Compares the value in rA with the contents of memory location M.

Example:

  • CMPA 100: Compares rA with the value in memory location 100.

2. CMPX (Compare X)

C = 63; F = field
Analogous to CMPA, but compares rX instead.

Example:

  • CMPX 200: Compares rX with the value in memory location 200.

3. CMPi (Compare i)

C = 56 + i; F = field
Analogous to CMPA, but compares rIi.

Example:

  • CMP3 300: Compares rI3 with the value in memory location 300.

Jump Operators in MIX

Jump instructions allow program control to transfer to another location.

1. JMP (Jump)

C = 39; F = 0
Performs an unconditional jump to memory location M.

Example:

  • JMP 500: Jump to location 500.

2. JSJ (Jump, Save J)

C = 39; F = 1
Same as JMP, but the contents of register rJ remain unchanged.

Example:

  • JSJ 600: Jump to location 600 while saving rJ.

3. JOV (Jump on Overflow)

C = 39; F = 2
If the overflow toggle is on, it is cleared, and a jump occurs.

Example:

  • JOV 700: Jump to location 700 if the overflow toggle is on.

4. JL, JE, JG, JGE, JNE, JLE (Conditional Jumps)

C = 39; F = 4-9
These instructions perform jumps based on the comparison indicator:

  • JL: Jump if LESS.
  • JE: Jump if EQUAL.
  • JG: Jump if GREATER.
  • JGE: Jump if GREATER or EQUAL.
  • JNE: Jump if UNEQUAL.
  • JLE: Jump if LESS or EQUAL.

Example:

  • JL 800: Jump to location 800 if the comparison indicator is LESS.

5. JAN, JAZ, JAP, JANN, JANZ, JANP (Jump on A Register Condition)

C = 40; F = 0-5
These instructions perform a jump if the value in rA satisfies the condition (negative, zero, positive, etc.).

Example:

  • JAN 900: Jump to location 900 if rA is negative.

6. JXN, JXZ, JXP, JXNN, JXNZ, JXNP (Jump on X Register Condition)

C = 47; F = 0-5
These instructions are similar to the JAN instructions but for rX.

Example:

  • JXN 1000: Jump to location 1000 if rX is negative.

7. JiN, JiZ, JiP, JiNN, JiNZ, JiNP (Jump on Index Register Condition)

C = 40 + i; F = 0-5
These instructions perform jumps based on the condition of the index register rIi.

Example:

  • J3N 1100: Jump to location 1100 if rI3 is negative.

Miscellaneous

Shift Operations

  • SLA (Shift Left A) – C = 6; F = 0
  • SRA (Shift Right A) – C = 6; F = 1
  • SLAX (Shift Left AX) – C = 6; F = 2
  • SRAX (Shift Right AX) – C = 6; F = 3
  • SLC (Shift Left Circular AX) – C = 6; F = 4
  • SRC (Shift Right Circular AX) – C = 6; F = 5

Notes:

  • M: number of bytes to shift (nonnegative)
  • SLA/SRA affects only rA, others affect rA and rX as a combined 10-byte register.
  • SLC/SRC perform circular shifts; signs of rA and rX are unchanged.

Examples:

  • Initial: rA = +12345, rX = -678910
  • SRAX 1 → rA = +01234, rX = -56789
  • SLA 2 → rA = +23400, rX = -56789
  • SRC 4 → rA = +67892, rX = -34005

MOVE Operation

  • MOVE – C = 7; F = number (default 1)

Description:

  • Moves F words from location M to rI1's location. rI1 increments by F.
  • Overlap caution: Words may overwrite if rI1 points into M's block.

No Operation / Halt

  • NOP – C = 0; No effect.
  • HLT – C = 5; F = 2; Halts machine (restart acts as NOP).

Input-Output Operators

  • IN (Input) – C = 36; F = unit
  • OUT (Output) – C = 37; F = unit
  • IOC (I/O Control) – C = 35; F = unit
  • JRED (Jump Ready) – C = 38; F = unit
  • JBUS (Jump Busy) – C = 34; F = unit

Devices:

  • Tape (0-7): 100 words/block
  • Disk/Drum (8-15): 100 words/block
  • Card Reader (16): 16 words
  • Printer (18): 24 words
  • Typewriter (19): 14 words

Conversion Operators

  • NUM (Character to Numeric) – C = 5; F = 0
  • CHAR (Numeric to Character) – C = 5; F = 1

Description:

  • NUM: Converts 10-byte rA/rX to decimal (rA contains result).
  • CHAR: Converts rA to 10-byte character code (fills rA/rX).

Example:

  • Initial: rA = -003129, rX = +375730
  • NUM → rA = -12977700
  • INCA 1 → rA = -12977699
  • CHAR → rA = -003129, rX = +377639

i

  • Ans 1 ;
  1. MIX is a 6-bit computer can hold ( 2^6 = 64 ) .
  2. In a ternary (base-3) system , 3 values (0, 1, 2).

[ 3^x \geq 64 ]

  1. Testing powers of 3:
    [ 3^3 = 27 ]
    [ 3^4 = 81 ]

Thus, a ternary MIX computer would likely use 4 trits per byte to ensure at least 64 unique values per byte.


ans 2 : 4.4292374574453

Let's break down how many bytes are needed to represent the value 99,999,999 in MIX.

Step 1: Understand MIX Byte Size

  • values from 0 to 63 (or (2^6 = 64) unique values). To compute the minimum bytes:
    \[Bytes needed=log64(99999999)=4.4292374574453\[ \text{Bytes needed} = \log_{64}(99999999) = 4.4292374574453

]


ans 3

FieldL:R
Address Field0:2
Index Field3:3
Field Field4:4
Operation Code5:5