HOME

TheInfoList




The MOS Technology 6502 (typically pronounced "sixty-five-oh-two" or "six-five-oh-two") William Mensch and the moderator both pronounce the 6502 microprocessor as ''"sixty-five-oh-two"''. is an
8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation of computer systems. Some definitions of architecture define it as descr ...
microprocessor A microprocessor is a computer processor where the data processing logic and control is included on a single integrated circuit An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) ...

microprocessor
that was designed by a small team led by
Chuck Peddle Charles Ingerham Peddle (November 25, 1937 – December 15, 2019) was an American electrical engineer Electrical engineering is an engineering discipline concerned with the study, design, and application of equipment, devices, and systems whi ...

Chuck Peddle
for
MOS Technology The metal–oxide–semiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET), also known as the metal–oxide–silicon transistor (MOS transistor, or MOS), is a type of insulated-gate field-effect transistor The field-effect trans ...
. The design team had formerly worked at
Motorola Motorola, Inc. () was an American telecommunications company based in , United States. After having lost $4.3 billion from 2007 to 2009, the company split into two independent public companies, and on January 4, 2011. Motorola Solutions ...

Motorola
on the
Motorola 6800 The 6800 ("''sixty-eight hundred''") is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit central process ...

Motorola 6800
project; the 6502 is essentially a simplified, less expensive and faster version of that design. When it was introduced in 1975, the 6502 was the least expensive microprocessor on the market by a considerable margin. It initially sold for less than one-sixth the cost of competing designs from larger companies, such as the 6800 or
Intel 8080 The Intel 8080 (''"eighty-eighty"'') is the second 8-bit microprocessor designed and manufactured by Intel. It first appeared in April 1974 and is an extended and enhanced variant of the earlier Intel 8008, 8008 design, although without binary ...
. Its introduction caused rapid decreases in pricing across the entire processor market. Along with the
Zilog Z80 The Z80 is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit central processing unit, CPU and arithmeti ...

Zilog Z80
, it sparked a series of projects that resulted in the
home computer Home computers were a class of s that entered the market in 1977 and became common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were intended for the use of a single nontech ...

home computer
revolution In political science Political science is the scientific study of politics Politics (from , ) is the set of activities that are associated with making decisions in groups, or other forms of power relations between individuals, suc ...
of the early 1980s. Popular
video game console A video game console is an electronic device that output Output may refer to: * The information produced by a computer, see Input/output In computing, input/output (I/O, or informally io or IO) is the communication between an information proc ...
s and computers, such as the
Atari 2600 The Atari 2600, originally branded as the Atari Video Computer System (Atari VCS) until November 1982, is a home video game console A home video game console is a video game console that is designed to be connected to a display device, such a ...

Atari 2600
,
Atari 8-bit family The Atari 8-bit family is a series of 8-bit home computers introduced by Atari, Inc. in 1979 as the Atari 400 and Atari 800 and manufactured until 1992. All of the machines in the family are technically similar and differ primarily in packaging. T ...
,
Apple II The Apple II (stylized as apple ][) is an and one of the world's first highly successful mass-produced products. It was designed primarily by ; oversaw the development of Apple II's foam-molded plastic case and developed the . It was in ...

Apple II
,
Nintendo Entertainment System The Nintendo Entertainment System (NES) is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit centr ...

Nintendo Entertainment System
,
Commodore 64 The Commodore 64, also known as the C64 or the CBM 64, is an 8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation ...

Commodore 64
,
Atari Lynx The Atari Lynx is a 8/16-bit handheld game console that was released by Atari Corporation in September 1989 in North America, and in Europe and Japan in 1990. It was the world's first handheld electronic game with a color LCD. It was also not ...

Atari Lynx
,
BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputer A microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit (CPU). It includes a micr ...
and others, use the 6502 or variations of the basic design. Soon after the 6502's introduction, MOS Technology was purchased outright by Commodore International, who continued to sell the microprocessor and licenses to other manufacturers. In the early days of the 6502, it was second source, second-sourced by Rockwell and
Synertek Synertek, Inc. was an American American(s) may refer to: * American, something of, from, or related to the United States of America, commonly known as the United States The United States of America (USA), commonly known as the United Stat ...
, and later licensed to other companies. In its
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "see-moss"), also known as complementary-symmetry metal–oxide–semiconductor (COS-MOS), is a type of metal–oxide–semiconductor field-effect transistor The metal–oxide–sem ...
form (the
65C02 The Western Design Center The Western Design Center (WDC), located in Mesa, Arizona Mesa ( ) is a city in Maricopa County, in the U.S. state of Arizona. It is a suburb about east of Phoenix in the East Valley section of the Phoenix Met ...
, which was developed by the
Western Design Center The Western Design Center (WDC), located in Mesa, Arizona Mesa ( ) is a city in Maricopa County Maricopa County is located in the south-central part of the U.S. state In the United States The United States of America (USA), co ...
), the 6502 family continues to be widely used in
embedded system An embedded system is a computer system A computer is a machine that can be programmed to carry out Sequence, sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as Com ...
s, with estimated production volumes in the hundreds of millions.


History and use


Origins at Motorola

The 6502 was designed by many of the same engineers that had designed the
Motorola 6800 The 6800 ("''sixty-eight hundred''") is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit central process ...

Motorola 6800
microprocessor family. Motorola started the 6800 microprocessor project in 1971 with Tom Bennett as the main architect. The chip layout began in late 1972, the first 6800 chips were fabricated in February 1974 and the full family was officially released in November 1974. John Buchanan was the designer of the 6800 chipBuchanan, John K., "MOS DC Voltage booster circuit"
US Patent 3942047
issued March 2, 1976.
Buchanan, John K., "Chip topography for MOS integrated circuitry microprocessor chip"
US Patent 3987418
issued October 19, 1976.
and Rod Orgill, who later did the 6501, assisted Buchanan with circuit analyses and chip layout.
Bill Mensch William (Bill) David Mensch, Jr. (born February 9, 1945), is an American electrical engineer born in Quakertown, Pennsylvania. He was a major contributor to the design of the Motorola 6800 8-bit microprocessor A microprocessor is a compu ...
joined Motorola in June 1971 after graduating from the University of Arizona (at age 26). His first assignment was helping define the peripheral ICs for the 6800 family and later he was the principal designer of the 6820
Peripheral Interface Adapter A Peripheral Interface Adapter (PIA) is a peripheral A peripheral or peripheral device is an auxiliary device used to put information into and get information out of the computer. The term peripheral device refers to all hardware components that ar ...
(PIA).Mensch, William D., "Chip topography for MOS interface circuit"
US Patent 3968478
issued July 6, 1976.
Motorola's engineers could run analog and digital simulations on an IBM 370-165 mainframe computer. All of the authors were with Motorola's Semiconductor Products Division. Bennett hired
Chuck Peddle Charles Ingerham Peddle (November 25, 1937 – December 15, 2019) was an American electrical engineer Electrical engineering is an engineering discipline concerned with the study, design, and application of equipment, devices, and systems whi ...

Chuck Peddle
in 1973 to do architectural support work on the 6800 family products already in progress. Page 30. Bennett already was at work on what became the 6800. "He hired me," Peddle says of Bennett, "to do the architectural support work for the product he'd already started." … Peddle says. "Motorola tried to kill it several times. Without Bennett, the 6800 would not have happened, and a lot of the industry would not have happened, either." He contributed in many areas, including the design of the 6850 ACIA (serial interface).Hepworth, Edward C., Rodney J. Means, Charles I. Peddle, "Asynchronous Communication Interface Adaptor"
Patent 3975712
issued August 17, 1976. Note: Motorola typically listed inventors in alphabetical order.
Motorola's target customers were established electronics companies such as
Hewlett-Packard The Hewlett-Packard Company, commonly shortened to Hewlett-Packard ( ) or HP, was an American multinational company headquartered in . HP developed and provided a wide variety of hardware components, as well as software and related servic ...

