6502 Unsupported Opcodes

From VisualChips

Revision as of 07:49, 14 January 2011 by EdS (Talk | contribs)
Jump to: navigation, search

The 6502 is famous for doing interesting and sometimes useful things when the program includes invalid (or unspecified) opcodes.

For a list of all opcodes and some explanation of what they do, see 6502 all 256 Opcodes.

The visual6502 simulator can help when investigating what these opcodes do, and why - see below for a few cases and pointers for exploration.


  • LAX will load both A and X - notice signals SBX and SBAC which control the writes to X and to A.
  • KIL will put the T-state counter into an unrecoverable state
  • XAA #$5A (also known as ANE) with A=FF

some background

Beware: different revisions of 6502 and versions from different manufacturers may have different behaviours.

For some of these opcodes, the chip does something logically predictable and our model has the same behaviour. But there may be opcodes which are not logically predictable, because they cause marginal voltages on the chip as different drivers fight one another, or a node which is undriven is sampled at a later time. In those cases, our visual6502 simulator, which is just a switch-level simulator with a couple of coarse heuristics for modelling contention and charge storage, won't do the same as a chip.

In fact, as some opcodes produce results which vary from one chip to another, no deterministic simulator could be 'accurate'. (A simulator could let you know that something is amiss)

But note that the underlying circuit data which we now have includes transistor strengths and an approximation of capacitative load: it could easily be extended for resistance and more accurate capacitance. So a more refined (lower level) simulation might shed more light on these undocumented opcodes. In fact, the FPGA model works differently - it moves charge from one node to another - and it might be more accurate for the difficult cases.


Personal tools