[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 6502 illegal opcodes questions



Michael J. Mahon <mjmahon@aol.com> wrote:


> Stephen Harris wrote:
> > Not really.  At the time every gate on the chip was expensive and saving
> > them was a valid concern.  When I studied VLSI design we called these
> > undefined cased "Don't care" conditions; invalid input meant we didn't
> > care about the output.  You can see this on some cheap LED digital
> > clocks where pressing wierd button combinations can cause odd displays;
> > invalid input.  That can actually cut down the number of gates by 20%
> > or more and so reduce the cost, accordingly.

> True, but the decoding in the 6502 is handled by a kind of PLA, so
> it would likely not be very expensive (in real estate) to trap or
> NOP the invalid combinations.

Remember, the 6502 was designed in 1975.  Every single gate was expensive.
Optimisation of the "don't care" conditions was an important skill that
had a very real impact on the production cost.  Cost was important on this
chip, being a lot cheaper than the competition.

Note that when WDC designed the CMOS version of the chip (65C02) they _did_
NOP the undefined instructions but that was a later design using newer
technologies (CMOS vs NMOS).

> I likely would have made the same choice.  (But as a coder, I would
> have regarded undefined ops as a curiosity, not as an opportunity
> to save a few cycles at the expense of future utility.)

The home computer I'm most used to that used the R6502 (the Rockwell
version) at 2Mhz was the Acorn BBC Micro.  About the only programs that
used the undocumented codes were games that used them for disassembly
protection; most disassemblers at the time didn't recognise them so
would display a single ??? and then try to decode the next byte as an
opcode.  Since the R6502 really treated it as a 2 or 3 byte NOP this
caused bad dissassembly.  Later disassemblers were updated to handle
this :-)

It caused some minor issues, though, when the BBC Master came out, which
used the 65C02.  Oops!  Magazines at the time would publish "hacks" to
fix the few popular rogue programs :-)

-- 
                                 Stephen  Harris
                                usenet@spuddy.org
      The truth is the truth, and opinion just opinion.  But what is what?
       My employer pays to ignore my opinions; you get to do it for free.