MOS Technology 6502
The 6502 is an 8-bit microprocessor designed by MOS Technologies in 1975 and made by Rockwell.
It was an 8-bit processor, with 16-bit address bus. Unlike the Intel 8080 and similar microprocessors, the 6502 had very few registers. Inside was one 8-bit register (the accumulator), two 8-bit index registers, an 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.
One of the first uses for the design was the Atari 2600, which used an offshoot version called the 6507 which had fewer pins and accessed less memory (it could address only 4k). Millions would be sold in this form. It was next used in the Apple II family, and then quickly appeared in various Commodore and Atari personal computers, the BBC Micro, and a huge number of other designs lost to history.
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.
6502s are almost notorious for having a variety of undocumented instructions, which vary from one design to the next. This was caused by roughly 32 opcodes being left undefined in the original 6502. This was common at the time, less useful instructions were printed at the outside edges of the chip, so if yields were low you could simply not document those opcodes, and many more chips would pass tests (often the damage to a chip is on the outside).
See also:
Links:
This article (or an earlier version of it) contains material from FOLDOC, used with permission.