illegal opcodes on 6502 nes version

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
dreampeppers99
Posts: 77
Joined: Mon Aug 21, 2006 4:19 am

illegal opcodes on 6502 nes version

Post by dreampeppers99 » Mon Mar 30, 2009 11:15 am

I'm writing a debugger to nes, then I need to know :
opcode:
cycles:
size:
of each instruction so I can disassembler properly.

I'm looking around and saw it http://members.chello.nl/taf.offenga/illopc31.txt. Need I to implemente all illegal opcodes? And if I don't implement it the final Size/Position of instructions will modify... invalidating my assembler?

User avatar
Dwedit
Posts: 4410
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Mon Mar 30, 2009 12:33 pm

Games do use the illegal opcodes, and depend on them being the correct size when executed.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
dreampeppers99
Posts: 77
Joined: Mon Aug 21, 2006 4:19 am

Post by dreampeppers99 » Mon Mar 30, 2009 1:01 pm

Games do use the illegal opcodes, and depend on them being the correct size when executed.
Thanks!
Then the "compiler" for games that doesn't use illegal opcodes, use the padding of "NOP" instruction... I guess

tepples
Posts: 22284
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Mar 30, 2009 1:42 pm

Dwedit wrote:Games do use the illegal opcodes
Which is probably why Nintendo abandoned making the Super NES fully backward-compatible with the NES.

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Mon Mar 30, 2009 1:51 pm

tepples wrote:
Dwedit wrote:Games do use the illegal opcodes
Which is probably why Nintendo abandoned making the Super NES fully backward-compatible with the NES.
One example of a game that uses "illegal" opcodes, plz?

tepples
Posts: 22284
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Mar 30, 2009 1:53 pm

Puzznic.

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu » Mon Mar 30, 2009 2:48 pm

tepples wrote:Puzznic.
And what proof is there that this is not a bad ROM dump? I'd say that's a lot more likely explanation, and this has been seen many MANY times in the past.

I skimmed the thread, and I still don't understand the term "double NOP". NOP is a single-byte opcode, and definitely supported on the 6502. Two NOPs = zzz....

tepples
Posts: 22284
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Mar 30, 2009 4:12 pm

As I understand it, a "double NOP" is ONE instruction with a two-byte encoding that does not write to CPU registers or memory. It's not $EA $EA, which is two instructions.
And what proof is there that this is not a bad ROM dump?
Separate dumps of two Game Paks containing the same instruction, I presume. Dwedit, can you clarify?

User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Mon Mar 30, 2009 5:16 pm

Any other example games using illegal ops? The vast majority of games I imagine they don't use any illegal ops. I'm sure the reason backwards compatibility was cut was not for a few games that used illegal ops that wouldn't work.

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg » Mon Mar 30, 2009 6:31 pm

I'm pretty sure Lolo 3 uses one of the "double NOP" opcode. I think a few games might use the alternate SBC opcode. Virtually everything else only uses official opcodes, as I found when writing a NES emulator. This wouldn't be a reason for Nintendo scrapping NES backwards compatibility in the Super NES.

strat
Posts: 389
Joined: Mon Apr 07, 2008 6:08 pm
Location: Missouri

Post by strat » Tue Mar 31, 2009 12:25 am

According to Game Over, including the NES PPU in the SNES would have added $75 to the cost of a unit.
Last edited by strat on Fri Dec 07, 2012 6:13 pm, edited 1 time in total.

User avatar
dreampeppers99
Posts: 77
Joined: Mon Aug 21, 2006 4:19 am

Post by dreampeppers99 » Tue Mar 31, 2009 6:09 am

koitsu wrote:
tepples wrote:Puzznic.
And what proof is there that this is not a bad ROM dump? I'd say that's a lot more likely explanation, and this has been seen many MANY times in the past.

I skimmed the thread, and I still don't understand the term "double NOP". NOP is a single-byte opcode, and definitely supported on the 6502. Two NOPs = zzz....
By what I'm reading exists more than one type of NOP (there's NORMAL nop and ILLEGAL NOP (s) )
xx ------ 2 NOP (xx=1A,3A,5A,7A,DA,FA)
Then there's also NOP Immediate, ZeroPage, Absolute...

my source: http://nocash.emubase.de/everynes.htm#cpuillegalopcodes :roll:

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Post by WedNESday » Tue Mar 31, 2009 9:22 am

dreampeppers99 don't worry too much about what we're saying at the moment. Just get all of the legal opcodes done first, and then start paying attention to the illegal ones. In my experience, 99.9% games never used them (not meant to be an exact number, but rather a feel of how rare they were). Games that did use them tended to use the same ones as some of them are either very unstable/unreliable or may actually very from console to console (can anyone verify that?).

If you know what NOP is, then you'll know that it only uses 1 byte, $EA. There are some illegal opcodes that actually go as far as reading from a memory location like ADC Absolute, X ($7D), but without actually doing any kind of addition or whatever. They can be used to read from certain memory locations that may 'trigger' off certain PPU/APU events, other wise they are just useless and waste clock cycles.

nestest.nes will help you test your legal, and then illegal opcodes when you've written them. So do things in order first.

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: illegal opcodes on 6502 nes version

Post by Zepper » Tue Mar 31, 2009 9:36 am

...
Last edited by Zepper on Sat Feb 19, 2011 6:18 pm, edited 1 time in total.

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg » Tue Mar 31, 2009 9:00 pm

Again, I'm going to harp on terminology. As far as the NES hardware is concerned, there are no illegal opcodes; all of them cause some effect when executed (more sophisticated processors do have illegal instructions, where attempted execution invokes an illegal instruction trap). Some of the opcodes are official as far as Rockwell and Nintendo are concerned, and others are not official, though well-documented. So, "illegal" and "undocumented" are misleading, while "unofficial" suits them perfectly.

Post Reply