[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 6502 illegal opcodes questions
In article <1147397570.212608.111710@i40g2000cwc.googlegroups.com>,
"mdj" <mdj.mdj@gmail.com> wrote:
> John Selck wrote:
>
> > Some illegals are quite useful, like SHX/SHY which in some cases can be
> > used as STX absolute,Y / STY absolute,X if you use the right. Also you
> > can do a CPU test and use different code on different CPUs. The demo
> > "Oneder/Oxyron" does this. It works on 6502 with illegal opcodes, and on
> > 65816 it uses a slower but illegal-free code.
>
> This is reasonable on the C64 where all machines were fitted with
> 6502's, and in the case of a 65816 it's accelerated, so a slower code
> section is acceptable.
>
> The Apple II series is essentially 3 platforms, and 3 CPU generations,
> all backwards compatible.
And of course you've neglected to mention the other major 6502 computer
series of the era, Atari. They never used anything but a standard 6502
core (but with an extra pin added to make DMA easier), so the 65C02 and
65816 were never an issue. In fact, Atari's 6502C with the extra signal
meant that you _couldn't_ just drop a 65C02 into the same socket.
This was even less of an issue on the 2600, which always used a 6507,
which is a standard 6502 die in a reduced pin count package. Quite a
few games used illegal opcodes to reduce cycle count so that they could
do things that were otherwise impossible with its clock-locked 1-D
graphics chip.
Oddly enough, the Apple II is where I heard most about people using
illegal opcodes and side effects like JSR ($xxFF) back in the day, as a
way to obfuscate copy-protection code. Like I cared, because I had a
TRS-80 (then a CoCo, and a 128K Mac), and most of the Z-80 undocumented
opcodes were obvious, even when they weren't useful. And none of the
6809 undocumented opcodes were useful at all, except there was one that
would do an SWI (equivalent to 6502 BRK) through the FIRQ vector and
another that would jump through the RESET vector.