MOS Technologies 6502

HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

The 6502 is an eight-bit microprocessor designed by MOS Technologies in 1975 and made by Rockwell.

Unlike the Intel 8080 and similar microprocessors, the 6502 had very few registers. It was an 8-bit processor, with 16-bit address bus. Inside was one 8-bit data register (accumulator), two 8-bit index registers, and 8-bit processor status register and an 8-bit stack pointer

The stack's address space was hard wired at $0100 (256) to $01FF (511). Software access to the stack was through four implied mode instructions, whose functions were to push or pull (pop) the accumulator or the processor status register.

It used these index and stack registers effectively, with more addressing modes, including a fast "direct page" or "zero page" mode that accessed memory locations from address 0 to 255 with an 8-bit address (it didn't have to fetch a second byte for the address); code for the 6502 used the zero page much as code for other processors would have used registers.

Addressing modes also included implied (1 byte instructions); absolute (3 bytes); relative (2 bytes); accumulator (1); (indirect,x) (2); (indirect),y (2); and immediate (2). Absolute mode was a general-purpose mode. Relative was used for conditional branch instructions, which could move the program counter up to 128 bytes forward or backward. Accumulator mode used the accumulator as an effective address, and didn't need any operand data. The indirect modes were useful for array processing. The offset was an 8-bit quantity stored in page 0 memory. Immediate mode used an 8-bit literal operand.

Back when the 6502 was introduced, RAM was actually faster than CPUs, so it made sense to optimize for RAM access rather than increase the number of registers on a chip.

The 6502 was used in the BBC Micro and the first members of the Apple II family, as well as various Commodore and Atari personal computers. Steve Wozniak described it as the first chip you could get for less than a hundred dollars (actually a quarter of the Motorola 6800 price).

One of the more important uses of the 6502 was in the Nintendo Entertainment System or NES, Famicom in Japan. The 6502 used in the NES was a modified version that was produced solely for Nintendo, called "2A03". The 2A03 lacked the 6502's decimal mode but added 23 memory-mapped registers for sound generation, object drawing, and joypad reading.

The 6502's indirect jump instruction, JMP (xxxx), was broken. If the address was hexadecimal xxFF, the processor would not access the address stored in xxFF and xxFF + 1, but rather xxFF and xx00. The 6510 did not fix this bug, nor was it fixed in any of the other NMOS versions of the 6502 such as the 8502 and the 2A03. William D. Mensch at Western Design Center was probably the first to fix it, in the 65C02; he then went on to design the WDC 65C816 processor.

The 6502 also had several useful undocumented instructions arising from "don't care" cells in the opcode decoder.

See also: MOS Technologies 6501

This article (or an earlier version of it) contains material from FOLDOC, used with permission.