Hewlett-Packard
,
Tektronix Tektronix, Inc., historically widely known as Tek, is an American company best known for manufacturing test and measurement devices such as oscilloscope model 475A portable analog oscilloscope, a typical instrument of the late 1970s An oscillo ...
,
TRWTRW may refer to: * TRW Inc., former US aerospace and automotive company, purchased by Northrop Grumman ** TRW Automotive, spun off from TRW Inc., later ZF TRW Automotive Holdings Corp. * The Real World (TV series), ''The Real World'' (TV series), a ...
, and
Chrysler Chrysler (; officially Stellantis North America) is one of the " Big Three" automobile manufacturer The automotive industry comprises a wide range of company, companies and organizations involved in the design, Business development, develo ...

Chrysler
. Advertisement showing three embedded applications from TRW, HP and RUSCO. In May 1972, Motorola's engineers began visiting select customers and sharing the details of their proposed 8-bit microprocessor system with ROM, RAM, parallel and serial interfaces. In early 1974, they provided engineering samples of the chips so that customers could prototype their designs. Motorola's "total product family" strategy did not focus on the price of the microprocessor, but on reducing the customer's total design cost. They offered development software on a timeshare computer, the "EXORciser" debugging system, onsite training and field application engineer support. Motorola advertisement emphasizing their complete set of peripheral chips and development tools. This shorten the customers product design cycle. Both Intel and Motorola had initially announced a $360 price for a single microprocessor. MC6800 microprocessor price was $360. The MC6850 asynchronous communications interface adaptor (ACIA) was slated for first quarter 1975 introduction. "Shima implemented the 8080 in about a year and the new device was introduced in April 1974 for $360." The actual price for production quantities was much less. Motorola offered a design kit containing the 6800 with six support chips for $300. "Distributors are being stocked with the M6800 family, and the division is also offering an introductory kit that includes the family's six initial parts, plus applications and programming manuals, for $300." Peddle, who would accompany the salespeople on customer visits, found that customers were put off by the high cost of the microprocessor chips. At the same time, these visits invariably resulted in the engineers he presented to producing lists of required instructions that were much smaller than "all these fancy instructions" that had been included in the 6800. Peddle and other team members started outlining the design of an improved feature, reduced size microprocessor. At that time, Motorola's new semiconductor fabrication facility in Austin, Texas, was having difficulty producing MOS chips, and mid-1974 was the beginning of a year-long recession in the semiconductor industry. Also, many of the
Mesa, Arizona Mesa ( ) is a city in Maricopa County Maricopa County is located in the south-central part of the U.S. state In the United States The United States of America (USA), commonly known as the United States (U.S. or US), or America, ...

Mesa, Arizona
employees were displeased with the upcoming relocation to
Austin, Texas Austin (, ) is the capital city A capital or capital city is the municipality holding primary status in a country, Constituent state, state, province, Department (country subdivision), department, or other administrative region, usually ...

Austin, Texas
. Motorola's Semiconductor Products Division management was overwhelmed with problems and showed no interest in Peddle's low-cost microprocessor proposal. Eventually Peddle was given an official letter telling him to stop working on the system. Peddle responded to the order by informing Motorola that the letter represented an official declaration of "project abandonment", and as such, the intellectual property he had developed to that point was now his. In a November 1975 interview, Motorola's Chairman, Robert Galvin, ultimately agreed that Peddle's concept was a good one and that the division missed an opportunity, "We did not choose the right leaders in the Semiconductor Products division." The division was reorganized and the management replaced. The new group vice-president John Welty said, "The semiconductor sales organization lost its sensitivity to customer needs and couldn't make speedy decisions." Summary: Semiconductor Products split into two parts, integrated circuits and discrete components. Semiconductor losses for the last four quarters exceeded $30 million. The sales organization lost its sensitivity to customer needs, "delays in responding to price cuts meant that customers bought elsewhere." Technical problems plagued IC production. The troubles are "not in design, but in chip and die yields." Problems have been solved. The MC6800 microprocessor "arrived in November 1974."


Moving to MOS Technology

Peddle began looking outside Motorola for a source of funding for this new project. He initially approached
Mostek Mostek was an integrated circuit manufacturer, founded in 1969 by L. J. Sevin, Louay E. Sharif, Richard L. Petritz and other ex-employees of Texas Instruments. Initially their products were manufactured in Worcester, Massachusetts, however by 19 ...
CEO L. J. Sevin, but he declined. Sevin later admitted this was because he was afraid Motorola would sue them. While Peddle was visiting
Ford Motor Company Ford Motor Company (commonly known as Ford) is an American multinational Multinational may refer to: * Multinational corporation, a corporate organization operating in multiple countries * Multinational force, a military body from multiple c ...
on one of his sales trips, Bob Johnson, later head of Ford's engine automation division, mentioned that their former colleague John Paivinen had moved to
General Instrument General Instrument (GI) was an American electronics Electronics comprises the physics, engineering, technology and applications that deal with the emission, flow and control of electrons in vacuum and matter. It uses active devices to control e ...
and taught himself semiconductor design. Paivinen then formed
MOS Technology The metal–oxide–semiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET), also known as the metal–oxide–silicon transistor (MOS transistor, or MOS), is a type of insulated-gate field-effect transistor The field-effect trans ...
in
Valley Forge, Pennsylvania The Village of Valley Forge is an unincorporated settlement located on the west side of Valley Forge National Historical Park at the confluence of Valley Creek and the Schuylkill River The Schuylkill River ( , ) is a river A river is a ...
in 1969 with two other executives from General Instrument, Mort Jaffe and Don McLaughlin.
Allen-Bradley File:Allen Bradley PLC.jpeg, 200px, Allen Bradley Programmable Controller with programmer Allen-Bradley is the brand-name of a line of factory automation equipment, today owned by Rockwell Automation. The company, with revenues of approximately ...

Allen-Bradley
, a supplier of electronic components and industrial controls, acquired a majority interest in 1970. The company designed and fabricated custom ICs for customers and had developed a line of calculator chips. After the Mostek efforts fell through, Peddle approached Paivinen, who "immediately got it". On 19 August 1974, Chuck Peddle, Bill Mensch, Rod Orgill, Harry Bawcom, Ray Hirt, Terry Holdt, and Wil Mathys left Motorola to join MOS. Mike Janes joined later. Of the seventeen chip designers and layout people on the 6800 team, eight left. The goal of the team was to design and produce a low-cost microprocessor for embedded applications and to target as wide as possible a customer base. This would be possible only if the microprocessor was low cost, and the team set the price goal at $5 in volume. Mensch later stated the goal was not the processor price itself, but to create a set of chips that could sell at $20 to compete with the recently-introduced
Intel 4040 The Intel 4040 microprocessor A microprocessor is a computer processor where the data processing logic and control is included on a single integrated circuit, or a small number of integrated circuits. The microprocessor contains the arithme ...
that sold for $29 in a similar complete chipset. Chips are produced by printing multiple copies of the chip design on the surface of a
"wafer"
, a thin disk of highly pure silicon. Smaller chips can be printed in greater numbers on the same wafer, decreasing their relative price. Additionally, wafers always include some number of tiny physical defects that are scattered across the surface. Any chip printed in that location will fail and has to be discarded. Smaller chips mean any single copy is less likely to be printed on a defect. For both of these reasons, the cost of the final product is strongly dependent on the size of the chip design. The original 6800 chips were intended to be , but layout was completed at , or an area of 29.0 mm2. For the new design, the cost goal demanded a size goal of , or an area of 16.6 mm2. Several new techniques would be needed to hit this goal.


Moving to NMOS

