Idea · Oct 12, 2026
Build Your Own Static Recompiler
A staged compilers assignment in which students translate CHIP-8 (then a small 6502 subset) ROMs ahead of time into WebAssembly, using their own interpreter as the oracle that proves every recompiled program behaves identically.
What it would do
Static recompilation, recently used to run PS2 games in the browser as WebAssembly, is a great capstone for a compilers or architecture course because correctness is unambiguous: the recompiled game must behave exactly like the original. Milestones: (1) write a reference CHIP-8 interpreter with a deterministic trace format; (2) disassemble ROMs and recover basic blocks and a control-flow graph, discovering why indirect jumps and self-modifying code make this undecidable in general; (3) emit WebAssembly text per basic block with a dispatcher loop, then compile with wabt; (4) add optimizations (block chaining, register promotion to Wasm locals, dead flag elimination) and measure speedups; (5) handle the hard cases with a fallback to the interpreter. The autograder runs both engines on public-domain ROMs with scripted inputs and compares register, memory and framebuffer traces tick by tick, reporting the first divergence.
Key features
- Reference interpreter with canonical execution traces used as the correctness oracle
- Disassembler with basic-block discovery and CFG visualization
- WebAssembly code generator with dispatcher loop and block chaining
- Optimization milestone with measured speedups against the interpreter
- Trace-diff autograder that pinpoints the first divergent instruction