1

Topic: illegal/unknown op-codes for Atari 6502C processor

Hello to all Assembler programmers there!!

Did you know that our Atari 8bit has more opcodes than the ones that are described in most machine
language books ?

These are called the "illegal" opcodes.

Some of them offer you more power and speed for your programs.

Here are some opcodes that you can also use on an 6502C cpu, because the "C" is the extended version
of the normal 6502 cpu.

TXA, TAX, TYA, TAY, TXY, TYX, PHX,PHY, PLX, PLY, CPX,CPY

and so on.

I had the complete list of these op-codes, but i bet you can find them on the internet aswell.

Advantages of using the extra op-codes/instruction set is that it reduces processor time to run a program.
And therefore, you can make demos/games look much more better and so on.

Greetinx vrom SOD/The Wizard.

2 (edited by Alphasys 13.01.2009 11:49:25)

Re: illegal/unknown op-codes for Atari 6502C processor

The CPU you're thinking about is the 65c02, which is not in the Atari. The 6502c, also known as Sally, is a standard 6502 with a halt line, which is used by the Antic to be able to get direct memory access. There are several 65c02 opcodes and/or adressing modes, that don't work with it.

65c02 Opcoded that won't work on the 6502c:
-----------------------------
All Indirect mode adressing, except for JMP.
BBR, BBS, BRA, BIT (immediate, Zeropage,X, Absolute,X), DEC (Accumulator), INC (Accumulator), JMP (indirect,X), PHX, PHY, PLX, PLY, RMB, SMB, STZ, TRB and TSB.

There are however true illegal opcodes that do work on the 6502c, but they have really odd effects at times.

ILLEGAL OPCODES
---------------
n = number of clock cycles

AAC = AND byte with accumulator. If result is negative then carrier is set.
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |AAC #arg   |$0B| 2 | 2
Immediate   |AAC #arg   |$2B| 2 | 2

AAX = AND X register with accumulator and store result in memory.
Status flags: N,Z

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |AAX #arg   |$8B| 2 | 2
Zero Page   |AAX arg    |$87| 2 | 3
Zero Page,Y |AAX arg,Y  |$97| 2 | 4
(Indirect,X)|AAX (arg,X)|$83| 2 | 6
Absolute    |AAX arg    |$8F| 3 | 4

ARR = AND byte with accumulator, then rotate one bit right in accumulator and check bit 5 and 6:
If both bits are 1: set C, clear V.
If both bits are 0: clear C and V.
If only bit 5 is 1: set V, clear C.
If only bit 6 is 1: set C and V.
Status flags: N,V,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |ARR #arg   |$6B| 2 | 2

ASR = AND byte with accumulator, then shift right one bit in accumulator.
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |ASR #arg   |$4B| 2 | 2

ATX = AND byte with accumulator, then transfer accumulator to X register.
Status flags: N,Z

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |ATX #arg   |$AB| 2 | 2

AXA = AND X register with accumulator then AND result with 7 and store in memory.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute,Y  |AXA arg,Y  |$9F| 3 | 5

AXS = AND X register with accumulator and store result in X register, then subtract byte from X register (without borrow).
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |AXS #arg   |$CB| 2 | 2

DCP = Subtract 1 from memory (without borrow).
Status flags: C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |DCP arg    |$C7| 2 | 5
Zero Page,X |DCP arg,X  |$D7| 2 | 6
Absolute    |DCP arg    |$CF| 3 | 6
Absolute,X  |DCP arg,X  |$DF| 3 | 7
Absolute,Y  |DCP arg,Y  |$DB| 3 | 7
(Indirect,X)|DCP (arg,X)|$C3| 2 | 8
(Indirect),Y|DCP (arg),y|$D3| 2 | 8

DOP = No operation (double NOP). The argument has no significance.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |DOP arg    |$04| 2 | 3
Zero Page   |DOP arg    |$14| 2 | 4
Zero Page   |DOP arg    |$34| 2 | 4
Zero Page   |DOP arg    |$44| 2 | 3
Zero Page   |DOP arg    |$54| 2 | 4
Zero Page   |DOP arg    |$64| 2 | 3
Zero Page   |DOP arg    |$74| 2 | 4
Zero Page   |DOP arg    |$80| 2 | 2
Zero Page   |DOP arg    |$82| 2 | 2
Zero Page   |DOP arg    |$89| 2 | 2
Zero Page   |DOP arg    |$93| 2 | 6*
Zero Page   |DOP arg    |$C2| 2 | 2
Zero Page   |DOP arg    |$D4| 2 | 4
Zero Page   |DOP arg    |$E2| 2 | 2
Zero Page   |DOP arg    |$F4| 2 | 4

ISC = Increase memory by one, then subtract memory from accumulator (with borrow).
Status flags: N,V,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |ISC arg    |$E7| 2 | 5
Zero Page,X |ISC arg,X  |$F7| 2 | 6
Absolute    |ISC arg    |$EF| 3 | 6
Absolute,X  |ISC arg,X  |$FF| 3 | 7
Absolute,Y  |ISC arg,Y  |$FB| 3 | 7
(Indirect,X)|ISC (arg,X)|$E3| 2 | 8
(Indirect),Y|ISC (arg),Y|$F3| 2 | 8

