| ▲ | Extra Instructions Of The 65XX Series CPU (1996)(ffd2.com) | |||||||||||||||||||||||||||||||
| 64 points by embedding-shape 14 hours ago | 12 comments | ||||||||||||||||||||||||||||||||
| ▲ | Dwedit 19 minutes ago | parent | next [-] | |||||||||||||||||||||||||||||||
One way to use unofficial instructions is so you can use Read-Modify-Write instructions in addressing modes that the official instruction cannot be used in. To understand, it helps if you write out the instruction table in columns, so here's the CMP and DEC instructions: Byte C1: (add 4 to get to the next instruction in this table) CMP X,ind [x indirect, read instruction's immediate value, add X, then read that pointer from zeropage, written like CMP ($nn,x)] CMP zpg [zeropage, written like CMP $nn] CMP # [immediate value, written like CMP #$nn] CMP abs [absolute address, written like CMP $nnnn] CMP ind,Y [indirect Y, read pointer from zeropage then add Y, written like CMP ($nnnn,Y)] CMP zpg,X [zeropage plus X, add X to the zeropage address, written like CMP $nn,X] CMP abs,Y [absolute address plus Y, add Y to the address, written like CMP $nnnn,Y] CMP abs,X [absolute address plus X, add X to the address, written like CMP $nnnn,X] So that's 8 possible addressing modes for this instruction. Immediately afterwards: Byte C2: (add 4 to get to the next instruction in this table) ??? DEC zpg DEX DEC abs ??? DEC zpg,X ??? DEC abs,X That's 5 possible addressing modes. So where's "DEC X,ind", "DEC ind,Y", and "DEC abs,Y"? They don't exist. Table for Byte C3 is 8 undocumented instructions that aren't supposed to be used. So people determined what the instruction did. Turns out, it's a combination of CMP and DEC, so people named the instruction "DCP". Byte C3: DCP X,ind DCP zpg ??? DCP abs DCP ind,Y DCP zpg,X DCP abs,Y DCP abs,X Unlike the "DEC" instruction, you have the "X,ind", "ind,Y", and "abs,Y" addressing modes available. So if you want to decrement memory, and don't care about your flags being correct (because it's also doing a CMP operation), you can use this DCP instruction. Same idea with INC and SBC, you get the ISC instruction. For when you want to increment, and don't care about register A and flags afterwards. | ||||||||||||||||||||||||||||||||
| ▲ | JetSetIlly 5 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
A couple of threads on AtariAge are exploring the possibility of using the "unstable" opcodes in this group (ARR, etc.) as a sort of fingerprint. The hope is that the instability is a prediction of the specific model of CPU. To what end I'm not sure of yet, but it's interesting research all the same. https://forums.atariage.com/topic/385516-fingerprinting-6502... https://forums.atariage.com/topic/385521-fingerprinting-6502... | ||||||||||||||||||||||||||||||||
| ▲ | djmips 22 minutes ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
a good essay on how they work https://www.pagetable.com/?p=39 | ||||||||||||||||||||||||||||||||
| ▲ | ruk_booze 9 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
A nice guide on how to actually put those ”illegal opcodes” into work is ”No More Secrets” | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| ▲ | rossjudson 13 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||
Some of those crazy instructions were used for copy protection, back in the day. Those mystery page boundary overflows were entertaining. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||