| 1 |
|
| 2 |
|
| 3 |
ACME |
| 4 |
|
| 5 |
...the ACME Crossassembler for Multiple Environments |
| 6 |
|
| 7 |
--- Undocumented ("illegal") opcodes --- |
| 8 |
|
| 9 |
|
| 10 |
In release 0.87, support for some of the undocumented opcodes of the |
| 11 |
NMOS 6502 processor was added. |
| 12 |
In release 0.89, some more were added. |
| 13 |
In release 0.94.8, another one ("LXA") was added. |
| 14 |
In release 0.95.2, the "ANC" opcode was changed from 0x2b to 0x0b. |
| 15 |
In release 0.95.3, C64DTV2 support was added, which includes these |
| 16 |
opcodes as well. |
| 17 |
In release 0.95.4, the remaining seven were added. |
| 18 |
In release 0.95.6, "ANC" was removed from C64DTV2 mode. |
| 19 |
|
| 20 |
Here are the new mnemonics, possible addressing modes and generated |
| 21 |
opcodes (mnemonics in parentheses are used by other sources): |
| 22 |
|
| 23 |
| addressing mode | |
| 24 |
mnemonic | 8 8,x 8,y 16 16,x 16,y (8,x) (8),y | performs: |
| 25 |
----------------+--------------------------------------+----------- |
| 26 |
slo (aso) | 07 17 0f 1f 1b 03 13 | asl + ora |
| 27 |
rla (rln) | 27 37 2f 3f 3b 23 33 | rol + and |
| 28 |
sre (lse) | 47 57 4f 5f 5b 43 53 | lsr + eor |
| 29 |
rra (rrd) | 67 77 6f 7f 7b 63 73 | ror + adc |
| 30 |
sax (axs, aax) | 87 97 8f 83 | stx + sta |
| 31 |
lax | a7 b7 af bf a3 b3 | ldx + lda |
| 32 |
dcp (dcm) | c7 d7 cf df db c3 d3 | dec + cmp |
| 33 |
isc (isb, ins) | e7 f7 ef ff fb e3 f3 | inc + sbc |
| 34 |
las (lar, lae) | bb | A,X,S = {addr} & S |
| 35 |
tas (shs, xas) | 9b | S = A & X {addr} = A&X& {H+1} |
| 36 |
sha (axa, ahx) | 9f 93 | {addr} = A & X & {H+1} |
| 37 |
shx (xas, sxa) | 9e | {addr} = X & {H+1} |
| 38 |
shy (say, sya) | 9c | {addr} = Y & {H+1} |
| 39 |
|
| 40 |
| addressing mode | |
| 41 |
mnemonic | implied #8 8 8,x 16 16,x | performs: |
| 42 |
----------------+---------------------------------+----------------------- |
| 43 |
anc (ana) | 0b* | A = A & arg, then C=N |
| 44 |
anc (anb) | 2b* | A = A & arg, then C=N |
| 45 |
alr/asr | 4b | A = A & arg, then lsr |
| 46 |
arr | 6b | A = A & arg, then ror |
| 47 |
sbx (axs, sax) | cb | X = (A & X) - arg |
| 48 |
dop (nop, skb) | 80** 80 04 14 | skips next byte |
| 49 |
top (nop, skw) | 0c** 0c 1c | skips next two bytes |
| 50 |
nop (skb, skw) | ea 80 04 14 0c 1c | see the two lines above |
| 51 |
jam (kil, hlt) | 02 | crash (wait for reset) |
| 52 |
These two are somewhat unstable, because they involve an arbitrary value: |
| 53 |
ane (xaa, axm) | 8b*** | A = (A | ??) & X & arg |
| 54 |
lxa (lax, atx) | ab*** | A,X = (A | ??) & arg |
| 55 |
|
| 56 |
Example: |
| 57 |
!cpu nmos6502 ; activate additional mnemonics... |
| 58 |
lax (some_zp_label,x) ; ...and use them. No, this |
| 59 |
dcp (other_zp_label),y ; example does not make sense. |
| 60 |
|
| 61 |
*) Up until ACME version 0.95.1, anc#8 generated opcode 0x2b. Since |
| 62 |
ACME version 0.95.2, anc#8 generates opcode 0x0b. Both opcodes work |
| 63 |
the same way on a real NMOS 6502 CPU, but they do not work on the |
| 64 |
C64DTV2. |
| 65 |
|
| 66 |
**) Note that DOP ("double nop") and TOP ("triple nop") can be used |
| 67 |
with implied addressing, but the generated opcodes are those for |
| 68 |
immediate and 16-bit absolute addressing, respectively, This way DOP |
| 69 |
and TOP can be used to skip the following one- or two-byte |
| 70 |
instruction. |
| 71 |
Using DOP/TOP with x-indexed addressing might have its uses when |
| 72 |
timing is critical (crossing a page border adds a penalty cycle). |
| 73 |
Unless using implied addressing, DOP/TOP can also be written as NOP. |
| 74 |
|
| 75 |
***) ANE and LXA first perform an ORA with an arbitrary(!) value and |
| 76 |
then perform an AND with the given argument. So they are unstable and |
| 77 |
therefore useless - unless the given argument is zero: |
| 78 |
ANE #0 reliably clears A - which is still useless; just use LDA #0. |
| 79 |
LXA #0 reliably clears both A and X. |
| 80 |
ACME will output a warning if these opcodes get assembled with a |
| 81 |
nonzero argument. |
| 82 |
|
| 83 |
There is no guarantee that these opcodes actually work on a given 6502 |
| 84 |
(or 6510, or 8500, or 8501, or 8502) CPU. But as far as I know, nobody |
| 85 |
ever found an unmodified C64/C128 where these illegals didn't work. |
| 86 |
|
| 87 |
These illegals will definitely *not* work on 65c02 and 65816 CPUs. But |
| 88 |
I really should not have to tell you that ;) |
| 89 |
|
| 90 |
Because there are no official mnemonics for these opcodes, different |
| 91 |
people use different names for them. I hope my choices are not too |
| 92 |
exotic for your taste. |
| 93 |
|
| 94 |
Just for the sake of completeness: Here are all the remaining opcodes |
| 95 |
(the ones ACME won't generate even with "nmos6502" cpu chosen): |
| 96 |
|
| 97 |
Opcode| Description C64DTV2 |
| 98 |
------+-------------------------------------------------------------- |
| 99 |
12 | same as 02 and others jam CRASH bra rel |
| 100 |
1a | same as (*legal*) ea nop |
| 101 |
22 | same as 02 and others jam CRASH |
| 102 |
2b | same as 0b anc #8 dop |
| 103 |
32 | same as 02 and others jam CRASH sac #8 |
| 104 |
34 | same as 14 and others dop 8,x |
| 105 |
3a | same as (*legal*) ea nop |
| 106 |
3c | same as 1c and others top 16,x |
| 107 |
42 | same as 02 and others jam CRASH sir #8 |
| 108 |
44 | same as 04 dop 8 |
| 109 |
52 | same as 02 and others jam CRASH |
| 110 |
54 | same as 14 and others dop 8,x |
| 111 |
5a | same as (*legal*) ea nop |
| 112 |
5c | same as 1c and others top 16,x |
| 113 |
62 | same as 02 and others jam CRASH |
| 114 |
64 | same as 04 dop 8 |
| 115 |
72 | same as 02 and others jam CRASH |
| 116 |
74 | same as 14 and others dop 8,x |
| 117 |
7a | same as (*legal*) ea nop |
| 118 |
7c | same as 1c and others top 16,x |
| 119 |
82 | same as c2/e2 dop #8, but said to CRASH sometimes |
| 120 |
89 | same as 80 dop #8 |
| 121 |
92 | same as 02 and others jam CRASH |
| 122 |
b2 | same as 02 and others jam CRASH |
| 123 |
c2 | same as 82/e2 dop #8, but said to CRASH sometimes |
| 124 |
d2 | same as 02 and others jam CRASH |
| 125 |
d4 | same as 14 and others dop 8,x |
| 126 |
da | same as (*legal*) ea nop |
| 127 |
dc | same as 1c and others top 16,x |
| 128 |
e2 | same as 82/c2 dop #8, but said to CRASH sometimes |
| 129 |
eb | same as (*legal*) e9 sbc #8 |
| 130 |
f2 | same as 02 and others jam CRASH |
| 131 |
f4 | same as 14 and others dop 8,x |
| 132 |
fa | same as (*legal*) ea nop |
| 133 |
fc | same as 1c and others top 16,x |
| 134 |
|
| 135 |
For more information about what these opcodes do, see these documents: |
| 136 |
John West, Marko Mäkelä. '64doc' file, 1994/06/03. |
| 137 |
Extra Instructions Of The 65XX Series CPU, Adam Vardy, 27 Sept. 1996 |
| 138 |
6502 Undocumented Opcodes, by Freddy Offenga, 5/17/1997 |
| 139 |
AAY64 (All About Your 64) |
| 140 |
|
| 141 |
...but the most comprehensive work is: |
| 142 |
|
| 143 |
"No More Secrets - NMOS 6510 Unintended Opcodes" |
| 144 |
|
| 145 |
Download it from https://csdb.dk/release/?id=248511 |
| 146 |
or ask google for the latest version. |