KIL = Stop program counter (processor lock up).
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Implied     |KIL        |$02| 1 | -
Implied     |KIL        |$12| 1 | -
Implied     |KIL        |$22| 1 | -
Implied     |KIL        |$32| 1 | -
Implied     |KIL        |$42| 1 | -
Implied     |KIL        |$52| 1 | -
Implied     |KIL        |$62| 1 | -
Implied     |KIL        |$72| 1 | -
Implied     |KIL        |$92| 1 | -
Implied     |KIL        |$B2| 1 | -
Implied     |KIL        |$D2| 1 | -
Implied     |KIL        |$F2| 1 | -

LAR = AND memory with stack pointer, transfer result to accumulator, X register and stack pointer.
Status flags: N,Z

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute,Y  |LAR arg,Y  |$BB| 3 | 4

LAX = Load accumulator and X register with memory.
Status flags: N,Z

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |LAX arg    |$A7| 2 | 3
Zero Page,X |LAX arg,X  |$B7| 2 | 4
Absolute    |LAX arg    |$AF| 3 | 4
Absolute,Y  |LAX arg,Y  |$BF| 3 | 4
(Indirect),Y|LAX (arg),Y|$A3| 2 | 6
(Indirect),Y|LAX (arg),Y|$B3| 2 | 5

NOP = No operation
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Implied     |NOP        |$1A| 1 | 2
Implied     |NOP        |$3A| 1 | 2
Implied     |NOP        |$5A| 1 | 2
Implied     |NOP        |$7A| 1 | 2
Implied     |NOP        |$DA| 1 | 2
Implied     |NOP        |$FA| 1 | 2

RLA = Rotate one bit left in memory, then AND accumulator with memory.
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |RLA arg    |$27| 2 | 5
Zero Page,X |RLA arg,X  |$37| 2 | 6
Absolute    |RLA arg    |$2F| 3 | 6
Absolute,X  |RLA arg,X  |$3F| 3 | 7
Absolute,Y  |RLA arg,Y  |$3B| 3 | 7
(Indirect,X)|RLA (arg,X)|$23| 2 | 8
(Indirect),Y|RLA (arg),Y|$33| 2 | 8

RRA = Rotate one bit right in memory, then add memory to accumulator (with carry).
Status flags: N,V,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |RRA arg    |$67| 2 | 5
Zero Page,X |RRA arg,X  |$77| 2 | 6
Absolute    |RRA arg    |$6F| 3 | 6
Absolute,X  |RRA arg,X  |$7F| 3 | 7
Absolute,Y  |RRA arg,Y  |$7B| 3 | 7
(Indirect,X)|RRA (arg,X)|$63| 2 | 8
(Indirect),Y|RRA (arg),Y|$73| 2 | 8

SBC = The same as the legal opcode $E9 (SBC #byte)
Status flags: N,V,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Immediate   |SBC #byte  |$EB| 2 | 2

SLO = Shift left one bit in memory, then OR accumulator with memory.
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |SLO arg    |$07| 2 | 5
Zero Page,X |SLO arg,X  |$17| 2 | 6
Absolute    |SLO arg    |$0F| 3 | 6
Absolute,X  |SLO arg,X  |$1F| 3 | 7
Absolute,Y  |SLO arg,Y  |$1B| 3 | 7
(Indirect,X)|SLO (arg,X)|$13| 2 | 8
(Indirect),Y|SLO (arg),Y|$03| 2 | 8

SRE = Shift right one bit in memory,  then EOR accumulator with memory.
Status flags: N,Z,C

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Zero Page   |SRE arg    |$47| 2 | 5
Zero Page,X |SRE arg,X  |$57| 2 | 6
Absolute    |SRE arg    |$4F| 3 | 6
Absolute,X  |SRE arg,X  |$5F| 3 | 7
Absolute,Y  |SRE arg,Y  |$5B| 3 | 7
(Indirect,X)|SRE (arg,X)|$43| 2 | 8
(Indirect),Y|SRE (arg),Y|$53| 2 | 8

SXA = AND X register with 7, store result in memory.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute,Y  |SXA arg,Y  |$9E| 3 | 5

SYA = AND Y register with 7, store result in memory.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute,X  |SYA arg,X  |$9C| 3 | 5

TOP = No operation (tripple NOP). The argument has no significance.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute    |TOP arg    |$0C| 3 | 4
Absolute    |TOP arg    |$1C| 3 | 4
Absolute    |TOP arg    |$3C| 3 | 4
Absolute    |TOP arg    |$5C| 3 | 4
Absolute    |TOP arg    |$DC| 3 | 4
Absolute    |TOP arg    |$FC| 3 | 4

XAS = AND X register with accumulator and store result in stack pointer, then AND stack pointer with 7 and store result in memory.
Status flags: -

Addressing  |Mnemonics  |Opc|Sz | n
------------|-----------|---|---|---
Absolute,Y  |XAS arg,Y  |$9B| 3 | 5

3

Re: illegal/unknown op-codes for Atari 6502C processor

What does 'illegal' means exactly in this case? If those opcodes offer more power, I want them too. haha