IT lexicon › Programming › Illegal opcodes

Illegal opcodes

Programming På svenska → Updated: 2026-10-02

Undocumented instructions in the MOS 6502/6510 that scene coders exploited for tighter, faster code than the maker ever intended.

The 6502's instruction decoder left a heap of bit patterns undefined, but they still did something — often two things at once. LAX loaded the A and X registers in one stroke; SAX wrote an AND of the two to memory. On a processor where every cycle counted, that was free speed and saved bytes.

MOS never documented them and never guaranteed them, but on the C64's 6510 they were stable enough to build on, and the demoscene did so freely in tight routines like linecrunch and VSP. Later 6502 variants such as the 65C02 reused the same bit patterns for real instructions, and the code stopped working — the price of relying on something never promised.

← Back to the lexicon