(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-13-24 01:35 AM
0 users currently in ROM Hacking.
Acmlm's Board - I3 Archive - ROM Hacking - The Invalid Opcode
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
Guy Perfect
Posts: 255/451
Ah, yes. I do remember reading that the DS has a specially defined vector for invalid opcodes.
HyperHacker
Posts: 1651/5072
On most systems, I think the CPU just stops/locks up. Some newer ones (N64 and I think DS) fire an interrupt if configured to do so.
Guy Perfect
Posts: 253/451
It's certainly appreciated. Thanks for the references.
Disch
Posts: 131/202
The NES's NMOS 6502 has a second set of "undocumented" opcodes which fill in the extra opcodes. Some completely deadlock the system (JAM/HLT, typically $x2 opcodes). Others are downright wacky and unpredictable, mixing and matching various data left on the bus lines with register contents in a bizarre fashion (something like set flags to result of A & X & high byte of target address, without changing any regs). Some are combinations of two instructions with weird quirks (like SBC,ROL in one instruction... or ADC,ROR or stuff like that)

There are some NOPs too -- but some take an addressing mode (Absolute mode, for example -- making it a 3 byte, 4 cycle NOP as opposed to 1 byte 2 cycle). I know Puzznic (U).nes uses an invalid NOP opcode, but I don't know of any other game which uses any illegal ops (I'm suprised Puzznic even does!)

Other opcodes are predictable and actually semi-useful (LAX comes to mind, which is a LDA/LDX combo)

I know later (CMOS) 6502 processors treat them all as 1-byte NOPs.


EDIT - relevent linkage:

When adding these opcodes in my emu I used the following two references.

http://nesdev.parodius.com/extra_instructions.txt <--- the better of the two, more precise, detailed, and more logical. My primary resource.

http://nesdev.parodius.com/undocumented_opcodes.txt <--- not quite as good, but lays out the opcodes with their coresponding instruction in a more clear manner. Used it mainly for matching up opcodes->instructions and addressing modes, but relying on the former link to actually outline the instruction's operation when there was a conflict.

EDIT2 -

Of course -- I'm sure for other systems it's different. I can only speak for the NES ^^
Guy Perfect
Posts: 252/451
For any given video game system, how are invalid opcodes treated? Does the system hang? Is the instruction treated as NOP? I suspect this will be different for different systems, but I'd figure I'd throw the question out there for anyone who knows.

It would be good to know for an assembly/disassembly engine that can adapt to different system architectures. I figure that would be a useful tool for game development and hacking. I don't have plans to make one just yet, but I'd like to have the information for when such a time comes.
Acmlm's Board - I3 Archive - ROM Hacking - The Invalid Opcode


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.004 seconds; used 351.54 kB (max 385.87 kB)