(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
04-28-24 10:14 AM
0 users currently in ROM Hacking.
Acmlm's Board - I3 Archive - ROM Hacking - The Invalid Opcode New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Guy Perfect









Since: 11-18-05

Last post: 6280 days
Last view: 6279 days
Posted on 04-09-06 09:09 PM Link | Quote
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.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6558 days
Last view: 6558 days
Posted on 04-10-06 11:35 AM Link | Quote
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 ^^


(edited by Disch on 04-10-06 10:40 AM)
(edited by Disch on 04-10-06 10:49 AM)
Guy Perfect









Since: 11-18-05

Last post: 6280 days
Last view: 6279 days
Posted on 04-10-06 04:53 PM Link | Quote
It's certainly appreciated. Thanks for the references.
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6279 days
Last view: 6279 days
Posted on 04-11-06 01:50 AM Link | Quote
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









Since: 11-18-05

Last post: 6280 days
Last view: 6279 days
Posted on 04-11-06 04:53 PM Link | Quote
Ah, yes. I do remember reading that the DS has a specially defined vector for invalid opcodes.
Add to favorites | Next newer thread | Next older thread
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.013 seconds; used 366.71 kB (max 436.97 kB)