All Topics  
MOS Technology 6502

 
MOS Technology 6502

   Email Print
   Bookmark   Link






 

MOS Technology 6502



 
 
The MOS Technology 6502 is an 8-bit
8-bit

Eight-bit CPUs normally use an 8-bit data bus and a 16-bit address bus which means that their address space is limited to 64 KBs. This is not a "natural law", however, so there are exceptions....
 microprocessor
Microprocessor

A microprocessor incorporates most or all of the functions of a central processing unit on a single integrated circuit . The first microprocessors emerged in the early 1970s and were used for electronic calculators, using Binary-coded decimal arithmetic on 4-bit Word ....
 that was designed by Chuck Peddle
Chuck Peddle

Electronics engineer Chuck Peddle is mostly known as the main designer of the MOS Technology MOS Technology 6502 microprocessor; the KIM-1 single-board computer; and its successor the Commodore PET personal computer, both based on the 6502....
 and Bill Mensch
Bill Mensch

United States engineer William David Mensch, Jr., born 9 February 1945 in Quakertown, Pennsylvania, Pennsylvania, is the founder, chairman and CEO of the Western Design Center of Mesa, Arizona, Arizona....
 for MOS Technology
MOS Technology

MOS Technology, Inc., also known as CSG , was a integrated circuit design and Semiconductor device fabrication company based in Norristown, Pennsylvania, in the United States....
 in 1975. When it was introduced, it was the least expensive full-featured CPU
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 on the market by a considerable margin, costing less than one-sixth the price of competing designs from larger companies such as Motorola
Motorola

Motorola, Inc. is an United States, multinational, Fortune 100, telecommunications company based in Schaumburg, Illinois. It is a manufacturer of wireless telephone handsets, also designing and selling wireless network infrastructure equipment such as cellular transmission base stations and signal amplifiers....
 and Intel. It was nevertheless fully comparable with them, and, along with the Zilog Z80
Zilog Z80

The Zilog Z80 is an 8-bit microprocessor designed and sold by Zilog from July 1976 onwards. It was widely used both in desktop and embedded computer designs as well as for military purposes....
, sparked a series of computer projects that would eventually result in the home computer
Home computer

A home computer was a class of personal computer entering the market in 1977 and becoming common during the 1980s. They were marketed to consumers as accessible personal computers, more capable than video game consoles....
 revolution of the 1980s.






Discussion
Ask a question about 'MOS Technology 6502'
Start a new discussion about 'MOS Technology 6502'
Answer questions from other users
Full Discussion Forum



Encyclopedia


The MOS Technology 6502 is an 8-bit
8-bit

Eight-bit CPUs normally use an 8-bit data bus and a 16-bit address bus which means that their address space is limited to 64 KBs. This is not a "natural law", however, so there are exceptions....
 microprocessor
Microprocessor

A microprocessor incorporates most or all of the functions of a central processing unit on a single integrated circuit . The first microprocessors emerged in the early 1970s and were used for electronic calculators, using Binary-coded decimal arithmetic on 4-bit Word ....
 that was designed by Chuck Peddle
Chuck Peddle

Electronics engineer Chuck Peddle is mostly known as the main designer of the MOS Technology MOS Technology 6502 microprocessor; the KIM-1 single-board computer; and its successor the Commodore PET personal computer, both based on the 6502....
 and Bill Mensch
Bill Mensch

United States engineer William David Mensch, Jr., born 9 February 1945 in Quakertown, Pennsylvania, Pennsylvania, is the founder, chairman and CEO of the Western Design Center of Mesa, Arizona, Arizona....
 for MOS Technology
MOS Technology

MOS Technology, Inc., also known as CSG , was a integrated circuit design and Semiconductor device fabrication company based in Norristown, Pennsylvania, in the United States....
 in 1975. When it was introduced, it was the least expensive full-featured CPU
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 on the market by a considerable margin, costing less than one-sixth the price of competing designs from larger companies such as Motorola
Motorola

Motorola, Inc. is an United States, multinational, Fortune 100, telecommunications company based in Schaumburg, Illinois. It is a manufacturer of wireless telephone handsets, also designing and selling wireless network infrastructure equipment such as cellular transmission base stations and signal amplifiers....
 and Intel. It was nevertheless fully comparable with them, and, along with the Zilog Z80
Zilog Z80

The Zilog Z80 is an 8-bit microprocessor designed and sold by Zilog from July 1976 onwards. It was widely used both in desktop and embedded computer designs as well as for military purposes....
, sparked a series of computer projects that would eventually result in the home computer
Home computer

A home computer was a class of personal computer entering the market in 1977 and becoming common during the 1980s. They were marketed to consumers as accessible personal computers, more capable than video game consoles....
 revolution of the 1980s. The 6502 design was originally second-sourced
Second source

In the electronics industry, a second source is a company that is licensed to manufacture and sell components originally designed by another company ....
 by Rockwell
Rockwell International

Rockwell International was the ultimate incarnation of a series of companies under the sphere of influence of Willard Rockwell, who had made his fortune after the invention and successful launch of a new bearing system for truck axles in 1919....
 and Synertek
Synertek

Synertek, Inc. was an United States semiconductor manufacturer founded in 1973. The initial founding group consisted of Bob Schreiner , Dan Floyd, Zvi Grinfas, Jack Baletto, and Gunnar Wetlesen....
 and later licensed to a number of companies; it is still made for embedded system
Embedded system

An embedded system is a special-purpose computer system designed to perform one or a few dedicated functions, often with real-time computing constraints....
s.