There were two significant advances that arrived in the market just as the 6502 was being designed that provided significant cost reductions. The first was the move to depletion-load NMOS. The 6800 used an early NMOS process that required three supply voltages, but one of the chip's features was an onboard voltage doubler that allowed a single +5 V supply be used for +5, −5 and +12 V internally, as opposed to other chips of the era like the
Intel 8080 The Intel 8080 (''"eighty-eighty"'') is the second 8-bit microprocessor designed and manufactured by Intel. It first appeared in April 1974 and is an extended and enhanced variant of the earlier Intel 8008, 8008 design, although without binary ...
that required three separate supply pins. While this feature reduced the complexity of the power supply and pin layout, it still required separate power rails to the various gates on the chip, driving up complexity and size. By moving to the new depletion-load design, a single +5 V supply was all that was needed, eliminating all of this complexity. A further practical advantage was that the clock signal for earlier CPUs had to be strong enough to survive all the dissipation as it traveled through the circuits, which almost always required a separate external chip that could supply a strong enough signal. With the reduced power requirements of NMOS, the clock could be moved onto the chip, simplifying the overall computer design. These changes greatly reduced complexity and the cost of implementing a complete system. Another change that was taking place was the introduction of projection masking. Previously, chips were patterned onto the surface of the wafer by placing a
mask A mask is an object normally worn on the face, typically for protection, disguise, performance, or entertainment. Masks have been used since antiquity for both ceremony, ceremonial and pragmatism, practical purposes, as well as in the perfor ...
on the surface of the wafer and then shining a bright light on it. The masks often picked up tiny bits of dirt or
photoresist A photoresist (also known simply as a resist) is a light-sensitive material used in several processes, such as photolithography and photoengraving, to form a patterned coating on a surface. This process is crucial in the Electronics industry, elect ...
as they were lifted off the chip, causing flaws in those locations on any subsequent masking. With complex designs like CPUs, 5 or 6 such masking steps would be used, and the chance that at least one of these steps would introduce a flaw was very high. In most cases, 90% of such designs were flawed, resulting in a 10% yield. The price of the working examples had to cover the production cost of the 90% that were thrown away. In 1973, Perkin-Elmer introduced the Micralign system, which projected an image of the mask on the wafer instead of requiring direct contact. Masks no longer picked up dirt from the wafers and lasted on the order of 100,000 uses rather than 10. This eliminated step-to-step failures and the high flaw rates formerly seen on complex designs. Yields on CPUs immediately jumped from 10% to 60 or 70%. This meant the price of the CPU declined roughly the same amount and the microprocessor suddenly became a commodity device. MOS Technology's existing fabrication lines were based on the older PMOS technology, they had not yet begun to work with NMOS when the team arrived. Paivinen promised to have an NMOS line up and running in time to begin the production of the new CPU. He delivered on the promise, the new line was ready by June 1975.


Design notes

Chuck Peddle, Rod Orgill, and Wil Mathys designed the initial architecture of the new processors. A September 1975 article in EDN magazine gives this summary of the design:
The MOS Technology 650X family represents a conscious attempt of eight former Motorola employees who worked on the development of the 6800 system to put out a part that would replace and outperform the 6800, yet undersell it. With the benefit of hindsight gained on the 6800 project, the MOS Technology team headed by Chuck Peddle, made the following architectural changes in the Motorola CPU…
The main change in terms of chip size was the elimination of the tri-state drivers from the address bus outputs. This had been included in the 6800 to allow it to work with other chips in
direct memory access Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system memory Memory is the faculty of the brain A brain is an organ (biology), organ that serves as the center of the nervous ...
(DMA) and co-processing roles, at the cost of significant die space. In practice, using such a system required the other devices to be similarly complex, and designers instead tended to use off-chip systems to coordinate such access. The 6502 simply removed this feature, in keeping with its design as an inexpensive controller being used for specific tasks and communicating with simple devices. Peddle suggested that anyone that actually required this style of access could implement it with a single 74158. The next major difference was to simplify the registers. To start with, one of the two accumulators was removed. General-purpose registers like accumulators have to be accessed by many parts of the instruction decoder, and thus require significant amounts of wiring to move data to and from their storage. Two accumulators makes many coding tasks easier, but costs the chip design itself significant complexity. Further savings were made by reducing the
stack register A stack register is a computer central processor register A processor register is a quickly accessible location available to a computer's processor. Registers usually consist of a small amount of fast storage, although some registers have speci ...
from 16 to 8 bits, meaning that the stack could only be 256 bytes long, which was enough for its intended role as a microcontroller. The 16-bit IX
index register An index register in a computer's CPU A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuit File:PExdcr01CJC.jpg, 200px, A circuit built on a printed circuit board (PCB ...
was split in two, becoming X and Y. More importantly, the style of access changed; in the 6800, IX held a 16-bit address, which was offset by an 8-bit number supplied with the instruction, the two were added to produce the final address. In the 6502 (and most other designs), the 16-bit base address was stored in the instruction, and the X or Y was added to it. Finally, the instruction set was simplified, freeing up room in the decoder and control logic. Of the original 72 instructions in the 6800, 56 were left. Among those removed were any instruction that moved data between the 6800's two accumulators, as well as a number of branch instructions inspired by the
PDP-11 The PDP-11 is a series of 16-bit 16-bit microcomputers are computers in which 16-bit microprocessors were the norm. A 16-bit register can store 216 different values. The range (computer programming), range of integer values that can be stored i ...
, like the ability to directly compare two numeric values. The 6502 used a simpler system that handled comparisons by performing math on the accumulator and then examining result flags. The chip's high-level design had to be turned into drawings of transistors and interconnects. At MOS Technology, the "layout" was a very manual process done with color pencils and . The layout consisted of thousands of polygon shapes on six different drawings; one for each layer of the fabrication process. Given the size limits, the entire chip design had to be constantly considered. Mensch and Paivinen worked on the instruction decoder while Mensch, Peddle and Orgill worked on the ALU and registers. A further advance, developed at a party, was a way to share some of the internal wiring to allow the ALU to be reduced in size. In spite of their best efforts, the final design ended up being 5 mils too wide. The first 6502 chips were , or an area of 19.8 mm2. The rotate right instruction (ROR) did not work in the first silicon, so the instruction was temporarily omitted from the published documents, but the next iteration of the design shrank the chip and corrected the rotate right instruction, which was then included in revised documentation.The August 1975 datasheet had 55 instructions with no ROR, the May 1976 datasheet had the ROR and 56 instructions. :File:MCS650x Instruction Set.jpg


Introducing the 6501 and 6502

MOS would introduce two microprocessors based on the same underlying design: the 6501 would plug into the same socket as the Motorola 6800, while the 6502 re-arranged the pinout to support an on-chip clock oscillator. Both would work with other support chips designed for the 6800. They would not run 6800 software because they had a different instruction set, different registers, and mostly different addressing modes. Rod Orgill was responsible for the 6501 design; he had assisted John Buchanan at Motorola on the 6800. Bill Mensch did the 6502; he was the designer of the 6820 Peripheral Interface Adapter (PIA) at Motorola. Harry Bawcom, Mike Janes and Sydney-Anne Holt helped with the layout. MOS Technology's microprocessor introduction was different from the traditional months-long product launch. The first run of a new integrated circuit is normally used for internal testing and shared with select customers as "engineering samples". These chips often have a minor design defect or two that will be corrected before production begins. Chuck Peddle's goal was to sell the first run 6501 and 6502 chips to the attendees at the Wescon trade show in San Francisco beginning on September 16, 1975. Peddle was a very effective spokesman and the MOS Technology microprocessors were extensively covered in the trade press. One of the earliest was a full-page story on the MCS6501 and MCS6502 microprocessors in the July 24, 1975 issue of ''Electronics'' magazine. The article covers the 6501 and 6502 plus the 28 pin versions that would only address 4K of memory. It also covered future devices such as "a design that Peddle calls a pseudo 16". Stories also ran in ''
EE Times ''EE Times'' (''Electronic Engineering Times'') is an electronics industry The electronics industry is the economic sector that produces electronic devices. It emerged in the 20th century and is today one of the largest global industries. Contem ...
'' (August 24, 1975), ''EDN'' (September 20, 1975), ''Electronic News'' (November 3, 1975), ''Byte'' (November 1975) Comparison of the 6502 and the 6800 microprocessors. Author visited MOS Technology in August 1975. and ''Microcomputer Digest'' (November 1975). Advertisements for the 6501 appeared in several publications the first week of August 1975. The 6501 would be for sale at Wescon for $20 each. In September 1975, the advertisements included both the 6501 and the 6502 microprocessors. The 6502 would cost only $25 (). When MOS Technology arrived at Wescon, they found that exhibitors were not permitted to sell anything on the show floor. They rented the MacArthur Suite at the and directed customers there to purchase the processors. At the suite, the processors were stored in large jars to imply that the chips were in production and readily available. The customers did not know the bottom half of each jar contained non-functional chips. The chips were $20 and $25 while the documentation package was an additional $10. Users were encouraged to make
photocopies A photocopier (also known as a copier or copy machine, and formerly a Genericised trade mark, Xerox Machine) is a machine that makes copies of documents and other visual images onto paper or plastic film quickly and cheaply. Most modern photocopi ...
of the documents, an inexpensive way for MOS Technology to distribute product information. The preliminary data sheets listed just 55 instructions excluding the Rotate Right (ROR) instruction which did not work correctly on these early chips. The reviews in ''Byte'' and ''EDN'' noted the lack of the ROR instruction. The next revision of the layout fixed this problem and the May 1976 datasheet listed 56 instructions. Peddle wanted every interested engineer and hobbyist to have access to the chips and documentation; other semiconductor companies only wanted to deal with "serious" customers. For example,
Signetics Signetics was an American electronics manufacturer specifically established to make integrated circuit An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) is a set of electronic circui ...
was introducing the 2650 microprocessor and its advertisements asked readers to write for information on their company letterhead.


