65xx
Talk0this wiki
The 65xx family of processors includes the 6502 and the variants of the 6502. This page tries to enumerate the different 65xx processors and describe their relationship.
This page does not help much if you want to learn assembly. Instead you want the main assembly hacking page, or the page for the processor in your system.
Contents |
Overview
Edit
These processors are old technology from the 1970s and 1980s. Each 65xx processor does 8-bit integer arithmetic and has a 16-bit address space. (The 65816 processor extends this to 16-bit integer arithmetic and to 24-bit address space.) Most of the 65xx processors have instructions for addition and subtraction, but not multiplication nor division. The 65xx processors do not have floating-point instructions, nor virtual memory, nor privilege levels.
For assembly hacking, you need not learn every 65xx variant. You can learn the processor in your target system, and skip the other variants. If you target the SNES, then you can learn the 65816 and skip the 6502.
From the home page of WLA DX, you can download a mnemonic list for your processor. The mnemonic list shows the available instructions and addressing modes for your processor. (You can use the list whether or not you use WLA DX.) If you would switch to a different processor in the 65xx family, then you can use the different mnemonic list to learn about the different processor.
6502
Edit
Year 1975 introduced the 6502 processor. The 6502 was the original member of the 65xx family. Some other chips had different numbers (like 6510 or 2a03) but implement the 6502 instruction set; each such chip is also a 6502 for our purpose.
The 6502 appeared in very many systems. Each of the Atari systems (2600 through 7800) and the NES has a 6502 central processor.
The other 65xx processors extend the 6502 with some additional opcodes, so the 6502 is a 65xx which has a minimum of opcodes. The 6502 also has greater quirks than the other 65xx processors; you might worry about quirks if you switch from another 65xx to 6502.
65c02
Edit
- Assembler: wla-65c02
The 65c02 processor comes between the 6502 and the 65816; the 65c02 has more opcodes than the 6502 but fewer opcodes than the 65816. The 65c02 has every 6502 opcode; the 65816 has almost every 65c02 opcode. Against the 6502, the 65c02 adds
- new addressing modes like lda ($nn) and jmp ($nnnn,x).
- new instructions like bra, phx, ply, stz, trb, tsb.
A later variant of the 65c02 adds the 32 special opcodes for the instructions bbr[0-7], bbs[0-7], rmb[0-7] and smb[0-7]. The 65816 has all 65c02 opcodes except these 32 special opcodes.
Few ROM hackers would encounter the 65c02, but the Atari Lynx FAQ mentions that the Atari Lynx has a 65c02. Handy, the Lynx emulator, emulates a 65c02 without the 32 special opcodes.
65sc02
Edit
We are not sure about the term "65sc02". The CSG65CE02 Technical Reference uses the term "65sc02" to refer to a 65c02 including the 32 special opcodes; but a forum thread uses the term "65sc02" to refer to a 65c02 without the 32 special opcodes. So if someone says "65sc02", you are not sure if it means to have the 32 special opcodes (bbr[0-7], bbs[0-7], rmb[0-7] and smb[0-7]) or to not have them.
65ce02
Edit
The 65ce02, also known as the CSG65CE02, is one of the variants of the 65c02. This particular variant only appears in the Commodore 65. The 65ce02 seems to have all 65c02 opcodes (including the 32 special opcodes), plus some new opcodes and features, including a third index register called Z, and a block register B to move the direct page.
HuC6280
Edit
- Assembler: wla-huc6280 (but does it work?)
The HuC6280 is another variant of the 65c02. The TurboGrafx-16 has a HuC6280 central processor. The HuC6280 seems to have all 65c02 opcodes (including the 32 special opcodes), plus some new instructions, like
- cla to clear the accumulator to zero.
- sxy to swap the values of the index registers X and Y.
65816
Edit
The 65816, also known as the 65c816, is a another variant of the 65c02, but is better than the 65ce02 or the HuC6280. ROM hackers know the 65816 as the central processor of the SNES. The 65816 has all 65c02 opcodes (except the 32 special opcodes), plus some new addressing modes and some new instructions.
The "816" in the name of the 65816 refers to the ability, through the 65816 processor flags, to switch the A, X and Y processors between 8-bit and 16-bit. (These registers are always 8-bit in other 65xx processors.) The 16-bit A allows 16-bit arithmetic; the 16-bit X and Y allow larger indexes, or you can use them to hold 16-bit addresses.
The 24-bit address space of the 65816 is less useful than it might have been, because the 65816 divides the address space into 16-bit banks. Assembly language mostly uses 16-bit addresses which access a particular bank. A few addressing modes use 24-bit long addresses, but long addresses tend to be not convenient to use.
6510
Edit
- Assembler: wla-6510 (but does it work?)
The 6510 processor is another version of the original 6502. The 6510 is the central processor of the Commodore 64. Some hardware pins might be different, but the 6502 and the 6510 share the same instructions. The 6510 has all original 6502 opcodes, plus not any new opcodes.
The difference between wla-6502 and wla-6510 is that wla-6510 also has instruction mnemonics for some of the illegal opcodes of the 6502 or 6510. Commodore 64 users tried some opcodes other than the documented 6502 or 6510 opcodes, found that some opcodes had consistent behavior, and invented new mnemonics for them.
SPC-700
Edit
- Assembler: wla-spc700
The SPC-700 processor does not belong to the 65xx family, but some of the concepts and instructions are similar. ROM hackers know the SPC-700 as the audio coprocessor of the SNES.
Some of the SPC-700 instructions are exactly like 6502 instructions, except that the opcode is different and the assembly syntax fits a different pattern. For example,
- the SPC-700 mov A, $nn (opcode $e4) is like the 6502 sta $nn (opcode $85).
- the SPC-700 mov $nn, A (opcode $c4) is like the 6502 lda $nn (opcode $a5).
The new pattern fits the new SPC-700 instruction mov $nn, $nn (opcode $fa).
References
Edit
- http://6502.org/ has some 65xx documents and code samples.
- 65xx opcodes
- FOLDOC entry for 6502
- 65C02 Opcodes explains the opcodes in the 65c02 that were not in the 6502.
- 65c02
- Atari Lynx FAQ
- C65c02.h in the source code of Handy
- 65ce02
- HuC6280
- 6510
- FOLDOC entry for 6510
- Pagezero Commodore Specifications has a 6510 reference, including illegal opcodes.
- How MOS 6502 Illegal Opcodes really work