Mos 6502ad 4585 Top

History and use

The 6502 was designed primarily by the same engineering team that had designed the Motorola 6800
Motorola 6800

The 6800 is an 8-bit microprocessor produced by Motorola and released shortly after the Intel 8080 in late 1974. It had 78 instructions, including the famous, undocumented Halt and Catch Fire bus test instruction....
. After resigning from Motorola
Motorola

Motorola, Inc. is an United States, multinational, Fortune 100, telecommunications company based in Schaumburg, Illinois. It is a manufacturer of wireless telephone handsets, also designing and selling wireless network infrastructure equipment such as cellular transmission base stations and signal amplifiers....
 en masse, the team went looking for another company that would be interested in hosting a design team, and found MOS Technology, then a small chipmaking company whose main product was a single-chip implementation of the popular Pong
Pong

Pong is one of the earliest Arcade game video games, and is a tennis sports game featuring simple 2D computer graphics. The aim is to defeat an opponent?either computer-controlled or a second player?by earning a higher score....
 video game.

At MOS, they quickly designed the 6501
MOS Technology 6501

The 6501 is an eight-bit microprocessor, the first sold by MOS Technology. The 6501 is the first member of the MOS Technology 65xx of microprocessors....
, a completely new processor that was pin-compatible with the 6800 (that is, it could be plugged into motherboard
Motherboard

A motherboard is the central printed circuit board in some complex electronic systems, such as modern personal computers. The motherboard is sometimes alternatively known as the mainboard, system board, or, on Apple Inc....
s designed for the Motorola processor, although its instruction set was different). Motorola sued immediately, and 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 but otherwise identical to the 6501. Motorola had no objection. However, this left MOS with the problem of getting developers to try their processor, so engineer Peddle designed the KIM-1
KIM-1

The KIM-1, short for Keyboard Input Monitor, was a small MOS Technology 6502-based microcomputer kit developed and produced by MOS Technology and launched in 1975....
 simple single-board computer. Much to their surprise, the KIM-1 sold well 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
SYM-1

The SYM-1 was a Microprocessor development board produced by Synertek circa 1978. Originally called the VIM-1 , that name was changed for legal reasons sometime between April and August 1978....
.

Apple Iieb
The 6502 was introduced at $25 at the Westcon show in September 1975. The company had an off-floor suite with a wooden barrel full of the chips, although this early run meant only the ones at the top of the barrel worked. At the same show the 6800 and Intel 8080
Intel 8080

The Intel 8080 was an early microprocessor designed and manufactured by Intel. The 8-bit microprocessor was released in April 1974 running at 2 megahertz , and is generally considered to be the first truly usable microprocessor....
 were selling for $179. At first many people thought the new chip's price was a hoax or a mistake, but while the show was still ongoing both Motorola and Intel had dropped their chips to $79. These price reductions legitimized the 6502, which started selling by the hundreds.

One of the first "public" uses for the design was the Apple I computer, introduced in 1976. The 6502 was next used in the Commodore PET
Commodore PET

The PET was a home computer-/personal computer produced by Commodore International starting in 1977. Although it was not a top seller outside the Canadian, US, and UK educational markets, it was Commodore's first full-featured computer and would form the basis for their future success....
 and the Apple II. It was later used in the Atari
Atari 8-bit family

The Atari 8-bit family is a series of 8-bit home computers manufactured from 1979 to 1992. All are based on the MOS Technology MOS Technology 6502 central processing unit and were the first home computers designed with custom coprocessor chips, giving them the most powerful graphic, sound and I/O subsystems of any 8 bit machine of their time...
 home computers, the BBC Micro
BBC Micro

The BBC Microcomputer System, or BBC Micro, was a series of microcomputers and associated peripherals designed and built by Acorn Computers for the BBC Computer Literacy Project, operated by the British Broadcasting Corporation....
 family, the Commodore VIC-20
Commodore VIC-20

The VIC-20 is an 8-bit home computer which was sold by Commodore International. The VIC-20 was announced in 1980, roughly three years after Commodore's first personal computer, the Commodore PET....
 and a large number of other designs both for home computers and business, such as Ohio Scientific
Ohio Scientific

Ohio Scientific Inc. was a United States computer company that built and marketed computers from the late 1970s to the early 1980s. The company was founded by Mike and Charity Cheiky in 1975 in Hiram, Ohio....
.

Commodore64
The 6510
MOS Technology 6510

The MOS Technology 6510 is a microprocessor designed by MOS Technology, and is a modified form of the very successful MOS Technology 6502.The primary change from the 6502 was the addition of an 8-bit general purpose input/output port ....
, a direct successor of the 6502 with a digital I/O port and a three-state address bus, was the CPU
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 utilized in the Commodore 64
Commodore 64

The Commodore 64 is an 8-bit home computer released by Commodore International in August, 1982, at a price of United States dollar595. Preceded by the Commodore VIC-20 and Commodore MAX Machine, the C64 features 64 kilobytes of Random-access memory with sound and graphics performance that were superior to IBM-compatible computers of tha...
 home computer. (Commodore's disk drive, the 1541
Commodore 1541

The Commodore 1541 , made by Commodore International, was the best-known floppy disk drive for the Commodore 64 home computer. The 1541 was a single-sided 170 kilobyte drive for 5?" disks....
, had a processor of its own—it too was a 6502.)

Another important use of the 6500 family was in video games. The first to make use was the Atari 2600
Atari 2600