Motorola lawsuit

The 6501/6502 introduction in print and at Wescon was an enormous success. The downside was that the extensive press coverage got Motorola's attention. In October 1975, Motorola reduced the price of a single 6800 microprocessor from $175 to $69. The $300 system design kit was reduced to $150 and it now came with a printed circuit board. The quantity one price for the MC6800 was reduced from $175 to $69. The previous price for 50 to 99 units was $125. On November 3, 1975, Motorola sought an injunction in Federal Court to stop MOS Technology from making and selling microprocessor products. They also filed a lawsuit claiming patent infringement and misappropriation of trade secrets. Motorola claimed that seven former employees joined MOS Technology to create that company's microprocessor products."Motorola said last week it would seek an immediate injunction to stop MOS Technology Inc., Norristown, Pa., from making and selling microprocessor products, including its MCS6500." (This issue was published on November 7.) Motorola was a billion-dollar company with a plausible case and lawyers. On October 30, 1974, Motorola had filed numerous patent applications on the microprocessor family and was granted twenty-five patents. The first was in June 1976 and the second was to Bill Mensch on July 6, 1976, for the 6820 PIA chip layout. These patents covered the 6800 bus and how the peripheral chips interfaced with the microprocessor. Motorola began making transistors in 1950 and had a portfolio of semiconductor patents. Allen-Bradley decided not to fight this case and sold their interest in MOS Technology back to the founders. Four of the former Motorola engineers were named in the suit: Chuck Peddle, Will Mathys, Bill Mensch and Rod Orgill. All were named inventors in the 6800 patent applications. During the discovery process, Motorola found that one engineer, Mike Janes, had ignored Peddle's instructions and brought his 6800 design documents to MOS Technology. In March 1976, the now independent MOS Technology was running out of money and had to settle the case. They agreed to drop the 6501 processor, pay Motorola $200,000 and return the documents that Motorola contended were confidential. Both companies agreed to cross-license microprocessor patents. "MOS Technology Inc. of Norristown, Pa. has agreed to withdraw its MCS6501 microprocessor from the market and to pay Motorola Inc. $200000 ..." "MOS Technology and eight former Motorola employees have given back, under court order documents that Motorola contends are confidential." "…both companies have agreed to a cross license relating to patents in the microprocessor field." That May, Motorola dropped the price of a single 6800 microprocessor to $35. By November,
Commodore Commodore may refer to: Ranks * Commodore (rank) Commodore is a senior naval rank used in many navies which is equivalent to brigadier and air commodore that is superior to a navy captain, but below a rear admiral. It is either regarded as ...
had acquired MOS Technology." Commodore International … is buying MOS Technology (Norristown, PA). This saves the six-year-old semiconductor house from impending disaster."


Computers and games

With legal troubles behind them, MOS was still left with the problem of getting developers to try their processor, prompting Chuck Peddle to design the MDT-650 ("microcomputer development terminal")
single-board computer A single-board computer (SBC) is a complete computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform generic sets of operations known as ...
. Another group inside the company designed the
KIM-1 The KIM-1, short for ''Keyboard Input Monitor'', is a small MOS Technology 6502, 6502-based single-board computer developed and produced by MOS Technology, MOS Technology, Inc. and launched in 1976. It was very successful in that period, due to ...
, which was sold semi-complete and could be turned into a usable system with the addition of a 3rd party
computer terminal A computer terminal is an electronic or electromechanical In engineering Engineering is the use of scientific principles to design and build machines, structures, and other items, including bridges, tunnels, roads, vehicles, and b ...
and
compact cassette The Compact Cassette or Musicassette (MC), also commonly called the tape cassette, cassette tape, audio cassette, or simply tape or cassette, is an analog magnetic tape Magnetic tape is a medium for , made of a thin, magnetizable coating ...

compact cassette
drive. Much to their amazement, the KIM-1 sold well to hobbyists and tinkerers, as well as to the engineers to which it had been targeted. The related Rockwell
AIM 65 The Rockwell AIM-65 computer was a introduced in 1978 based on the microprocessor. The AIM-65 was essentially an expanded computer. Available software included a line-oriented , interpreter, , , , and development system. Available hardwar ...
control/training/development system also did well. The software in the AIM 65 was based on that in the MDT. Another roughly similar product was the Synertek
SYM-1 The SYM-1 was a single board "trainer" computer produced by Synertek Synertek, Inc. was an American American(s) may refer to: * American, something of, from, or related to the United States of America, commonly known as the United States ...
. One of the first "public" uses for the design was the
Apple I The Apple Computer 1, originally released as the Apple Computer and known later as the Apple I, or Apple-1, is a desktop computer A desktop computer is a personal computer A personal computer (PC) is a multi-purpose computer whose siz ...

Apple I
microcomputer A microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit (CPU). It includes a microprocessor, Computer memory, memory and minimal input/output (I/O) circuitry mounted on a single printed ci ...
, introduced in 1976. The 6502 was next used in the
Commodore PET The Commodore PET is a line of personal computer A personal computer (PC) is a multi-purpose computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...

Commodore PET
and the
Apple II The Apple II (stylized as apple ] '') is an 8-bit home computer">8-bit.html" ;"title="'') is an 8-bit">'') is an 8-bit home computer and one of the world's first highly successful mass-produced microcomputer products. It was designed primari ...
, both released in 1977. It was later used in the
Atari 8-bit family The Atari 8-bit family is a series of 8-bit home computers introduced by Atari, Inc. in 1979 as the Atari 400 and Atari 800 and manufactured until 1992. All of the machines in the family are technically similar and differ primarily in packaging. T ...
and
Acorn Atom The Acorn Atom is a home computer Home computers were a class of s that entered the market in 1977 and became common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were int ...

Acorn Atom
home computers, the
BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputer A microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit (CPU). It includes a micr ...
,
Commodore VIC-20 The Commodore VIC-20 (known as the VC-20 in Germany and the VIC-1001 in Japan) is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bit ...
and other designs both for home computers and business, such as
Ohio Scientific Ohio Scientific Inc. (also known as Ohio Scientific Instruments) was an Ohio-based computer company that built and marketed microcomputers from 1975 to 1981. Their best-known products were the Challenger series of microcomputers and Superboard si ...
and
Oric Oric was the name used by UK-based Tangerine Computer Systems Tangerine Computer SystemsThe choice of the company's name, Tangerine, was inspired by the success of the-then already famous (in the computer business world) Apple Computer. ...

Oric
. The 6510, a direct successor of the 6502 with a digital I/O port and a tri-state address bus, was the
CPU A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuit File:PExdcr01CJC.jpg, 200px, A circuit built on a printed circuit board (PCB). An electronic circuit is composed of ...

CPU
utilized in the best-selling
Commodore 64 The Commodore 64, also known as the C64 or the CBM 64, is an 8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation ...

Commodore 64
home computer. 6502 or 6502-variant CPUs were used in all of Commodore's
floppy disk A floppy disk or floppy diskette (sometimes casually referred to as a floppy or diskette) is a type of disk storage Disk storage (also sometimes called drive storage) is a general category of storage mechanisms where data is recorded by vario ...

floppy disk
drives for all of their 8-bit computers, from the PET line (some of which had two 6502-based CPUs) through the Commodore 128D, including the Commodore 64, and in all of Atari's disk drives for all of their 8-bit computer line, from the 400/800 through the XEGS. Another important use of the 6500 family was in video games. The first to make use of the processor design was the Atari VCS, later renamed the
Atari 2600 The Atari 2600, originally branded as the Atari Video Computer System (Atari VCS) until November 1982, is a home video game console A home video game console is a video game console that is designed to be connected to a display device, such a ...

Atari 2600
. The VCS used a variant of the 6502 called the 6507, which had fewer pins and, as a result, could address only 8  KB of memory. Millions of the Atari consoles would be sold, each with a MOS processor. Another significant use was by the . The 6502 used in the NES was a
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 (the first source). It is common for engineers and purchasers to avoid components that are only ava ...
version by
Ricoh is a Japanese Multinational corporation, multinational imaging and electronics company (law), company. It was founded by the now-defunct commercial division of the Riken, Institute of Physical and Chemical Research (Riken) known as the ''Riken ...
, a partial
system-on-a-chip A system on a chip (SoC; or This article uses the convention that SoC is pronounced . Therefore, it uses the convention "an" for the indefinite article Indefinite may refer to: * the opposite of definite in grammar ** indefinite article ...
, that lacked the
binary-coded decimal In computing and electronics, electronic systems, binary-coded decimal (BCD) is a class of Binary numeral system, binary encodings of decimal numbers where each numerical digit, digit is represented by a fixed number of bits, usually four or ei ...
mode but added 22 memory-mapped registers and on-die hardware for sound generation, joypad reading, and sprite list DMA. Called
2A03 The Ricoh 2A03 or RP2A03 (NTSC The National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12-19, with Some supplementary references cited in the Reports, and th ...
in
NTSC The National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12-19, with Some supplementary references cited in the Reports, and the Petition for adoption of transm ...
consoles and
2A07 The Ricoh 2A03 or RP2A03 (NTSC The National Television System Committee (NTSC)National Television System Committee (1951–1953), Report and Reports of Panel No. 11, 11-A, 12-19, with Some supplementary references cited in the Reports, and th ...
in
PAL PAL 300px, upright=1.2, Analog television encoding systems by nation; SECAM.html"_;"title="NTSC_(green),_SECAM">NTSC_(green),_SECAM_(orange),_and_PAL_(blue). Phase_Alternating_Line_(PAL)_is_a_colour_encoding_system_for_Analog_television.html" ...
consoles (the difference being the memory divider ratio and a lookup table for audio sample rates), this processor was produced exclusively for
Nintendo is a Japanese Multinational corporation, multinational consumer electronics and video game company headquartered in Kyoto, Japan. The company was founded in 1889 as by craftsman Fusajiro Yamauchi and originally produced handmade playing ca ...

Nintendo
. The
Atari Lynx The Atari Lynx is a 8/16-bit handheld game console that was released by Atari Corporation in September 1989 in North America, and in Europe and Japan in 1990. It was the world's first handheld electronic game with a color LCD. It was also not ...

Atari Lynx
used a 4 MHz version of the chip, the 65SC02. In the 1980s, a popular electronics magazine Elektor/Elektuur used the processor in its microprocessor development board Junior Computer. File:Acorn atom zx1.jpg,
Acorn Atom The Acorn Atom is a home computer Home computers were a class of s that entered the market in 1977 and became common during the 1980s. They were marketed to consumers as affordable and accessible computers that, for the first time, were int ...

Acorn Atom
File:Acorn Electron 4x3.jpg,
Acorn Electron The Acorn Electron is a budget version of the BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputer A microcomputer is a small, relatively inexpensive computer A computer is a ...

Acorn Electron
File:Apple 1 Woz 1976 at CHM.agr.jpg,
Apple I The Apple Computer 1, originally released as the Apple Computer and known later as the Apple I, or Apple-1, is a desktop computer A desktop computer is a personal computer A personal computer (PC) is a multi-purpose computer whose siz ...

Apple I
File:Apple II tranparent 800.png,
Apple II The Apple II (stylized as apple ][) is an and one of the world's first highly successful mass-produced products. It was designed primarily by ; oversaw the development of Apple II's foam-molded plastic case and developed the . It was in ...

Apple II
File:Apple iieb.jpg, Apple IIe File:Atari-2600-Console.jpg,
Atari 2600 The Atari 2600, originally branded as the Atari Video Computer System (Atari VCS) until November 1982, is a home video game console A home video game console is a video game console that is designed to be connected to a display device, such a ...

Atari 2600
File:Atari-5200-4-Port-wController-L.jpg,
Atari 5200 The Atari 5200 SuperSystem or simply Atari 5200 is a home video game console A home video game console is a video game console that is designed to be connected to a display device, such as a television, and an external power source as to pl ...

Atari 5200
File:Atari-7800-Console-Set.jpg,
Atari 7800 The Atari 7800 ProSystem, or simply the Atari 7800, is a home video game console A home video game console is a video game console that is designed to be connected to a display device, such as a television, and an external power source as t ...

Atari 7800
File:Atari-800-Computer-FL.jpg,
Atari 800 The Atari 800 is a home computer manufactured by Atari Atari () is a brand name owned by several entities since its inception in 1972, currently by Atari Interactive Atari Interactive is a name used by several separate groups and corporat ...
File:Atari-Lynx-I-Handheld.jpg,
Atari Lynx The Atari Lynx is a 8/16-bit handheld game console that was released by Atari Corporation in September 1989 in North America, and in Europe and Japan in 1990. It was the world's first handheld electronic game with a color LCD. It was also not ...

Atari Lynx
File:Acorn BBC Master Series.jpg,
BBC Master The BBC Master is a home computer released by Acorn Computers Acorn Computers Ltd. was a British computer company established in Cambridge, England, in 1978. The company produced a number of computers which were especially popular in the United ...
File:BBC Micro Front Restored.jpg,
BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputer A microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit (CPU). It includes a micr ...
File:Commodore 2001 Series-IMG 0448b.jpg,
Commodore PET The Commodore PET is a line of personal computer A personal computer (PC) is a multi-purpose computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...

Commodore PET
File:Commodore-VIC-20-FL.jpg,
Commodore VIC-20 The Commodore VIC-20 (known as the VC-20 in Germany and the VIC-1001 in Japan) is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bit ...
File:C64c system.jpg,
Commodore 64 The Commodore 64, also known as the C64 or the CBM 64, is an 8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation ...

Commodore 64
File:Commodore-128.jpg,
Commodore 128 The Commodore 128, also known as the C128, C-128, C= 128,The "C=" represents the graphical part of the logo. is the last 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, d ...

Commodore 128
File:Nintendo-Famicom-Console-Set-FL.jpg, File:NES-Console-Set.jpg,
Nintendo Entertainment System The Nintendo Entertainment System (NES) is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit centr ...

Nintendo Entertainment System
File:OSI Challenger 4P.jpg, Ohio Scientific Challenger 4P File:Orao-IMG 7278.jpg, File:Oric1.jpg,
Oric-1 Oric was the name used by UK-based Tangerine Computer Systems Tangerine Computer SystemsThe choice of the company's name, Tangerine, was inspired by the success of the-then already famous (in the computer business world) Apple Computer. ...
File:Oric Atmos 01a.jpg,
Oric Atmos Oric was the name used by UK-based Tangerine Computer Systems for a series of 6502-based home computers sold in the 1980s, primarily in Europe. With the success of the ZX Spectrum from Sinclair Research, Tangerine's backers suggested a home ...
File:Tamagotchi 0124 ubt.jpeg, Tamagotchi digital pet File:TurboGrafx16-Console-Set.jpg,
TurboGrafx-16 The TurboGrafx-16, known as the outside North America, is a fourth-generation home video game console A home video game console is a video game console that is designed to be connected to a display device, such as a television, and an e ...

TurboGrafx-16


Technical description

The 6502 is a
little-endian In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and sof ...
8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation of computer systems. Some definitions of architecture define it as descr ...
processor with a
16-bit 16-bit microcomputers are computers in which 16-bit microprocessors were the norm. A 16-bit register can store 216 different values. The range (computer programming), range of integer values that can be stored in 16 bits depends on the Integer ( ...
address bus In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation of computer systems. The architecture of a system refers to its structur ...
. The original versions were fabricated using an process technology chip with an die size of (advertised as ), for a total area of 16.6 mm2. The internal logic runs at the same speed as the external clock rate, but despite the low clock speeds (typically in the neighborhood of 1 to 2 
MHz The hertz (symbol: Hz) is the derived unit of frequency Frequency is the number of occurrences of a repeating event per unit of time. It is also referred to as temporal frequency, which emphasizes the contrast to spatial frequency and an ...
), the 6502's performance was competitive with other contemporary CPUs using significantly faster clocks. This is partly due to a simple state machine implemented by combinational (clockless) logic to a greater extent than in many other designs; the two-phase clock (supplying two synchronizations per cycle) could thereby control the machine cycle directly. Typical instructions might take half as many cycles to complete on the 6502 as on contemporary designs. Like most simple CPUs of the era, the dynamic NMOS 6502 chip is not sequenced by a
microcode In processor design Processor design is a subfield of computer engineering and electronics engineering (fabrication) that deals with creating a processor (computing), processor, a key component of computer hardware. The design process involves c ...
ROM but uses a
PLA PLA may refer to: Organizations Politics and military * People's Liberation Army The People's Liberation Army (PLA) is the regular army, regular armed forces of the China, People's Republic of China (PRC) and the armed wing of the PRC's foun ...
(which occupied about 15% of the chip area) for instruction decoding and sequencing. As in most 8-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 fraction varied strongly among chip versions). This was critical at a time when affordable memory had access times in the range . Because the chip only accessed memory during certain parts of the clock cycle, and those cycles were indicated by the PHI2-low clock-out pin, other chips in a system could access memory during those times when the 6502 was off the bus. This was sometimes known as "hidden access". This technique was widely used by computer systems; they would use memory capable of access at 2 MHz, and then run the CPU at 1 MHz. This guaranteed that the CPU and video hardware could interleave their accesses, with a total performance matching that of the memory device. When faster memories became available in the 1980s, newer machines could run at higher clock rates, like the 2 MHz CPU in the
BBC Micro The British Broadcasting Corporation Microcomputer System, or BBC Micro, is a series of microcomputer A microcomputer is a small, relatively inexpensive computer with a microprocessor as its central processing unit (CPU). It includes a micr ...
, and still use the bus sharing techniques.


Registers

Like its precursor, the 6800, the 6502 has very few registers. The 6502's registers include one 8-bit accumulator register (A), two 8-bit
index register An index register in a computer's CPU A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuit File:PExdcr01CJC.jpg, 200px, A circuit built on a printed circuit board (PCB ...
s (X and Y), 7 processor status flag bits (P; from bit 7 to bit 0 these are the negative (N), overflow (V), ''reserved'', break (B), decimal (D), interrupt disable (I), zero (Z) and carry (C) flag), an 8-bit
stack pointer In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of com ...
(S), and a 16-bit
program counter The program counter (PC), commonly called the instruction pointer (IP) in Intel Intel Corporation is an American multinational corporation A multinational company (MNC) is a corporate A corporation is an organization—usually a gr ...
(PC). This compares to a typical design of the same era, the
Z80 The Z80 is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit central processing unit, CPU and arithmeti ...

Z80
, which has eight general-purpose 8-bit registers, which can be combined into four 16-bit ones. The Z80 also had a complete set of alternate registers, which made a total of sixteen general-purpose registers. In order to make up somewhat for the lack of registers, the 6502 included a ''zero-page'' addressing mode that uses one address byte in the instruction instead of the two needed to address the full 64 KB of memory. This provides fast access to the first 256 bytes of RAM by using shorter instructions. Chuck Peddle has said in interviews that the specific intention was to allow these first 256 bytes of RAM to be used like registers. The stack address space is
hardwired Hardwire or hardwired may refer to: *Electrical wiring *Hardwired control unit, a part of a computer's central processing unit *In computer programming, a kludge to temporarily or quickly fix a problem *Wired communication In arts and entertainmen ...
to memory page $01, i.e. the address range $0100$01FF (256511). Software access to the stack is done via four implied addressing mode instructions, whose functions are to push or pop (pull) the accumulator or the processor status register. The same stack is also used for subroutine calls via the JSR (jump to subroutine) and RTS (return from subroutine) instructions and for interrupt handling.


Addressing

The chip uses the index and stack registers effectively with several addressing modes, including a fast "direct page" or "zero page" mode, similar to that found on the PDP-8, that accesses memory locations from addresses 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 uses the zero page much as code for other processors would use registers. On some 6502-based microcomputers with an operating system, the operating system uses most of zero page, leaving only a handful of locations for the user. Addressing modes also include ''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 is a general-purpose mode. Branch instructions use 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 uses the accumulator as an effective address and does not need any operand data. Immediate mode uses an 8-bit literal (computer programming), literal operand.


Indirect addressing

The indirect modes are useful for Array data type, array processing and other looping. With the 5/6 cycle "(indirect),y" mode, the 8-bit Y register is added to a 16-bit base address read from zero page, which is located by a single byte following the opcode. The Y register is therefore an ''index'' register in the sense that it is used to hold an actual ''index'' (as opposed to the X register in the 6800, where a base address was directly stored and to which an immediate offset could be added). Incrementing the index register to walk the array byte-wise takes only two additional cycles. With the less frequently used "(indirect,x)" mode the effective address for the operation is 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 acts as a set of up to 128 additional (though very slow) address registers. The 6502 is capable of performing addition and subtraction in binary or
binary-coded decimal In computing and electronics, electronic systems, binary-coded decimal (BCD) is a class of Binary numeral system, binary encodings of decimal numbers where each numerical digit, digit is represented by a fixed number of bits, usually four or ei ...
. Placing the CPU into BCD mode with the SED (set D flag) instruction results in decimal arithmetic, in which $99 + $01 would result in $00 and the carry (C) flag being set. In binary mode (CLD, clear D flag), the same operation would result in $9A and the carry flag being cleared. Other than Atari BASIC, BCD mode was seldom used in home-computer applications. See the wikibooks:Computer Programming/Hello world#Accumulator + index register machine: MOS Technology 6502, CBM KERNEL, MOS assembler syntax, Hello world! article for a simple but characteristic example of 6502 assembly language.


Instructions and opcodes

6502 instruction opcode, operation codes (''opcodes'') are 8 bits long and have the general form AAABBBCC, where AAA and CC define the opcode, and BBB defines the addressing mode. For instance, consider the ORA instruction, which performs a bitwise OR on the bits in the accumulator with another value. The instruction opcode is of the form 000bbb01, where bbb may be 010 for an immediate mode value (constant), 001 for zero-page fixed address, 011 for an absolute address, and so on. This pattern is not absolute, and there are a number of exceptions. However, where it does apply, it allows one to easily deconstruct opcode values back to assembly mnemonics for the majority of instructions, handling the edge cases with special-purpose code. Of the 256 possible opcodes available using an 8-bit pattern, the original 6502 uses 151 of them, organized into 56 instructions with (possibly) multiple addressing modes. Depending on the instruction and addressing mode, the opcode may require zero, one or two additional bytes for operands. Hence 6502 machine instructions vary in length from one to three bytes. The operand is stored in the 6502's customary endianness#Atomic element size 8-bit 2, little-endian format. The WDC 65C816, 65C816, the 16-bit
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "see-moss"), also known as complementary-symmetry metal–oxide–semiconductor (COS-MOS), is a type of metal–oxide–semiconductor field-effect transistor The metal–oxide–sem ...
descendant of the 6502, also supports 24-bit addressing, which results in instructions being assembled with three-byte operands, also arranged in little-endian format. The remaining 105 opcodes are undefined. In the original design, instructions where the low-order 4 bits (''nibble'') were 3, 7, B or F were not used, providing room for future expansion. Likewise, the $2x column had only a single entry, LDX #''constant''. The remaining 25 empty slots were distributed. Some of the empty slots were used in the 65C02 to provide both new instructions and variations on existing ones with new addressing modes. The $Fx instructions were initially left free to allow 3rd-party vendors to add their own instructions, but later versions of the 65C02 standardized a set of bit fiddling instructions developed by Rockwell Semiconductor.


Assembly language

A 6502 assembly language statement consists of a three-character instruction mnemonic, followed by any operands. Instructions that do not take a separate operand but target a single register based on the addressing mode combine the target register in the instruction mnemonic, so the assembler uses INX as opposed to INC X to increment the X register.


Instruction table


Detailed behavior

The processor's non-maskable interrupt (NMI) input is Interrupt#Edge-triggered, edge sensitive, which means that the interrupt is triggered by the falling edge of the signal rather than its level. The implication of this feature is that a wired-OR interrupt circuit is not readily supported. However, this also prevents nested NMI interrupts from occurring until the hardware makes the NMI input inactive again, often under control of the NMI interrupt handler. The simultaneous assertion of the NMI and Interrupt request, IRQ (maskable) hardware interrupt lines causes IRQ to be ignored. However, if the IRQ line remains assertion (software development), asserted after the servicing of the NMI, the processor will immediately respond to IRQ, as IRQ is Interrupt#Level-triggered, level sensitive. Thus a sort of built-in interrupt priority was established in the 6502 design. The B flag is set by the 6502's periodically sampling its NMI edge detector's output and its IRQ input. The IRQ signal being driven low is only recognized though if IRQs are allowed by the I flag. If in this way a NMI request or (maskable) IRQ is detected the B flag is set to zero and causes the processor to execute the BRK instruction next instead of executing the next instruction based on the program counter. The BRK instruction then pushes the processor status onto the stack, with the B flag bit set to zero. At the end of its execution the BRK instruction resets the B flag's value to one. This is the only way the B flag can be modified. If an instruction other than the BRK instruction pushes the B flag onto the stack as part of the processor status the B flag always has the value one. A high-to-low transition on the SO input pin will set the processor's overflow status bit. This can be used for fast response to external hardware. For example, a high-speed Polling (computer science), polling device driver can poll the hardware once in only three cycles using a Branch-on-oVerflow-Clear (BVC) instruction that branches to itself until overflow is set by an SO falling transition. The Commodore 1541 and other
Commodore Commodore may refer to: Ranks * Commodore (rank) Commodore is a senior naval rank used in many navies which is equivalent to brigadier and air commodore that is superior to a navy captain, but below a rear admiral. It is either regarded as ...
floppy disk A floppy disk or floppy diskette (sometimes casually referred to as a floppy or diskette) is a type of disk storage Disk storage (also sometimes called drive storage) is a general category of storage mechanisms where data is recorded by vario ...

floppy disk
drives use this technique to detect when the serialization, serializer is ready to transfer another byte of disk data. The system hardware and software design must ensure that an SO will not occur during arithmetic processing and disrupt calculations.


Variations and derivatives

There were numerous variants of the original NMOS 6502.


16-bit derivatives

The Western Design Center designed and currently produces the WDC 65C816, W65C816S processor, a 16-bit, static-core successor to the
65C02 The Western Design Center The Western Design Center (WDC), located in Mesa, Arizona Mesa ( ) is a city in Maricopa County, in the U.S. state of Arizona. It is a suburb about east of Phoenix in the East Valley section of the Phoenix Met ...
, with greatly enhanced features. The W65C816S is a newer variant of the 65C816, which is the core of the Apple IIGS, Apple IIGS computer and is the basis of the Ricoh 5A22 processor that powers the Super Nintendo Entertainment System. The W65C816S incorporates minor improvements over the 65C816 that make the newer chip not an exact hardware-compatible replacement for the earlier one. Among these improvements was conversion to a static core, which makes it possible to stop the clock in either phase without the registers losing data. Available through electronics distributors, as of March 2020, the W65C816S is officially rated for 14 MHz operation. The Western Design Center also designed and produced the WDC 65C816, 65C802, which was a 65C816 core with a 64-kilobyte address space in a 65(C)02 pin-compatible package. The 65C802 could be retrofitted to a 6502 board and would function as a 65C02 on power-up, operating in "emulation mode." As with the 65C816, a two-instruction sequence would switch the 65C802 to "native mode" operation, exposing its 16-bit accumulator and
index register An index register in a computer's CPU A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuit File:PExdcr01CJC.jpg, 200px, A circuit built on a printed circuit board (PCB ...
s, as well as other 65C816 enhanced features. The 65C802 was not widely used; new designs almost always were built around the 65C816, resulting in 65C802 production being discontinued.


Example code

The following 6502 assembly language source code is for a subroutine named TOLOWER, which copies a ASCIIZ, null-terminated string (computer science), character string from one location to another, converting upper-case letter characters to lower-case letters. The string being copied is the "source", and the string into which the converted source is stored is the "destination".


Bugs and quirks

The 6502 had several hardware bug, bugs and quirks, which had to be accounted for when programming it: * The earliest revisions of the 6502, such as those shipped with some
KIM-1 The KIM-1, short for ''Keyboard Input Monitor'', is a small MOS Technology 6502, 6502-based single-board computer developed and produced by MOS Technology, MOS Technology, Inc. and launched in 1976. It was very successful in that period, due to ...
computers, had a severe bug in the circular shift, ROR (rotate right memory or accumulator) instruction. The operation of ROR in these chips is effectively an ASL (arithmetic shift left) instruction that does not affect the carry bit in the status register. MOS left the instruction out of chip documentation entirely because of the defect, promising that ROR would appear on 6502 chips starting in 1976. The vast majority of 6502 chips in existence today do not exhibit this bug. * The NMOS 6502 family has a variety of illegal opcode, undocumented instructions, which vary from one chip manufacturer to another. The 6502 instruction decoding is implemented in a hardwired control, hardwired logic array (similar to a programmable logic array) that is only defined for 151 of the 256 available opcodes. The remaining 105 trigger strange and occasionally hard-to-predict actions, such as crashing the processor, performing two valid instructions consecutively, performing strange mixtures of two instructions, 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 (software interrupt) instructions. Some programmers utilized this feature to extend the 6502 instruction set by providing functionality for the unimplemented opcodes with specially written software intercepted at the BRK instruction's 0xFFFE vector. All of the undefined opcodes have been replaced with NOP (code), NOP instructions in the
65C02 The Western Design Center The Western Design Center (WDC), located in Mesa, Arizona Mesa ( ) is a city in Maricopa County, in the U.S. state of Arizona. It is a suburb about east of Phoenix in the East Valley section of the Phoenix Met ...
, an enhanced
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "see-moss"), also known as complementary-symmetry metal–oxide–semiconductor (COS-MOS), is a type of metal–oxide–semiconductor field-effect transistor The metal–oxide–sem ...
version of the 6502, although with varying byte sizes and execution times. In the WDC 65C816, 65C802/65C816, all 256 opcodes perform defined operations. * The 6502's indirect branch, memory indirect jump instruction, JMP (<address>), is partly broken. If <address> is hexadecimal, hex xxFF (i.e., any word ending in FF), the processor will not jump to the address stored in xxFF and xxFF+1 as expected, but rather the one defined by xxFF and xx00 (for example, JMP ($10FF) would jump to the address stored in 10FF and 1000, instead of the one stored in 10FF and 1100). This defect continued through the entire NMOS line, but was corrected in the CMOS derivatives. * The NMOS 6502 indexed addressing across page boundaries will do an extra read of an invalid address. This characteristic may cause random issues by accessing hardware that acts on a read, such as clearing timer or IRQ flags, sending an I/O handshake, etc. This defect continued through the entire NMOS line, but was corrected in the CMOS derivatives, in which the processor does an extra read of the last instruction byte. * The 6502 read-modify-write instructions perform one read and two write cycles. First, the unmodified data that was read is written back, and then the modified data is written. This characteristic may cause issues by twice accessing hardware that acts on a write. This anomaly continued through the entire NMOS line, but was fixed in the CMOS derivatives, in which the processor will do two reads and one write cycle. Defensive programming practice will generally avoid this problem by not executing read/modify/write instructions on hardware registers. * The N (result negative), V (sign bit overflow) and Z (result zero) status register, status flags are generally meaningless when performing arithmetic operations while the processor is in binary-coded decimal, BCD mode, as these flags reflect the binary, not BCD, result. This limitation was removed in the CMOS derivatives. Therefore, this feature may be used to distinguish a CMOS processor from an NMOS version. * If the 6502 happens to be in BCD mode when a hardware interrupt occurs, it will not revert to binary mode. This characteristic could result in obscure bugs in the interrupt service routine if it fails to clear BCD mode before performing any arithmetic operations. For example, the
Commodore 64 The Commodore 64, also known as the C64 or the CBM 64, is an 8-bit In computer architecture In computer engineering, computer architecture is a set of rules and methods that describe the functionality, organization, and implementation ...

Commodore 64
's KERNAL did not correctly handle this processor characteristic, requiring that interrupt request, IRQs be disabled or re-vectored during BCD math operations. This issue was addressed in the CMOS derivatives as well. * The 6502 instruction set includes BRK (opcode $00), which is technically a software interrupt (similar in spirit to the SWI mnemonic of the
Motorola 6800 The 6800 ("''sixty-eight hundred''") is an 8-bit In computer architecture, 8-bit integer (computer science), integers or other data#Uses of data in computing, data units are those that are 8 bits wide (1 octet). Also, 8-bit central process ...

Motorola 6800
and ARM architecture, ARM processors). BRK is most often used to interrupt program execution and start a machine language monitor for testing and debugging during software development. BRK could also be used to route program execution using a simple jump table (analogous to the manner in which the Intel 8086 and derivatives handle software interrupts by number). However, if a hardware interrupt occurs when the processor is fetching a BRK instruction, the NMOS version of the processor will fail to execute BRK and instead proceed as if only a hardware interrupt had occurred. This fault was corrected in the CMOS implementation of the processor. * When executing JSR (jump to subroutine) and RTS (return from subroutine) instructions, the return address pushed to the stack by JSR is that of the last byte of the JSR operand (that is, the most significant byte of the subroutine address), rather than the address of the following instruction. This is because the actual copy (from
program counter The program counter (PC), commonly called the instruction pointer (IP) in Intel Intel Corporation is an American multinational corporation A multinational company (MNC) is a corporate A corporation is an organization—usually a gr ...
to stack (data structure), stack and then conversely) takes place before the automatic increment of the program counter that occurs at the end of every instruction. This characteristic would go unnoticed unless the code examined the return address in order to retrieve parameters in the code stream (a 6502 programming idiom documented in the ''ProDOS 8 Technical Reference Manual''). It remains a characteristic of 6502 derivatives to this day.


See also

* Comparison of assemblers#6502 assemblers, List of 6502 assemblers * List of home computers by category#MOS Technology 6502, MOS Technology 6502-based home computers * Interrupts in 65xx processors * Transistor count * Apple II accelerators * cc65 – 6502 macro assembler and C compiler


Notes


References


Citations


Bibliography

* * * *
Interview with William Mensch
Stanford and the Silicon Valley Project, October 9, 1995


Further reading

;Datasheets and manuals *
6500 Series Datasheet
'; MOS Technology; 12 pages; 1976. *
6500 Series Hardware Manual
'; 2nd Ed; MOS Technology; 182 pages; 1976. *
6500 Series Programming Manual
'; 2nd Ed; MOS Technology; 262 pages; 1976. ;Books * ''6502 Applications Book''; 1st Ed; Rodnay Zaks; Sybex; 281 pages; 1979; . (archive)
/small> * ''6502 Assembly Language Programming''; 2nd Ed; Lance Leventhal; Osborne/McGraw-Hill; 650 pages; 1986; . (archive)
/small> * ''6502 Assembly Language Subroutines''; 1st Ed; Lance Leventhal and Winthrop Saville; Osborne/McGraw-Hill; 550 pages; 1982; . (archive)
/small> * ''6502 Games''; 1st Ed; Rodnay Zaks; Sybex; 292 pages; 1980; . (archive)
/small> * ''6502 User's Manual''; 1st Ed; Joseph Carr; Reston; 288 pages; 1984; . (archive)
/small> * ''Advanced 6502 Programming''; 1st Ed; Rodnay Zaks; John Wiley & Sons; 292 pages; 1982; . (archive)
/small> * ''Machine Language For Beginners - Personal Computer Machine Language Programming For Atari, VIC, Apple, C64, and PET Computers''; 1st Ed; Richard Mansfield; Compute! Publications; 350 pages; 1983; . (archive)
/small> * ''Programming the 6502''; 4th Ed; Rodnay Zaks; Sybex; 408 pages; 1983; . (archive)
/small> * ''Programming the 65816 - including the 6502,
65C02 The Western Design Center The Western Design Center (WDC), located in Mesa, Arizona Mesa ( ) is a city in Maricopa County, in the U.S. state of Arizona. It is a suburb about east of Phoenix in the East Valley section of the Phoenix Met ...
, 65802''; 1st Ed; David Eyes and Ron Lichty; Prentice Hall; 636 pages; 1986; . (archive)
/small> ;Reference cards * ''6502 Microprocessor Instant Reference Card''; James Lewis; Micro Logic; 2 pages; 1980. (archive)
/small>


