Undocumented instructions

Let's talk about anything related to the 6502 microprocessor.
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

Undocumented instructions

Post by asmlang_6 »

Can anyone give me a list of what the undocumented instructions of the MOS 6502 do? Undocumented as in undocumented (not listed on the NMOS 6502 Opcodes page).
Sam

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
kc5tja
Posts: 1706
Joined: 04 Jan 2003

Re: Undocumented instructions

Post by kc5tja »

asmlang_6 wrote:
Can anyone give me a list of what the undocumented instructions of the MOS 6502 do? Undocumented as in undocumented (not listed on the NMOS 6502 Opcodes page).
Since the 6510 is just a 6502 with an I/O port integrated into it (literally, that's the only difference), you might want to find the 6510 undocumented opcode map. With the ubiquity of the Commodore 64, this almost certainly will be far easier to find than the 6502's list.
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

Re: Undocumented instructions

Post by asmlang_6 »

kc5tja wrote:
Since the 6510 is just a 6502 with an I/O port integrated into it (literally, that's the only difference), you might want to find the 6510 undocumented opcode map.
Two things:

I didn't ask for the 6510 undocumented opcode map.

Where is that list, anyway?
Sam

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
Memblers
Posts: 64
Joined: 16 Jan 2003
Location: Indianapolis
Contact:

Post by Memblers »

There's a list on my site, on the bottom of this section:
http://nesdev.parodius.com/#Docs6502

By all accounts I've heard, all CPUs based on the NMOS 6502 have the same undocumented ops. C64, Atari, and NES included.
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

Post by asmlang_6 »

Memblers wrote:
There's a list on my site, on the bottom of this section:
http://nesdev.parodius.com/#Docs6502
I'm talking about undocumented as in not even on the "NMOS 6502 Opcodes" part of 6502.org.
Sam

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Post by GARTHWILSON »

kc5tja suggested the C64's 6510 because internally it's the same processor and searching the C64 material would likely get you what you're looking for. I understand that Berkeley Softworks used the undocumented op codes when they wrote GEOS for the C64.

Memblers also understood what you wanted, and gave the link to his site which in turn has plenty of good stuff for you. Three of the links I found there dealing with undocumented op codes are:
http://nesdev.parodius.com/undocumented_opcodes.txt
http://nesdev.parodius.com/extra_instructions.txt
http://nesdev.parodius.com/6502_cpu.txt

These unofficial op codes however really should only be used for legacy code and hardware. If you want a more powerful 6502, you'll do much better to use the CMOS version (expecially WDC's, which are being made today), or the 65816.
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

Post by asmlang_6 »

Thanks! I've found all the opcodes from $00 to $FF.
Sam

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
asmlang_6
Posts: 53
Joined: 20 Jul 2005
Location: Hawaii

Post by asmlang_6 »

Correction: there is one opcode I can't find: $8B.
Sam

---
"OK, let's see, A0 on the 6502 goes to the ROM. Now where was that reset vector?"
debounce
Posts: 27
Joined: 23 Nov 2004
Location: London, UK

$8B = ANE

Post by debounce »

The operation $8B is documented in 6502_cpu.txt, under ANE (thanks Garth.) "The BBC Lives" has an updated version of the document, with a few corrections plus a section on the Commodore memory map (which I wouldn't know anything about, I'm just a BBC Micro guy.)
User avatar
Mike Naberezny
Site Admin
Posts: 296
Joined: 30 Aug 2002
Location: Northern California
Contact:

Undocumented Opcodes

Post by Mike Naberezny »

GARTHWILSON wrote:
Three of the links I found there dealing with undocumented op codes are:
http://nesdev.parodius.com/undocumented_opcodes.txt
http://nesdev.parodius.com/extra_instructions.txt
http://nesdev.parodius.com/6502_cpu.txt

These unofficial op codes however really should only be used for legacy code and hardware. If you want a more powerful 6502, you'll do much better to use the CMOS version (expecially WDC's, which are being made today), or the 65816.
We should really take this information and put together a good document for 6502.org.

On a similar note, another thing that needs to be done is expanding the opcodes page for the additional 65C02 and 65C816 opcodes.

Any volunteers?

Thanks,
Mike
User avatar
dclxvi
Posts: 362
Joined: 11 Mar 2004