The Atari 2600 is a video game console released in October 1977. It is credited with popularizing the use of microprocessor-based hardware and cartridge containing game code, instead of having non-microprocessor dedicated console hardware with all games built in....
 videogame console. The 2600 used an offshoot of the 6502 called the 6507
MOS Technology 6507

The 6507 is an 8-bit microprocessor from MOS Technology It is a "cut down" version of their popular MOS Technology 6502. To reduce costs the 6507 included only thirteen address pins instead of the 6502's sixteen....
, which had fewer pins and, as a result, could address only 8 KB
Kilobyte

Kilobyte is a unit of Computer data storage equal to either 1,024 bytes or 1,000 bytes , depending on context.It is abbreviated in a number of ways: KB, kB, K and Kbyte....
 of memory. Millions of the Atari consoles would be sold, each with a MOS processor. Another significant use was by the Nintendo Famicom
Nintendo Entertainment System

The Nintendo Entertainment System is an 8-bit video game console that was released by Nintendo in North America, Europe and Australia in . In most of Asia, including Japan , the Philippines, China, Vietnam and Singapore, it was released as the ....
, a Japan
Japan

Japan is an island country in East Asia. Located in the Pacific Ocean, it lies to the east of the Sea of Japan, People's Republic of China, North Korea, South Korea and Russia, stretching from the Sea of Okhotsk in the north to the East China Sea and Taiwan in the south....
ese video game console. Its international equivalent, the Nintendo Entertainment System
Nintendo Entertainment System

The Nintendo Entertainment System is an 8-bit video game console that was released by Nintendo in North America, Europe and Australia in . In most of Asia, including Japan , the Philippines, China, Vietnam and Singapore, it was released as the ....
, also used the processor. The 6502 used in the NES was a second source
Second source

In the electronics industry, a second source is a company that is licensed to manufacture and sell components originally designed by another company ....
 version by Ricoh
Ricoh

or Ricoh, is a Japanese company that was established on February 6, 1936 as , a company in the RIKEN zaibatsu. It is headquartered in the Ricoh Building in Chuo, Tokyo, Tokyo....
, a partial system-on-a-chip
System-on-a-chip

System-on-a-chip or system on chip refers to integrating all components of a computer or other Electronics system into a single integrated circuit ....
, that lacked a binary-coded decimal
Binary-coded decimal

In computing and electronics systems, binary-coded decimal is an encoding for decimal numbers in which each digit is represented by its own binary sequence....
 mode but added 22 memory-mapped registers for sound generation, joypad reading, and sprite
Sprite (computer graphics)

In computer graphics, a sprite is a two-dimensional/three-dimensional or animation that is integrated into a larger scene.Sprites were originally invented as a method of quickly compositing several images together in two-dimensional video games using special hardware....
 list DMA
Direct memory access

Direct memory access is a feature of modern computers and microprocessors that allows certain hardware subsystems within the computer to access system Computer storage for reading and/or writing independently of the central processing unit....
. Called 2A03 in NTSC
NTSC

NTSC is the analog television system used in most of the Americas, Japan, South Korea, Taiwan, the Philippines, Burma, and some Pacific island nations and territories ....
 consoles and 2A07 in PAL
PAL

PAL, short for Phase Alternating Line, is a color-encoding system used in broadcast television systems in large parts of the world. Other common analog television systems are SECAM and NTSC....
 consoles (the difference being the memory divider
Memory divider

A Memory divider is a ratio which is used to determine the operating clock frequency of computer memory in accordance with Front Side Bus frequency, if memory system is dependent on FSB clock speed....
 ratio and a lookup table for audio sample rates), this processor was produced exclusively for Nintendo
Nintendo

is a global company located in Kyoto, Japan founded on September 23, 1889 by Fusajiro Yamauchi to produce handmade hanafuda cards. By 1963, the company had tried several small niche businesses, such as a cab company and a love hotel....
.

Even as of 2006, some universities, including the Eindhoven University of Technology, the Netherlands, University of Tasmania
University of Tasmania

The University of Tasmania is an Australian university, with three campuses in Tasmania. A 'Sandstone universities', it is the fourth-oldest university in Australia....
, the University of Applied Sciences
University of applied sciences

University of Applied Sciences is a university type, originated in the Education in Germany. It refers to:* Fachhochschule, a Germany or Austrian institution of academic higher education, including undergraduate and postgraduate education....
 in Cologne
Cologne

Cologne is Germany's fourth-largest city , and is the largest city both in the German Federal State of North Rhine-Westphalia and within the Rhine-Ruhr, one of the major European metropolitan areas with more than ten million inhabitants....
, Germany
Germany

Germany , officially the Federal Republic of Germany , is a country in Central Europe. It is bordered to the north by the North Sea, Denmark, and the Baltic Sea; to the east by Poland and the Czech Republic; to the south by Austria and Switzerland; and to the west by France, Luxembourg, Belgium, and the Netherlands....
, University of Exeter
University of Exeter

The University of Exeter is a university in the South West England of England. Most of its activities are located in the city of Exeter, Devon, where it is the principal higher education institution....
 in Devon
Devon

Devon is a large Counties of England in South West England. The county is also referred to as Devonshire, but that is an entirely unofficial name, rarely used inside of the county but often indicating a shire....
, England
England

native_name =|conventional_long_name = England|common_name = England|image_flag = Flag of England.svg|image_coat = England COA.svg|symbol_type = Royal Coat of Arms...
, Carleton College
Carleton College

