Opentopia Directory Encyclopedia Tools

MOS Technology 6502

Encyclopedia : M : MO : MOS : MOS Technology 6502


The MOS Technology 6502 is an 8-bit microprocessor designed by MOS Technology in 1975. When it was introduced it was the least expensive full featured CPU on the market by far, at about 1/6th the price, or less, of competing designs from larger companies such as Motorola and Intel. It was nevertheless faster than most of them, and, along with the Zilog Z80, sparked off a series of computer projects* that would eventually result in the home computer revolution of the 1980s. The 6502 design was originally second-sourced by Rockwell and Synertek and later licensed to a number of companies; it is still made for embedded systems.

(* See the list of home computers by category, which clearly shows the market divide between the 6502 and the Z80.)

A MOS 6502 processor in a DIL-40 plastic package.
Enlarge
A MOS 6502 processor in a DIL-40 plastic package.

History and use

The 6502 was designed primarily by the same engineering team that had designed the Motorola 6800. After quitting Motorola en masse, they quickly designed the 6501, a completely new processor that was pin-compatible with the 6800 (that is, it could be plugged into motherboards designed for the Motorola processor, although its instruction set was different). Motorola sued immediately, and although today the case would have been dismissed out of hand, MOS agreed to stop producing the 6501 and went back to the drawing board.

The result was the "lawsuit-compatible" 6502, which was by design unusable in a 6800 motherboard; Motorola, apparently no longer feeling threatened, did not object. However, this left MOS with the problem of getting new developers to try their processor, so engineer Chuck Peddle designed the KIM-1 single-board computer. Much to their surprise, the KIM-1 sold in huge numbers to hobbyists and tinkerers as well as to the engineers it was intended for. The related Rockwell AIM 65 control/training/development system also did well. Another roughly similar product was the Synertek SYM-1.

The 6502 was released in September 1975 at $25, when the 6800 and Intel 8080 were selling for $179. At first many people thought it was some sort of a scam, but shortly both Motorola and Intel had dropped their chips to $79. But instead of saving Intel and Motorola from the upstart MOS, the price reductions legitimized the 6502, which started selling by the hundreds.

