Week 28 of 125

TAOCP 1.3.1 Description of MIX

Sign up or sign in to tick these off and give this week a due date.

  • MIX, Knuth's imaginary 1960s-style computer: its words made of bytes and signs, registers, memory, comparison indicator, and the full instruction set. Every program in the original volumes is written for it.

    Time About 7 hours this week

    Why it matters

    Reading and writing assembly for a simple machine teaches what high-level code costs. Even though modern hardware is different, the habit of counting memory references and instruction cycles is timeless.

    Before you start

    • 1.1 Algorithms
    • Some exposure to assembly or the TIS-100/EXAPUNKS games

    How to approach it

    Install a MIX simulator first (GNU MDK is the common choice). Keep the instruction summary chart open. For every instruction family, write a two-line program and run it to see the registers change. Field specifications like (0:5) and (1:3) confuse everyone at first; spend time on them.

    Exercises

    Do the 00 to 15 exercises to make sure you can read MIX fluently. Then write and actually run at least two of the 20-ish programming exercises in a MIX simulator (GNU MDK works). Reading assembly is not the same as writing it; the bugs you hit are the lesson.

    Traps

    • Assuming bytes are 8 bits. A MIX byte holds at least 64 values and programs must not depend on its exact size.
    • Misreading field specs (L:R). Test them in the simulator.
    • Wondering whether to skip MIX for MMIX: Knuth is replacing MIX with MMIX (see the Vol 1 Fascicle 1 and his MMIX page), but the 3rd-edition text you are reading uses MIX, so learn MIX now.

    Reading guide

  • Two problems from the NeetCode 150, in order. One box for the pair.