Carleton College is an independent Sectarianism, coeducational, Liberal arts colleges in the United States in Northfield, Minnesota, Minnesota, United States....
, Hull University, Matthew Boulton College
Matthew Boulton College

Matthew Boulton College is a Further and Higher Education college situated in the Eastside, Birmingham of Birmingham, West Midlands . It has Centre of Vocational Excellence status in Print Media & Graphics, Business & Professional Services and Vocational Medical Sciences....
, University of Brescia
Brescia

Brescia is a city in the region of Lombardy in northern Italy. It is situated at the foot of the Alps, between the Mella and the Naviglio, with a population of around 190,000....
 in Italy
Italy

Italy , officially the Italian Republic , is a country located on the Italian Peninsula in Southern Europe and on the two largest islands in the Mediterranean Sea, Sicily and Sardinia....
 and Universidad APEC
Universidad APEC

Universidad APEC is a private university located in Santo Domingo, Dominican Republic. It was founded in 1965 under the name of Instituto de Estudios Superiores ....
 in Santo Domingo
Santo Domingo

Santo Domingo, or in full, Santo Domingo de Guzm?n, is the Capital and largest city in the Dominican Republic, and the second largest city in the Caribbean....
, Dominican Republic
Dominican Republic

The Dominican Republic is a nation on the island of Hispaniola, part of the Greater Antilles archipelago in the Caribbean region. The western third of the island is occupied by the nation of Haiti, making Hispaniola one of two Caribbean islands that are List of divided islands, Saint Martin being the other....
 still use the processor to teach assembly language, computer architecture and digital integrated systems.

Technical description

The 6502 is an 8-bit
8-bit

Eight-bit CPUs normally use an 8-bit data bus and a 16-bit address bus which means that their address space is limited to 64 KBs. This is not a "natural law", however, so there are exceptions....
 processor with a 16-bit address bus
Address bus

An address bus is a computer bus that is used to specify a memory address. When a central processing unit or direct memory access-enabled device needs to read or write to a memory location, it specifies that memory location on the 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's performance 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 synchronizations 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 used a PLA
Programmable logic array

A programmable logic array is a programmable device used to implement combinational logic electrical network. The PLA has a set of programmable AND gate planes, which link to a set of programmable OR gate planes, which can then be conditionally complemented to produce an output....
 (which occupied about 15% of the chip area) for instruction decoding and sequencing. Like most typical eight-bit microprocessors, the chip does some limited 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 was available for memory access (due to the asynchronous design, this percentage varied strongly among chip versions). This was critical at a time when affordable memory had access times in the range 450-250ns. The original NMOS 6502 was minimalistically engineered and efficiently manufactured and therefore cheap—an important factor in getting design wins in the very price-sensitive game console and home computer markets.
Mos6502
Like its precursor, the Motorola
Motorola

Motorola, Inc. is an United States, multinational, Fortune 100, telecommunications company based in Schaumburg, Illinois. It is a manufacturer of wireless telephone handsets, also designing and selling wireless network infrastructure equipment such as cellular transmission base stations and signal amplifiers....
 6800
Motorola 6800

The 6800 is an 8-bit microprocessor produced by Motorola and released shortly after the Intel 8080 in late 1974. It had 78 instructions, including the famous, undocumented Halt and Catch Fire bus test instruction....
 (but unlike Intel 8080
Intel 8080

The Intel 8080 was an early microprocessor designed and manufactured by Intel. The 8-bit microprocessor was released in April 1974 running at 2 megahertz , and is generally considered to be the first truly usable microprocessor....
 and similar microprocessors) the 6502 has very few registers
Processor register

In computer architecture, a processor register is a small amount of Computer storage available on the CPU whose contents can be accessed more quickly than storage available elsewhere....
. At the time the processor was designed, small bipolar memories were relatively fast, so it made sense to rely on RAM instead of wasting expensive NMOS chip area on CPU
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
-registers.

The 6502's registers included one 8-bit accumulator
Accumulator (computing)

In a computer's central processing unit , an accumulator is a processor register in which intermediate arithmetic logic unit results are stored....
 register (A), two 8-bit index register
Index register

An index register in a computer's central processing unit is a processor register used for modifying operand addresses during the run of a program, typically for doing vector/array operations....
s (X and Y), an 8-bit processor status register
Status register

A status register is a collection of Flag bits for a Central processing unit. A popular example of a status register is the FLAGS register of x86 architecture based microprocessors....
 (P), an 8-bit stack pointer
Stack (data structure)

In computer science, a stack is an abstract data type and data structure based on the principle of LIFO . Stacks are used extensively at every level of a modern computer system....
 (S), and a 16-bit program counter
Program counter

The program counter, or PC is a processor register that indicates where the computer is in its instruction sequence. Depending on the details of the particular computer, the PC holds either the address of the instruction being executed, or the address of the next instruction to be executed....
 (PC). The subroutine call/scratchpad stack's address space was hardwired 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 functions 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, and for interrupt
Interrupt

In computing, an interrupt is an asynchronous communication signal from hardware indicating the need for attention or a synchronous event in software indicating the need for a change in execution....
 handling.

The chip used the index and stack registers effectively with several addressing mode
Addressing mode

Addressing modes are an aspect of the instruction set architecture in most central processing unit designs. The various addressing modes that are defined in a given instruction set architecture define how Machine code Instruction in that architecture identify the operand of each instruction....
s, including a fast "direct page" or "zero page
Zero page

The zero page is the series of memory addresses at the absolute beginning of a computer's address space; that is, the page whose starting address is zero....
" mode, similar to that found on the PDP-8
PDP-8