One of the first "public" uses for the design was the Atari 2600 videogame console. The 2600 used an offshoot of the 6502 called the 6507, which had fewer pins and, as a result, could address only 8 KB of RAM. Millions of the Atari consoles would be sold, each with a MOS processor. The 6502 was next used in the Apple II family, and then appeared in various Commodore and Atari home computers, the BBC Micro family, and a huge number of other designs now lost to history such as Ohio Scientific. The 6510, a direct successor of the 6502 with a digital I/O port and a three-state bus, was the CPU utilized in the extremely popular Commodore 64 home computer. (Commodore's disk drive, the 1541, had a processor of its own—it too was a 6502.)

Another important use of the 6502 was in the Nintendo Famicom, a Japanese video game console. Its North American and European equivalent, the Nintendo Entertainment System, also used the processor. The 6502 used in the NES was a modified version, a partial system-on-a-chip, that lacked a binary-coded decimal mode but added 22 memory-mapped registers for sound generation, joypad reading, and sprite list DMA. Called 2A03 in NTSC consoles and 2A07 in PAL consoles (the difference being the clock divider ratio and a lookup table for audio sample rates), this processor was produced exclusively for Nintendo.

The efficient design of the 6502 also inspired the principal designers of the ARM RISC processor, and so the legacy of the 6502 may be said to transcend the original processor family. Its spirit lives on in the ARM design, which is used in several desktop computers as well as a plethora of handheld and other embedded systems and is sold as an IP block to be used in system-on-chip products.

Description

The 6502 is an 8-bit processor with a 16-bit address bus. The internal logic runs at the same speed as the external clock rate, but despite the slow clock speeds (typically in the neighborhood of 1 or 2 MHz), the 6502 was actually competitive with other CPUs using significantly faster clocks. This is partly due to a simplistic state machine implemented by combinatorial (clockless) logic to a greater extent than in many other designs; the two phase clock (supplying two syncronizations per cycle) can thereby control the whole machine-cycle directly. Like most simple CPUs of the era, the dynamic NMOS 6502 chip was not sequenced by a microcode ROM but nevertheless used a "small"* PLA for instruction decode and sequencing; and like most contemporary microprocessors, the chip does some overlapping of fetching and execution.

The low clock frequency moderated the speed requirement of memory and peripherals attached to the CPU as only about 50% of the clock cycle (this varied somewhat among chip versions) was available for memory access; critical at a time when (affordable) memory had access times in the range 450-250ns. The original NMOS 6502 was minimalistically engineered and efficiently manufacured and therefore cheap; an important factor in getting design wins in the very price sensitive game console and home computer markets.

Like its precursor, the Motorola 6800 (but unlike Intel 8080 and similar microprocessors) the 6502 has very few registers**. Inside was one 8-bit accumulator register (A), two 8-bit index registers (X and Y), an 8-bit processor status register (P), an 8-bit stack pointer (S), and a 16-bit program counter (PC). The subroutine call/scratchpad stack's address space was to memory page $01, i.e. the address range $0100$01FF (256511). Software access to the stack was done via four implied addressing mode instructions whose function were to push or pop (pull) the accumulator or the processor status register. The same stack was also used for subroutine calls via the JSR (Jump to Subroutine) and RTS (Return from Subroutine) instructions.

The chip used the index and stack registers effectively with several addressing modes, including a fast "direct page" or "zero page" mode that accessed memory locations from address 0 to 255 with a single 8-bit address (saving the cycle normally required to fetch the second byte of the address) – code for the 6502 used the zero page much as code for other processors would have used registers. In most 6502-based microcomputers with an operating system, the OS itself used almost the entire zero page, leaving perhaps a handful of locations for the user.

Addressing modes also included implied (1 byte instructions); absolute (3 bytes); indexed absolute (3 bytes); indexed zero-page (2 bytes); relative (2 bytes); accumulator (1); indirect,x and indirect,y (2); and immediate (2). Absolute mode was a general-purpose mode. Branch instructions uses a signed 8-bit offset to modify the program counter as it would appear if the branch were not taken (i.e. two bytes past the branch instruction itself); the numerical range -128..127 therefore translates to 126 bytes backwards and 129 bytes forward from the branch instruction. Accumulator mode used the accumulator as an effective address, and did not need any operand data. Immediate mode used an 8-bit literal operand.

The indirect modes were useful for array processing and other looping. With the 5/6 cycle "(indirect),y" mode, the 8-bit Y register was added to a 16-bit base address in zero page, located by a single byte following the opcode; incrementing Y in order to walk the array (byte wise) took only two additional cycles. The Y register was thus an index register in a true sense, and the 6502's specifications, saying 8-bit index registers***, may be taken literally; it is about 8-bit indexing, not 8-bit addressing. With the less frequently used "(indirect,x)" mode the effective address for the operation was found at the zero page address formed by adding the second byte of the instruction to the contents of the X register. Using the indexed modes, the zero page effectively acted as a set of 128 additional (though very slow) address registers.

See the article for a simple but characteristic example of 6502 assembly language.

* About 15% of the chip area actually!

** The 6800 was designed around 1973 at a time when (small bipolar) memories were relatively fast. It therefore made sense to use RAM instead of wasting expensive NMOS chip area on CPU-registers (then a significant part of the CPU)

*** This is where the 6502 differs most from the Motorola 6800, which has one 16 bits address/index register instead of two eight bits index registers.

Dubious features

16-bit derivatives

Synertek published a data sheet and application notes on the SY6516, a 16-bit derivative of the 6502, but the part was never introduced.

The Western Design Center designed and produced the 65816 processor, a 16-bit successor to the 65C02 as well as a hybrid offshoot called the 65802 which was a 65816 with a 64 KB address space in a 65(C)02 pin-compatible package.

Mitsubishi (now Renesas Technology) made a line of 16-bit microcontrollers with an architecture very similar to the 65816, though it was not 100% compatible.

Acceleration

Many users of 1 MHz 6502-based systems soon wished their computers could go faster. A number of companies sold replacement hardware to speed up those systems. Generally, 6502 system accelerators were based on:

6502 trivia

See also

Wikibooks has a manual, textbook or guide to this subject:

References

External links

This article was originally based on material from the Free On-line Dictionary of Computing, which is [Foldoc licenselicensed] under the GFDL.



65xx-series CPUs from MOS Technology, second source/clone vendors, and the Western Design Center
MOS 4510MOS 6501MOS 6502WDC 65C02Hudson HuC6280Ricoh 2A03MOS 6507MOS 6508MOS 6509
MOS 6510 (and 7501, 8500, 8501) ● MOS 8502MOS 65CE02WDC 65802WDC 65816Ricoh 5A22Nintendo SA-1

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: