Find Related products on Amazon

Shop on Amazon

How MOS 6502 Illegal Opcodes Work – Michael Steil

Published on: 2025-08-10 14:36:05

The original NMOS version of the MOS 6502, used in computers like the Commodore 64, the Apple II and the Nintendo Entertainment System (NES), is well-known for its illegal opcodes: Out of 256 possible opcodes, 151 are defined by the architecture, but many of the remaining 105 undefined opcodes do useful things. Many articles have been written to test and document these, but I am not aware of any article that tries to explain where exactly they come from. I’ll do this here. The Block Diagram Every 6502 data sheet comes with a block diagram, but these are of no use, because they are oversimplified, partially incorrect, and don’t explain how instruction decoding works. The following more detailed diagram is a lot more useful: (Original from Apple II things) The Decode ROM (PLA) There is no need to understand the whole diagram. The important part is on the left: The instruction register, which holds the opcode, and the current clock cycle within the instruction (T0 to T6) get fed ... Read full article.