The PDP-8 was the first successful commercial minicomputer, produced by Digital Equipment Corporation in the 1960s. DEC introduced it on 22 March 1965, and sold more than 50,000 systems, the most of any computer up to that date....
, that accessed memory locations from address 0 to 255 with a single 8-bit address (saving the cycle normally required to fetch the high-order byte of the address)—code for the 6502 used the zero page much as code for other processors would have used registers. On some 6502-based microcomputers with an operating system, the OS would use most of zero page, leaving only a handful of locations for the user.

Addressing mode
Addressing mode

Addressing modes are an aspect of the instruction set architecture in most central processing unit designs. The various addressing modes that are defined in a given instruction set architecture define how Machine code Instruction in that architecture identify the operand of each instruction....
s 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 used a signed 8-bit offset relative to the instruction after the branch; the numerical range -128..127 therefore translates to 128 bytes backward and 127 bytes forward from the instruction following the branch (which is 126 bytes backward and 129 bytes forward from the start of the branch instruction). Accumulator mode used the accumulator as an effective address, and did not need any operand
Operand

An operand is one of the inputs of an operator in mathematics. The following arithmetic expression shows an example of operators and operands:...
 data. Immediate mode used an 8-bit literal
Literal

Literal may refer to:*Literal and figurative language, taken in a non-figurative sense.*Literal translation, the close adherence to the forms of a source language text....
 operand.

The indirect modes were useful for array
Array

In computer science, an array is a data structure consisting of a group of element s that are accessed by index . In most programming languages each element has the same data type and the array occupies a contiguous area of computer memory....
 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. As the resulting address could be anywhere in the 16-bit memory range, the Y register was a true index register, as opposed to the 6800, which had one 16-bit address register. Incrementing the index register to walk the array byte-wise took only two additional cycles. 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.

The 6502 also included a set of binary coded decimal (BCD) instructions, a feature normally implemented in software. Placing the CPU into BCD allowed numbers to be manipulated in base-10, with a set of conversion instructions to convert between base-10 and binary (base-2). For instance, with the "D" flag set, 99+1 would result in 00 and the carry flag being set. These instructions made implementing a BASIC programming language easier, removing the need to convert numbers for display in the BASIC interpreter itself. However, this feature meant other useful instructions could not be implemented due to a lack of CPU real estate, and was sometimes removed to make room for custom instructions.

A Byte magazine
Byte (magazine)

Byte magazine was an influential microcomputer computer magazine in the late 1970s and throughout the 1980s, because of its wide-ranging editorial coverage....
 article once referred to the 6502 as "the original RISC processor," due to its efficient, simplistic, and nearly orthogonal instruction set
Orthogonal instruction set

Orthogonal instruction set is a term used in computer engineering. A computer's instruction set is said to be orthogonal if any instruction can use data of any type via any addressing mode....
 (most instructions work with most addressing modes), as well as its 256 zero-page "registers". The 6502 is technically not a RISC design however, as arithmetic operations can read any memory cell (not only zero-page), and some instructions (inc, rol etc.) even modify memory contrary to the basic load/store philosophy of RISC. Furthermore, orthogonality
Orthogonal instruction set

Orthogonal instruction set is a term used in computer engineering. A computer's instruction set is said to be orthogonal if any instruction can use data of any type via any addressing mode....
 is equally often associated with "CISC
Complex instruction set computer

A complex instruction set computer is a computer instruction set architecture in which each instruction can execute several low-level operations, such as a load from Memory , an arithmetic operator, and a memory , all in a single instruction....
". However the 6502 performed reasonably well compared to other contemporaneous processors such as the Z80, which used a much faster clock rate, and the 6502 has been credited as being inspirational to RISC processors such as the ARM
ARM architecture

The ARM architecture is a 32-bit RISC central processing unit architecture developed by ARM Limited that is widely used in embedded system designs....
.

See the Hello world! article for a simple but characteristic example of 6502 assembly language
Assembly language

An assembly language is a low-level language for programming computers. It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture....
.

Detailed behavior

The processor's non-maskable interrupt
Non-Maskable interrupt

A non-maskable interrupt is a computer Central processing unit interrupt that cannot be ignored by standard interrupt masking techniques in the system....
 input is edge sensitive, which means that if the source of an NMI holds the line low NMI's are effectively disabled.

The simultaneous assertion of the NMI (non-maskable) and IRQ
Interrupt request

The computing phrase "interrupt request" is used to refer to either the act of interrupting the Computer bus lines used to signal an interrupt, or the interrupt input lines on a Programmable Interrupt Controller ....
 (maskable) hardware interrupt lines causes IRQ to be ignored. However, if the IRQ line remains asserted after the servicing of the NMI, the processor will immediately respond to IRQ, as IRQ is level-sensitive. Thus a sort of built-in interrupt priority was established in the 6502 design.

The "Break" flag of the processor is very different from the other flag bits. It has no flag setting, resetting, and testing instructions of its own, and is not handled by the PHP and PLP instructions either. It exists only on the stack, where BRK and PHP write a 1, while IRQ and NMI write a 0.

Bugs & Quirks

The original 6502 and its NMOS derivatives are noted for having a variety of undocumented instructions
Illegal opcode

An Illegal Opcode, also called an Undocumented Instruction, is an instruction to a CPU that is not mentioned in any official documentation released by the CPU's designer or manufacturer, which nevertheless has an effect....
, which vary from one chip manufacturer to the next. The 6502's instruction decoding is implemented in a hardwired logic array (similar to a programmable logic array
Programmable logic array

A programmable logic array is a programmable device used to implement combinational logic electrical network. The PLA has a set of programmable AND gate planes, which link to a set of programmable OR gate planes, which can then be conditionally complemented to produce an output....
) which is only defined for 151 of the 256 available opcode
Opcode

In computer technology, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question ....
s. The remaining 105 trigger strange and hard-to-predict actions (e.g., immediately crashing the processor, performing several valid instructions at once, or simply doing nothing at all). Eastern House Software developed the "Trap65", a device that plugged between the processor and its socket to convert (trap) unimplemented opcodes into BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 (software interrupt) instructions. Some programmers utilized this feature to extend the 6502's instruction set by providing functionality for the unimplemented opcodes with specially written software intercepted at the BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 instruction's 0xFFFE vector. All of the undefined opcodes have been replaced by NOP
NOP

In computer science NOP or NOOP is an assembly language instruction, sequence of programming language statements, or protocol command that effectively does nothing at all....
 instructions in the 65C02
WDC 65C02

The Western Design Center WDC 65C02 microprocessor is an upgraded CMOS version of the popular NMOS logic-based MOS Technology 6502 8-bit central processing unit — the CMOS redesign being made by Bill Mensch of the Western Design Center ....
 CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 version (although with varying byte sizes and execution times).

The 6502's memory indirect jump
Indirect branch

An indirect branch is a type of control flow present in some machine language instruction sets. Rather than specifying the memory address of the next instruction to execution , as in a direct Branch , the parameter specifies where the address is located....
 instruction, JMP (<address low-word>), is partially broken. If <address low-word> was hex
Hexadecimal

In mathematics and computer science, hexadecimal is a numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen....
 xxFF (i.e. any word ending in FF), the processor would not jump to the address stored in xxFF and xxFF+1, but rather the one in xxFF and xx00. Called "address wrapping". This defect continued through the entire NMOS line, but was fixed in the CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 derivatives.

The 6502's Indirect-Indexed-Y ((Ind),Y) addressing mode is also partially broken. If the zero-page address was hex
Hexadecimal

In mathematics and computer science, hexadecimal is a numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen....
 FF (i.e. last address of zero-page FF), the processor would not fetch data from the address pointed to by xxFF and xxFF+1 + Y, but rather the one in FF and 00 +Y. The address wraps. This defect continued through the entire NMOS line, but was fixed in the CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 derivatives.

The 6502's Indirect-Indexed-X ((Ind,X)) addressing mode is also partially broken if the zero-page address was hex
Hexadecimal

In mathematics and computer science, hexadecimal is a numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 09 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen....
 FF (i.e. last address of zero-page FF), the address wraps.

The 6502's indexed addressing across page boundaries will do an extra read of invalid address. This can cause issues by accessing hardware that acts on a read (clearing timer or IRQ flags, sending an I/O handshake). This defect continued through the entire NMOS line, but was fixed in the CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 derivatives, the processor does an extra read of last instruction byte.

The 6502's Read/Modify/Write instruction at effective address does one read and two write cycles. This can cause issues by twice accessing hardware that acts on a write. This defect continued through the entire NMOS line, but was fixed in the CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 derivatives, the processor will do two reads and one write cycle.

The N (result negative), V (sign bit overflow) and Z (result zero) status flags
Status register

A status register is a collection of Flag bits for a Central processing unit. A popular example of a status register is the FLAGS register of x86 architecture based microprocessors....
 are not valid when performing arithmetic operations while the processor is in BCD
Binary-coded decimal

In computing and electronics systems, binary-coded decimal is an encoding for decimal numbers in which each digit is represented by its own binary sequence....
 mode, as these flags reflect the binary, not BCD, result. This limitation was removed in the CMOS
CMOS

Complementary metal?oxide?semiconductor , is a major class of integrated circuits. CMOS technology is used in microprocessors, microcontrollers, Static Random Access Memory, and other digital logic circuits....
 derivatives. Therefore, this feature may be used to cleanly distinguish CMOS from NMOS CPU versions without using any illegal opcodes ().

If the processor happens to be in BCD mode when a hardware interrupt occurs it will not revert to binary mode. This quirk could result in hard-to-solve bugs in the interrupt service routine if it failed to clear BCD mode before performing any arithmetic operations. For example, the Commodore 64
Commodore 64

The Commodore 64 is an 8-bit home computer released by Commodore International in August, 1982, at a price of United States dollar595. Preceded by the Commodore VIC-20 and Commodore MAX Machine, the C64 features 64 kilobytes of Random-access memory with sound and graphics performance that were superior to IBM-compatible computers of tha...
's kernel did not correctly handle this processor characteristic, requiring that IRQs be disabled or revectored during BCD
BCD

BCD may refer to:* Bad Conduct Discharge, a form of discharge from US military service* Bachelor of Community Design, a three year university degree offered at Dalhousie University...
 math operations. This issue was addressed in the CMOS derivatives as well.

The SO pin (Set Overflow) was intended for use in high-speed device drivers. Asserting it would immediately set the processor's Overflow (V) status register bit. Successful use of this feature could eliminate a load instruction from a high-speed device driver, reducing the number of instructions in a data transfer loop by 25%, but obviously great care was required in the system design in order not to corrupt general computation.

The 6502 instruction set includes BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 (opcode $00), which is technically a software interrupt (similar in spirit to the SWI mnemonic of the 6800
Motorola 6800

The 6800 is an 8-bit microprocessor produced by Motorola and released shortly after the Intel 8080 in late 1974. It had 78 instructions, including the famous, undocumented Halt and Catch Fire bus test instruction....
). BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 is most often used to interrupt program execution and start a machine code monitor
Machine code monitor

