TAOCP Vol 1: Fundamental Algorithms · Week 29
TAOCP 1.3.2 The MIX Assembly Language: reading guide
MIXAL, the assembly language for MIX: symbols, local labels, pseudo-operations, and worked programs including finding a maximum and printing a table of primes. It also shows how Knuth annotates programs with execution counts.
Time About 8 hours this week
Why it matters
This is where you go from reading machine instructions to writing real programs. The execution-count annotations are how Knuth turns code into exact running-time formulas.
Before you start
- 1.3.1 Description of MIX
How to approach it
Type in the example programs and run them in the simulator, not just read them. Then change something (print a different number of primes, find the minimum) and get it working. Add the frequency counts yourself and check them against the simulator's instruction counts.
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
- Local symbols like 2H, 2F and 2B trip people up; F means the next one forward, B the previous one backward.
- Simulator syntax can differ slightly from the book; check your simulator's manual for column and format rules.