DeiMOS — A Superoptimizer for the MOS 6502

What DeiMOS does
It has been reported that DeiMOS is a superoptimizer aimed at the venerable MOS 6502, the 8‑bit CPU that powered the NES and the Commodore 64. A superoptimizer doesn't guess at good code — it brute‑forces the search for the provably best instruction sequence for a given task. Exhaustive search, exhaustive verification. Simple idea. Brutal execution.
How it works
Users supply two functions: one to generate an initial system state and another to verify that an output state is correct. DeiMOS then generates candidate programs, emulates them on a 6502, and checks correctness for every possible input variation — up to 256 tests for an 8‑bit value. That makes full verification tractable in ways it wouldn't be on modern 64‑bit hardware. Pruning and heuristics do the heavy lifting: skip bytes that halt the CPU, track the deepest executed address to advance the search smartly, and avoid emitting obviously useless opcodes. The naïve 256^N brute force approach is doable for tiny N, but without these tricks, the search balloons into the weeds.
Why this matters (and why it's kind of fun)
There's a little emotional tug here — the idea of using modern computing and clever pruning to squeeze the last cycles out of a 1975 microprocessor feels like digital archaeology. Who doesn't like the notion that a tiny, well‑scoped target lets you prove optimality rather than guess it? For retro coders, educators, and anyone who loves elegant low‑level tricks, DeiMOS is a neat proof of concept: exhaustive methods can still find surprising, non‑obvious instruction sequences on simple ISAs. Of course, scale is the villain in this story — the magic stops as soon as programs get long or the ISA grows complex. But for the 6502, apparently, there's still gold in those old silicon hills.
Sources: aransentin.github.io, Hacker News
Comments