A machine code monitor is software built into or separately available for various computers, allowing the user to enter commands to view and change memory address on the machine, with options to load and save memory contents from/to secondary storage....
 for testing and debugging during software development. It could also be used to route program execution using a simple jump table (analogous to the manner in which the 8088
Intel 8088

The Intel 8088 is an Intel x86 microprocessor based on the Intel 8086, with 16-bit registers and an 8-bit external data bus. It can address up to 1 megabyte of random access memory....
 and derivatives handle software interrupts by number). Unfortunately, if a hardware interrupt occurs at the same time the processor is fetching a BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 instruction, the NMOS version of the processor will fail to execute BRK
BRK

The 65xx family of processors — the MOS Technology 6502 and its derivatives, the WDC 65C02 and the WDC 65816/65802 — all handle interrupts in roughly the same way....
 and instead proceed as if only a hardware interrupt had occurred. This fault was corrected in the CMOS implementation of the processor.

The JSR (call subroutine) instruction pushes the address of the last byte of the call instruction on to the stack
Stack

Stack may refer to:...
 (the program counter
Program counter

The program counter, or PC is a processor register that indicates where the computer is in its instruction sequence. Depending on the details of the particular computer, the PC holds either the address of the instruction being executed, or the address of the next instruction to be executed....
 would have been increased after execution has been done) . The RTS (return) instruction pulls the return address off the stack and increments it before placing it into the program counter
Program counter

The program counter, or PC is a processor register that indicates where the computer is in its instruction sequence. Depending on the details of the particular computer, the PC holds either the address of the instruction being executed, or the address of the next instruction to be executed....
, resulting in automatic compensation for this design quirk(). This characteristic would go unnoticed unless you pulled the return address to pick up parameters in the code stream (a common 6502 programming idiom). It remains a characteristic of 6502 derivatives to this day.

16-bit derivatives

The Western Design Center
Western Design Center

The Western Design Center , located in Mesa, Arizona, United States, is a company developing and manufacturing MOS Technology 65xx-based microprocessors, microcontrollers , and related support chips....
 designed and produced the 65C816 processor, a 16-bit successor to the 65C02, as well as a hybrid offshoot called the 65C802 which was a 65C816 core with a 64 KB address space in a 65(C)02 pin-compatible package—it could be plugged into a 6502 board and would function as a 65C02, or it could be configured via software to expose its 16 bit accumulator
Accumulator (computing)

In a computer's central processing unit , an accumulator is a processor register in which intermediate arithmetic logic unit results are stored....
 and index registers. Few 65C802 parts were sold, and the chip is no longer produced.

The 65C816 was the core of the widely popular Super Nintendo Entertainment System
Super Nintendo Entertainment System

The Super Nintendo Entertainment System or Super NES is a History of video game consoles video game console that was released by Nintendo in North America, Europe, Australasia , and South America between 1990 and 1993....
, and the Apple IIGS
Apple IIGS

The Apple , the fifth model inception of the Apple II, was the most powerful member of the Apple II series of microcomputer made by Apple Inc.. At the time of its release, it was capable of advanced color graphics and then-state-of-the-art sound synthesis that surpassed those of most other computers, including the black and white Macintosh ....
. The 65C816 is still widely used, both as a discrete
Electronic component

An electronic component is a basic Electronics element usually packaged in a discrete form with two or more connecting leads or metallic pads....
 processor and as the core of a microcontroller
Microcontroller

A microcontroller is a small computer on a single integrated circuit consisting of a relatively simple CPU combined with support functions such as a crystal oscillator, timers, watchdog, serial and analog I/O etc....
.

Mitsubishi
Mitsubishi

The , Mitsubishi Group of Companies, or Mitsubishi Companies is a Japanese Conglomerate consisting of a range of autonomous businesses which share the Mitsubishi brand, trademark and legacy....
 (now Renesas Technology
Renesas Technology

is a Japanese Semiconductor device manufacturer. It is based in Tokyo and has manufacturing, design and sales operations in around 20 countries with about 26,200 employees worldwide....
) made a line of 16-bit microcontrollers with an architecture very similar to the 65816, though it was not 100% compatible.

Synertek
Synertek

Synertek, Inc. was an United States semiconductor manufacturer founded in 1973. The initial founding group consisted of Bob Schreiner , Dan Floyd, Zvi Grinfas, Jack Baletto, and Gunnar Wetlesen....
 published a data sheet and application notes on the SY6516, a 16-bit derivative of the 6502, but the part was never introduced.

32-bit derivatives

The Western Design Center at one time claimed to be developing a W65T32 Terbium, a compatible 32-bit follow-up to the W65C816. The Terbium was named after the 65th element
Terbium

Terbium is a chemical element with the symbol Tb and atomic number 65....
 as 65 is the prefix to all of WDC's microprocessor number identifiers. The chip would have had a 32-bit address bus, a 16-bit data bus, and a variable length instruction set.

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 or 65C02 chips running at a faster clock rate
  • 65C816
    WDC 65816/65802

    The WDC 65816 , a 16-bit microprocessor central processing unit developed by the Western Design Center, is an expanded and compatible successor to the venerable MOS Technology MOS Technology 6502....
     chips in 6502 emulation mode, running at a much faster clock rate (up to 20 MHz)
  • 4 MHz and 8 MHz Zip Chip processors, made by Zip Technology, and 10 MHz Rocket Chips, made by Bits and Pieces, all using onboard cache RAM and proprietary glue logic to speed up processing while remaining compatible with a 1 MHz motherboard. Zip Technology's patent #4,794,523 eventually forced Bits and Pieces to cease manufacturing of the Rocket Chip.