Post by dclxvi »

By "expanding the opcodes page", do you mean something along the lines of the "NMOS 6502 Opcodes" (under the "Tutorials and Primers") for the 65C02 and 65816? If so, I'll volunteer for those. Rather than making one long document, I suggest three separate documents for the 6502, 65C02, and 65816. I would also suggest that the 65C02 document merely consist of the changes between the 65C02 and the 6502, since there are far more similarities (software-wise) than differences. The 65816, on the other hand, has very few opcodes with no changes and no additional functionality (CLC is one example). Even something like DEX which is 2 cycles and 1 byte under all conditions has a change in functionality: it's a 16-bit decrement when the x flag is 0, but an 8-bit decrement when x=1. Also, some examples that illustrate the "caveats" in the 65816 would probably be helpful, as these are somewhat lightly documented in the datasheet and WDC's Programming Manual.

I don't wish to discourage anyone from volunteering for the undocumented NMOS 6502 opcodes (I have a few 6502s, but have never really explored the undocumented opcodes myself), but I should point out that the various documents that describe these opcodes and the (cross) assemblers that can assemble them use names that differ from each other. For example, there are opcode names used in the March 1981 AAL article which do not appear in the documents linked above. It would be a good idea to do some research and gather as many different names as possible so that as many names as possible can be documented.
nelbr
Posts: 15
Joined: 19 Apr 2005

Re:

Post by nelbr »

GARTHWILSON wrote:
kc5tja suggested the C64's 6510 because internally it's the same processor and searching the C64 material would likely get you what you're looking for. I understand that Berkeley Softworks used the undocumented op codes when they wrote GEOS for the C64.

Memblers also understood what you wanted, and gave the link to his site which in turn has plenty of good stuff for you. Three of the links I found there dealing with undocumented op codes are:
http://nesdev.parodius.com/undocumented_opcodes.txt
http://nesdev.parodius.com/extra_instructions.txt
http://nesdev.parodius.com/6502_cpu.txt

These unofficial op codes however really should only be used for legacy code and hardware. If you want a more powerful 6502, you'll do much better to use the CMOS version (expecially WDC's, which are being made today), or the 65816.
Thanks for the information. After long research, I found the source of a bug on Ultima I on my Apple ][ emulator and sure enough, it was caused by an undocumented opcode. So, I decided to implement them on my underlying 6502 emulator.

However, looking at the links above, I see conflicting information with regards to status flags. For example, for opcodes $83, $87, $8F, $93

Document 1 claims that:

AAX (SAX) [AXS]
AND X register with accumulator and store result in memory. Status flags: N,Z

Document 2 claims that:

AXS *** (SAX)
AXS ANDs the contents of the A and X registers (without changing the contents of either register) and stores the result in memory.
AXS does not affect any flags in the processor status register.


Document 1 is not clear if the accumulator is affected and claims flags N and Z are. Document 2 however is more clear, claims accumulator is not affected and no flags are affected. I am thinking on using document 2 for my emulation, just wondering if there is anything updated and more streamlined by now ?
User avatar
GARTHWILSON
Forum Moderator
Posts: 8775
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Re:

Post by GARTHWILSON »

nelbr wrote:
[I'm] just wondering if there is anything updated and more streamlined by now.
See that section of my links page by going to http://wilsonminesco.com/links.html#soft and then down to the ten links after the blank line, starting with "How 6502 illegal op codes really work". Another blank line separates that section from the next one.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
nelbr
Posts: 15
Joined: 19 Apr 2005

Re: Re:

Post by nelbr »

GARTHWILSON wrote:
nelbr wrote:
[I'm] just wondering if there is anything updated and more streamlined by now.
See that section of my links page by going to http://wilsonminesco.com/links.html#soft and then down to the ten links after the blank line, starting with "How 6502 illegal op codes really work". Another blank line separates that section from the next one.
Oh, great thanks. Very cool site and lots of information on those links.
John West
Posts: 383
Joined: 03 Sep 2002

Re: Undocumented instructions

Post by John West »

"No More Secrets" https://csdb.dk/release/?id=198357is the best description I've seen. The most recent version includes the effect of the RDY pin on some instructions that had previously been considered to behave randomly.
Post Reply