Idea · Oct 16, 2026
Build Your Own FORTRAN I Compiler
For Fortran's 70th birthday, students build a compiler for a FORTRAN I subset that targets a simulated IBM 704 with only three index registers, and reproduce the original team's bet that compiled code could rival hand-written assembly.
What it would do
The first Fortran manual appeared 70 years ago (15 October 1956), and Backus's team's real achievement was not the language but an optimizing compiler good enough that 704 programmers would accept it. In this assignment students recreate that story at small scale. They are given a 704-like simulator (36-bit words, accumulator and MQ, three index registers, cycle counts per instruction) and a FORTRAN I subset: fixed-form statements, integer and floating variables, one- and two-dimensional arrays, arithmetic IF, GO TO, and DO loops. Milestone 1 is a fixed-form lexer and parser. Milestone 2 translates arithmetic expressions, first with the original trick of inserting parentheses to encode precedence, then with a modern precedence-climbing parser for comparison. Milestone 3 compiles DO loops and subscripted array references, which is where the original's index-register work mattered. Milestone 4 allocates the three index registers using estimated execution frequencies (from loop nesting, then from profiling runs) and measures spill cost. Milestone 5 pits each student's output against provided hand-written 704 assembly on a benchmark set and reports the cycle-count ratio, mirroring the 1957 claim.
Key features
- Provided IBM 704-style simulator with cycle-accurate counts and only three index registers
- FORTRAN I subset spec with a test suite of period-appropriate numerical programs
- Two expression translators (historical parenthesization trick vs precedence climbing) compared side by side
- Frequency-guided index-register allocation with measured spill cost
- Final benchmark against hand-written assembly with a cycle-ratio leaderboard