External links


6502.org - the 6502 microprocessor resource
– repository

- Commodore archive
650x information
– Concise description, photos of MOS and second source chips; at cpu-collection.de
mdfs.net
– 6502 instruction set * * ;Simulators / Emulators
Online 6502 compatible assembler and emulator, written in JavaScript


– Zophar's Domain
6502 simulator for Windows
– Atari Gaming Headquarters
Visual Transistor-level Simulation of 6502 CPU

MCL65 6502 CPU core - C code
- MicroCore Labs GitHub ;Boards




Build your own KIM-1 training board
- see
KIM-1 The KIM-1, short for ''Keyboard Input Monitor'', is a small MOS Technology 6502, 6502-based single-board computer developed and produced by MOS Technology, MOS Technology, Inc. and launched in 1976. It was very successful in that period, due to ...

6502 home computer



BE6502 single board computer
- based on Ben Eater videos ;FPGA
cpu6502_tc 6502 CPU core - VHDL source code
- OpenCores
ag_6502 6502 CPU core - Verilog source code
- OpenCores
M65C02 65C02 CPU core - Verilog source code
- OpenCores
MCL65 6502 CPU core - Verilog
- MicroCore Labs GitHub {{DEFAULTSORT:Mos Technology 6502 MOS Technology microprocessors 65xx microprocessors Computer-related introductions in 1975 8-bit microprocessors