StanJr Posted October 30, 2003 Share Posted October 30, 2003 The opcodes? Thomas just referenced "illegal opcodes" in his discussion of the Splatform mini-game. So what makes them illegal? And will the police actually arrest Thomas for using them? Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted October 30, 2003 Share Posted October 30, 2003 Just an instruction or line of code that performs an operation not planned in the design of the CPU. "Illegal" because it therefore shouldn't have been allowed, but works anyway. Quote Link to comment Share on other sites More sharing options...
StanJr Posted October 30, 2003 Author Share Posted October 30, 2003 so "illegal" is a misnomer. I think they should change the name to "advanced opcodes" or something, illegal sounds dirty. Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted October 30, 2003 Share Posted October 30, 2003 Actually, it's an apt enough name. If you perform too many illegal instructions, you could "break the law" of the CPU and crash your program. Also any time a processor is updated for a new generation of hardware, there's a chance that any loopholes which previously allowed illegal opcodes will be closed. I think that's partly why certain homebrews work fine on an old 2600 but flake out when played on a Jr. Quote Link to comment Share on other sites More sharing options...
Bryan Posted October 30, 2003 Share Posted October 30, 2003 Just an instruction or line of code that performs an operation not planned in the design of the CPU. "Illegal" because it therefore shouldn't have been allowed, but works anyway. Actually, the best term is 'undocumented'. The CPU may do something useful in response to them, but their operation was never documented. This may be because their operation was inconsistent or confusing, or because the designer planned on assigning a different function to those opcodes in the future. The 6502 has very simple instruction decode logic (it tries to act on any opcode), and these opcodes create corruptions or combinations of other valid instructions. Some are useful and some are not. -Bry edit: In response to MMF. Not all versions of the 6502(+family) respond the same way to them. This is why they may cause incompatibilities. Some of them will simply lock up the CPU's state machine. Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted October 30, 2003 Share Posted October 30, 2003 edit: In response to MMF. Not all versions of the 6502(+family) respond the same way to them. This is why they may cause incompatibilities. Some of them will simply lock up the CPU's state machine. That's what I meant, stated much more elegantly. It's been far too long since I took programming in college. Quote Link to comment Share on other sites More sharing options...
Bryan Posted October 30, 2003 Share Posted October 30, 2003 A few examples (the names were assigned by programmers): ANC - Corruption of AND Opcodes: $0B, $2B Works like AND, but also sets the Carry flag if the result is Negative LAX - Combination of LDA, LDX Opcodes: $A7, $B7, $AF, $BF, $A3, $B3 Loads A and X with the same value. SRE - Combination of LSR and EOR Opcodes: $47, $57, $4F, $5F, $5B, $43, $53 Shift a memory location right, then perform an exclusive-OR with the Accumulator. The combinations are possible because normal 6502 instructions do not have the last 2 bits set at once. When you do set both bits, you often get the effect of 2 instructions run back-to-back. You can read more here: http://www.s-direktnet.de/homepages/k_nadj...dj/opcodes.html -Bry Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted October 31, 2003 Share Posted October 31, 2003 HLT *** HLT crashes the microprocessor. When this opcode is executed, program execution ceases. No hardware interrupts will execute either. Now THAT'S an illegal opcode. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted October 31, 2003 Share Posted October 31, 2003 Also any time a processor is updated for a new generation of hardware, there's a chance that any loopholes which previously allowed illegal opcodes will be closed. I think that's partly why certain homebrews work fine on an old 2600 but flake out when played on a Jr. AFAIK the CPU of the Jr. supports all illegal opcodes that the original 650x CPUs supports too. And I only using very few illegal opcodes (LAX, NOP and DCP) and I am not using so called "unstable" illegal opcodes (which behave differently in different CPUs). So, if a game won't work on a Jr. the reason must be different. Do you have any examples? Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted November 1, 2003 Share Posted November 1, 2003 http://www.atariage.com/store/product_info...products_id=113 Vault Assault. Will not play correctly on a Jr. Quote Link to comment Share on other sites More sharing options...
Albert Posted November 1, 2003 Share Posted November 1, 2003 AFAIK the CPU of the Jr. supports all illegal opcodes that the original 650x CPUs supports too. And I only using very few illegal opcodes (LAX, NOP and DCP) and I am not using so called "unstable" illegal opcodes (which behave differently in different CPUs). NOP is an illegal opcode on the 6507? Oh, and I prefer "undocumented" to "illegal" as well. "Illegal" does make them sound more sexy, though. ..Al Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted November 1, 2003 Share Posted November 1, 2003 NOP (code $EA) isn't...but alternate versions that waste varying amounts of cycles are (even tho they work as well), as well as other bit variations of the instruction (1A, 3A, 5A, 7A, DA, FA). Only NOP (code $EA) is official. Quote Link to comment Share on other sites More sharing options...
Big Player Posted November 1, 2003 Share Posted November 1, 2003 Was Thrust the first 2600 game to use illegal opcodes? Is the 2600 the only 650x-based system where these opcodes provide any advantage? Quote Link to comment Share on other sites More sharing options...
CPUWIZ Posted November 1, 2003 Share Posted November 1, 2003 Is the 2600 the only 650x-based system where these opcodes provide any advantage? No, definately not, I've used illegal opcodes on the C64 in 1982 and also on other systems with different processors. Quote Link to comment Share on other sites More sharing options...
Bryan Posted November 1, 2003 Share Posted November 1, 2003 I'm pretty sure there are some on the Z80 as well. The Z80 has some 'prefix' codes that aren't instructions, but rather they modify the action the next instruction will take, so some instructions are other instructions with a certain prefix code. -Bry Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 1, 2003 Share Posted November 1, 2003 Was Thrust the first 2600 game to use illegal opcodes? Probably, though I am not 100% sure. But AFAIK all older games work on the older Stella emulators (<v1.2), so the answer is most likely "yes!" I think the main reason for the original programers not using them was, that they couldn't be 100% sure those opcodes would be supportd by all future 6507 (or replacement) CPUs. Quote Link to comment Share on other sites More sharing options...
Bryan Posted November 1, 2003 Share Posted November 1, 2003 I thought Robot Tank used one. NOP (code $EA) isn't...but alternate versions that waste varying amounts of cycles are (even tho they work as well), as well as other bit variations of the instruction (1A, 3A, 5A, 7A, DA, FA). Only NOP (code $EA) is official. Even $EA isn't actually a No-Operation code. It just performs an operation and then doesn't store the result anywhere. The other undocumented NOP codes are all doing the same thing but using different addressing modes for their discarded operation. -Bry Quote Link to comment Share on other sites More sharing options...
Csonicgo Posted November 1, 2003 Share Posted November 1, 2003 didn't Koolaid man use illegal opcodes? Quote Link to comment Share on other sites More sharing options...
MegaManFan Posted November 2, 2003 Share Posted November 2, 2003 Well Thomas, what about Vault Assault? You never responded. Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2003 Share Posted November 2, 2003 Well Thomas, what about Vault Assault? You never responded. Sorry, I missed your reply. You are refering to thisthread, right? This is no problem with "illegal" opcodes, but with "illegal" programming. Some hardware registeres are accessed during a period where they shouldn't be, causing unpredictable results. Probably a similar problem as with Kool Aid Man. Quote Link to comment Share on other sites More sharing options...
Big Player Posted November 2, 2003 Share Posted November 2, 2003 So I understand this correctly, one advantage of using certain illegal opcodes is saving computer cycles, since two operations are performed with one instruction? Are there other advantages? Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2003 Share Posted November 2, 2003 Are there other advantages? They also save some ROM space (by executing two instructions in one and by allowing some nice tricks e.g. with NOP). Any other advantages you had in your mind? There aren't any more I can think about. Quote Link to comment Share on other sites More sharing options...
Bryan Posted November 2, 2003 Share Posted November 2, 2003 Are there other advantages? They also save some ROM space (by executing two instructions in one and by allowing some nice tricks e.g. with NOP). Any other advantages you had in your mind? There aren't any more I can think about. I can think of 3: Speed - Sometimes you can shave a cycle or two with an Illegal Op Size - Sometimes you can shave a byte or two as well Multi-Length NOP's - During timed portions of code, having a 3,4,5 cycle NOP can be useful. Oh yeah, a 4th reason is that they can make you feel like an uber-coder. -Bry Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted November 2, 2003 Share Posted November 2, 2003 Multi-Length NOP's - During timed portions of code, having a 3,4,5 cycle NOP can be useful. Yup! How could I forget that one? Oh yeah, a 4th reason is that they can make you feel like an uber-coder. The best reason of all. Quote Link to comment Share on other sites More sharing options...
Inky Posted November 2, 2003 Share Posted November 2, 2003 I'm going to have to place you all under arrest for violation of some portion of the PATRIOT ACT for discussion of things which may or may not be illegal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.