6502 in popular culture

In the science fiction movie The Terminator
The Terminator

The Terminator is a 1984 in film Science fiction film/action film directed and co-written by James Cameron. It features Arnold Schwarzenegger, Linda Hamilton and Michael Biehn....
 (1984), starring Arnold Schwarzenegger
Arnold Schwarzenegger

Arnold Alois Schwarzenegger is an Austrian-American bodybuilder, actor, businessman, and Politics of the United States, currently serving as the List of Governors of California Governor of California of the state of California....
, the audience at one point is treated to a view through the T-800
T-800

The Terminator is a fictional character portrayed by Arnold Schwarzenegger – a cyborg, initially portrayed as a programmable assassin and military infiltration unit....
 Model-101 robot character's eye/camera
Computer vision

Computer vision is the science and technology of machines that see. As a scientific discipline, computer vision is concerned with the theory for building artificial systems that obtain information from images....
 display with some 6502 assembly
Assembly language

An assembly language is a low-level language for programming computers. It implements a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture....
/machine code
Machine code

Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit. Machine code may be regarded as a primitive programming language or as the lowest-level representation of a compiled and/or assembly language computer program....
 program fragments scrolling
Scrolling

In computer graphics, movies, television, and other kinetic displays, scrolling is sliding text, images or video across a monitor or display. "Scrolling", as such, does not change the layout of the text or pictures, or but incrementally moves panning or Tilt the user's view across what is apparently a larger image that is not wholly seen....
 down the screen. The program was listing the Apple
Apple II series

The Apple II was one of the first highly successful mass produced microcomputer products, manufactured by Apple Computer and introduced in 1976....
 Disk Operating System (DOS) 3.3 disassembled
Disassembler

A disassembler is a computer program that translates machine language into assembly language?the inverse operation to that of an Assembly language#Assembler....
 program listing. Also shown is the output from a run of an Apple ][ checksum
Checksum

A checksum or hash sum is a fixed-size data computed from an arbitrary block of digital data for the purpose of error detection that may have been introduced during its telecommunications or computer storage....
 program called KEY PERFECT 4.0, published in Nibble magazine
Nibble (magazine)

Nibble was a magazine for Apple II family computer users with a focus on hobbyist Computer programming. The nibble meant "half a byte" or "four bits." Its slogan was "The Magazine for Apple II Enthusiasts." Most of the articles incorporated the source code of a small to medium-sized utility, application program, or game and a detaile...
.

Bender
Bender Bending Rodríguez

Bender, full name Bender "Bending" Rodr?guez and designated Bending Unit 22, is a fictional robot character in the animated television series Futurama....
, a fictional android "industrial robot" manufactured in 2998 CE, and a main character in the animated TV series Futurama
Futurama

Futurama is an Animated cartoon United States Situation comedy created by Matt Groening, and developed by Groening and David X. Cohen for the Fox Broadcasting Company....
, was revealed to have a 6502 as his "brain," in the episode "Fry and the Slurm Factory
Fry and the Slurm Factory

"Fry and the Slurm Factory" is the thirteenth episode of the first production season of Futurama. It originally aired in North America on November 14, 1999 as the fourth episode of the second broadcast season....
."

See also

  • Lisa assembler
    Lisa assembler

    Lazer's Interactive Symbolic Assembler is an interactive MOS Technology 6502 assembly language#Assembler for Apple II family computers written by Randall Hyde in the late 1970s....
  • MOS Technology 6502-based home computers
    List of home computers by category

    This is a list of home and office computers by category where the main category is the home computer's CPU word and the subcategory is the specific central processing unit used in each machine....
  • Interrupts in 65xx processors


External links

General information:
  • – Repository and portal (Mike Naberezny)
  • – Concise description, photos of MOS and second source chips; at cpu-collection.de (Dirk Oppelt)
  • – The secret, transparent, high-throughput 6502 DMA channel (by Jorge Chamorro Bieling)
  • – 6502 instruction set


Instruction set features:
  • – With link to concise 6502 programming chart in PDF
    Portable Document Format

    Portable Document Format is a file format created by Adobe Systems in 1993 for document exchange. PDF is used for representing two-dimensional documents in a manner independent of the application software, hardware, and operating system....
     (Eric Clever)
  • – By Dennette A. Harrod, in BYTE
    Byte (magazine)

    Byte magazine was an influential microcomputer computer magazine in the late 1970s and throughout the 1980s, because of its wide-ranging editorial coverage....
    , Volume 5, Number 10 (October 1980), pp.282–5


Emulators and simulators:
  • – At Zophar's Domain (Sam Michaels)
  • – At Dan Boris' homepage hosted by The Atari Gaming Headquarters
  • – by Stian Sřreng


Early 6502 computers:
  • – Hosted by the Applefritter site (Tom Owad)
  • – At The Obsolete Technology Website (anonymous collector)
  • – The Old Computer Hut


Hardware accelerators:
  • – At the Apple II History website (Steven Weyhrich)
  • – By Jim Brain, in C=Hacking, Issue #12, Version 1.3, March 1996 (search for "@(#)cmdcpu")


Hardware:
  • – home of the 65xx brand CMOS microprocessors.