The 6502 CPU Powered a Whole Generation!

The 8-Bit Guy
26 Mar 202425:16

Summary

TLDRThis episode delves into the revolutionary 6502 microprocessor, a cornerstone of 1980s technology that powered iconic home computers, game consoles, and even arcade machines. Originating from MOS Technology, the 6502's affordability and versatility made it ubiquitous, from the Commodore PET to the Nintendo Entertainment System. We explore its standard and variant forms, its influence extending into toys, medical devices, and even space technology. Highlights include a technical breakdown of its operation, comparisons with contemporary CPUs, and its enduring legacy in modern computing. The video culminates with insights from Bill Mensch, a key figure behind the 6502, revealing its ongoing relevance in various sectors.

Takeaways

  • šŸ’¾ The 6502 microprocessor, created by MOS Technology, powered many 1980s computers, arcade machines, and game consoles, making it a pivotal component in the era's technology.
  • šŸ•¹ļø Iconic devices like the Commodore PET, VIC-20, Apple II, and Atari 400/800 utilized the standard 6502, showcasing its widespread adoption and versatility.
  • šŸŽ® Beyond computers, the 6502 found its way into game consoles such as the Atari 2600 and Nintendo's NES, underlining its ubiquity in entertainment technology.
  • šŸ”Œ Variants of the 6502, designed with modifications for cost reduction or feature addition, powered computers like the Commodore 64 and Apple IIgs, as well as in toys and medical devices.
  • šŸ“ˆ Despite its 8-bit architecture, the 6502's efficient design allowed it to compete effectively with higher clocked CPUs, demonstrating that MHz isn't the sole factor in computing performance.
  • šŸŽ² The 6502's simplicity facilitated a direct communication path with other chips via the data bus and chip select lines, making it an efficient and straightforward processor for its time.
  • āš™ļø Unique for its time, the 6502 could perform operations on both the rising and falling edges of the clock pulse, doubling its work rate per cycle compared to many contemporaries.
  • šŸ› ļø The advent of the 65c816, a 16-bit successor to the 6502, introduced extended capabilities like a larger address bus and 16-bit internal math, expanding the potential for more complex computing tasks.
  • šŸŒ The 6502's legacy extends into modern applications, with variants still in production for hobbyist markets and embedded systems, proving its enduring influence on computing.
  • šŸ‘Øā€šŸ”¬ A discussion with Bill Mensch, a co-creator of the 6502, revealed the processor's ongoing relevance, including its role in life-support systems and the decision-making behind not pursuing a 32-bit variant.

Q & A

  • What was the 6502 microprocessor used in during the 1980s?

    -The 6502 microprocessor was used in a variety of devices during the 1980s, including affordable home computers, arcade machines, video game consoles, and even some toys and medical devices like pacemakers.

  • How did the 6502 microprocessor impact the home computer market in the 1980s?

    -The 6502 microprocessor played a significant role in the home computer market by making computers more affordable and accessible. It powered popular home computers such as the Commodore PET, VIC-20, Apple II, and Atari 400 and 800.

  • What is a variant of the 6502 microprocessor, and how does it differ from the standard 6502?

    -A variant of the 6502 microprocessor is a version that may have added extra features or removed certain features to make the chip smaller or cheaper. While these variants run the same machine code as the original 6502, they may not be pin-compatible, meaning they cannot be directly swapped between different systems.

  • How did the 6502 microprocessor enable the gaming industry in the 1980s?

    -The 6502 microprocessor was widely used in arcade machines and video game consoles, including the Atari 2600, 5200, 7800, and the Lynx handheld, as well as the Nintendo NES and SNES. Its ubiquity and affordability contributed to the rapid growth of the gaming industry during this period.

  • What are some unique applications of the 6502 microprocessor outside of computers and gaming?

    -The 6502 microprocessor has been used in a variety of non-traditional applications, including toys like Furbies and Tamagotchis, implanted medical devices such as pacemakers, and even satellites orbiting the planet.

  • What made the 6502 microprocessor so popular and successful during its time?

    -The 6502 microprocessor was popular due to its affordability, versatility, and the fact that it was used in many successful home computers and gaming consoles of the era. Its simple design and wide compatibility with various systems also contributed to its success.

  • How does the 6502 microprocessor communicate with other chips on a motherboard?

    -The 6502 microprocessor communicates with other chips through a data bus, a read/write line, and a chip select (CS) or enable line. The data bus allows for 8-bit communication, while the read/write line determines the direction of data flow. The CS line allows the CPU to selectively communicate with different chips on the bus.

  • What is the significance of the 6502's 8-bit data bus and 16-bit address bus?

    -The 8-bit data bus of the 6502 allows for data transfer in 8-bit chunks, while the 16-bit address bus enables the CPU to address up to 64 kilobytes of memory. This combination of data and address bus widths was a key factor in the 6502's success and its ability to support a wide range of applications.

  • How did the 6502 microprocessor's performance compare to other CPUs of the era, such as the Z80?

    -Despite having a lower clock speed, the 6502 was able to compete well with other CPUs like the Z80 due to its efficient use of clock cycles and its ability to perform work on both the rising and falling edges of the clock pulse, effectively doing twice as much work per cycle.

  • What is the difference between the 6502 and its 16-bit variant, the 65816?

    -The 65816, also known as the 65c816, is an extension of the 6502 that operates in 16-bit mode, allowing for larger data operations and a larger addressable memory space of up to 16 MB. It also includes additional instructions and features that improve performance and functionality.

  • Why did the 6502 architecture not persist much beyond the 16-bit era?

    -The 6502 architecture did not persist much beyond the 16-bit era primarily due to the industry shift towards MS-DOS compatible systems and the rise of more advanced 32-bit architectures like ARM, which offered greater performance and capabilities for evolving software and hardware needs.

  • What are some modern applications and customers for the 6502 microprocessor?

    -Today, the 6502 microprocessor is still used in niche markets such as the hobbyist and retro computing communities, as well as in life-support systems, where its reliability and simplicity make it a critical component in devices like pacemakers.

Outlines

00:00

šŸ“ŗ Introduction to the 6502 Microprocessor

The video begins with an introduction to the 6502 microprocessor, highlighting its widespread use in various devices during the 1980s, including home computers, arcade machines, and video game consoles. The narrator expresses intent to discuss the 6502's role in these systems and its variants, as well as an interview with Bill Mensch, one of the creators of the 6502. The 1980s technological landscape is briefly painted, emphasizing the era's reliance on the 6502 processor.

05:04

šŸ’” How the 6502 Processor Works

This paragraph delves into the technical aspects of the 6502 processor, explaining how it communicates with other chips via an 8-bit data bus and a read/write line. The concept of Chip Select (CS) and the address bus are introduced, illustrating how multiple chips can communicate over the same data bus without interference. The explanation extends to the binary addressing system and why memory modules increase in size by doubling in capacity. The 6502's efficiency and performance are compared to other CPUs of the era, such as the Z80, highlighting the 6502's ability to perform more work per clock cycle and complete instructions faster.

10:07

šŸŽ® The 6502 in Gaming Consoles and Computers

The narrative shifts to focus on the 6502's application in gaming consoles and home computers, detailing the specific clock speeds at which various systems like the Atari 2600, Apple III, BBC Micro, and Super Nintendo operated. The discussion includes the challenges of attributing game performance to the CPU versus other system components, such as graphics co-processors. The Apple IIgs is presented as an example of a system primarily reliant on the CPU for its operations, and the impact of overclocking the 6502 is demonstrated through the gaming example of Wolfenstein 3D.

15:13

šŸ”¢ Mathematical Operations on the 6502

The paragraph explores how the 6502 handles mathematical operations, particularly with 8-bit numbers. It explains the process of adding 16-bit numbers by carrying out multiple instructions and the absence of direct multiply and divide instructions in the 6502's repertoire. The alternative methods for multiplication and division, including bit shifting and lookup tables, are discussed, along with a personal anecdote from the narrator about the efficiency of these methods over built-in multiply and divide commands on other processors.

20:14

šŸ› ļø Variants of the 6502 Processor

This section provides an overview of various 6502 processor variants, including the 6507 used in the Atari 2600, the 6502C (Sally chip), and the 6510 found in the Commodore 64. The differences in pin arrangements and functionalities, such as memory banking and the addition of general-purpose I/O pins, are highlighted. The Western Design Center 65c02, the only variant still in production, is introduced, along with its new opcodes and compatibility with older code. The challenges and potential of using the 65c02 in older systems are discussed, with a practical demonstration of its integration into a Commodore VIC-20.

šŸš€ The 65c816: A 16-bit Evolution of the 6502

The evolution of the 6502 into the 65c816, a 16-bit processor, is detailed. Despite having an 8-bit data bus, the 65c816 is capable of 16-bit math internally and has a larger address bus, allowing for up to 16 MB of RAM. The transition from 8-bit to 16-bit mode is explained, along with the pin differences and the need for an adapter board for installation in older systems. The 65c816's compatibility with the 65c02 opcodes and its use in the Apple IIgs and Super Nintendo are highlighted. The section concludes with a discussion on the 6502's longevity and modern applications, including its role in life-support systems.

šŸ—£ļø Conversation with Bill Mensch, Co-Creator of the 6502

The video concludes with an interview segment featuring Bill Mensch, one of the original creators of the 6502 and the 65c816 processors. Bill shares insights into the current market for the 6502, including its popularity in the hobbyist community and its critical role in life-support systems. He also discusses the transition in processor architecture beyond the 16-bit era, mentioning his recommendation of ARM architecture to licensees. The conversation provides a personal perspective on the legacy and ongoing relevance of the 6502 processor.

Mindmap

Keywords

šŸ’”6502 microprocessor

The 6502 microprocessor, developed by MOS Technology, is a central processing unit (CPU) that played a pivotal role in the 1980s home computers, arcade machines, and video game consoles. It was known for its affordability and efficiency, which led to its widespread adoption in various systems such as the Commodore PET, Apple II, and Atari 400/800. The 6502's significance in the video is that it represents the backbone of an entire generation of computing and gaming devices, showcasing its versatility and historical impact on the technology landscape.

šŸ’”variants

In the context of the 6502 microprocessor, variants refer to different versions or modifications of the original chip that may have additional features or altered specifications. These variants maintain compatibility with the original 6502's machine code but may differ in aspects such as pin configuration, making them non-interchangeable with the standard 6502 in certain applications. Variants allowed for more tailored solutions in various devices, contributing to the 6502's adaptability and longevity in the market.

šŸ’”data bus

The data bus is a critical component of a computer's architecture, consisting of a series of electronic channels that transfer data between the CPU and other hardware components, such as RAM chips. In the 6502 microprocessor, an 8-bit data bus means it can handle 8 bits of data at a time, which directly influences the processor's ability to communicate and manage information within the system. The width of the data bus is a key factor in determining the processor's performance and the types of devices it can support.

šŸ’”read/write line

The read/write line is a signal line in a computer system that controls the direction of data flow between the CPU and other components, such as memory chips. When the read/write line is activated (or set to 'read'), data is expected to be received by the CPU, whereas when it is deactivated (or set to 'write'), data is sent from the CPU to another component. This line is crucial for ensuring the correct and orderly exchange of information within the computer system.

šŸ’”Chip Select (CS) line

A Chip Select (CS) line, also known as an Enable line, is a signal used by the CPU to control which hardware devices on the data bus are allowed to communicate at any given time. When the CS line for a specific chip is activated, it grants that chip permission to transmit or receive data on the bus. This mechanism prevents data collisions and ensures that only the intended devices participate in data transfers, maintaining an organized and efficient communication protocol within the computer system.

šŸ’”address bus

The address bus in a computer system is a set of electronic channels that carry address signals from the CPU to the memory or I/O devices. These signals specify the location in memory or on the device where data is to be read from or written to. The size of the address bus, determined by the number of address lines, dictates the maximum amount of memory that the system can address. For example, a 16-bit address bus, like the one in the 6502, can address up to 65,536 unique memory locations or 64 kilobytes of memory.

šŸ’”clock speed

Clock speed, measured in hertz (Hz), is the rate at which a CPU's internal clock oscillates, which determines how many instructions per second a processor can execute. A higher clock speed generally indicates a faster and more efficient CPU. However, the 6502 microprocessor, despite having a lower clock speed compared to other CPUs of its era, was able to perform competitively due to its efficient design and fewer clock cycles required per instruction.

šŸ’”binary addressing

Binary addressing is a method used in computer systems to identify memory locations using binary numbers. Each address line on the address bus represents a binary digit (bit), and the combination of all bits on the address bus forms a binary address that points to a specific memory location. The size of the address bus directly affects the range of memory addresses that can be represented, with each additional bit doubling the possible addresses. This concept is fundamental to understanding how memory is organized and accessed in digital systems.

šŸ’”math operations

Math operations in the context of CPUs refer to the basic arithmetic functions such as addition, subtraction, multiplication, and division that a processor can perform on data. The 6502 microprocessor, being an 8-bit processor, operates on 8-bit numbers directly but requires additional instructions or techniques to handle larger numbers, as it lacks dedicated multiply and divide instructions. Programmers must use methods like bit shifting or lookup tables to perform these operations, which, while more complex, can still be efficient in certain scenarios.

šŸ’”65c02

The 65c02 is a variant of the 6502 microprocessor that was introduced by Western Design Center in 1983. It retains the original 6502's instruction set but adds new opcodes designed to improve programming efficiency and speed. The 65c02 is notable for still being in production today and for being used in systems like the Apple IIe, IIc, and Atari Lynx. Despite the addition of new instructions, the 65c02 maintains compatibility with existing 6502 code, making it a versatile and backward-compatible upgrade.

šŸ’”65c816

The 65c816 is a significant upgrade to the 6502 family of processors, introduced in 1985. It is a 16-bit capable CPU that retains the 8-bit data bus of the 6502 but can perform 16-bit math operations and access up to 16 MB of RAM, a substantial increase from the 64 KB limit of the original 6502. The 65c816 also supports all the new opcodes of the 65c02 and adds more, providing a more powerful and feature-rich platform for software development. It was used in systems like the Apple IIgs and the Super Nintendo.

Highlights

The 6502 microprocessor was a key component in many home computers, arcade machines, and video game consoles from the 1980s.

The 6502 was created by MOS Technology and was known for its affordability and efficiency.

The standard 6502 was used in iconic computers such as the Commodore PET, VIC-20, Apple II, and Atari 400 and 800.

A dozen or so variants of the 6502 existed, some with added or removed features, but not all were pin-compatible.

The 6502's ubiquity extended to dozens of arcade games, including classics like Asteroids and Centipede.

The 6502's influence can be found in unexpected places, such as toys, pacemakers, and even satellites.

The 6502 was introduced in 1975, a time of significant technological advancements and societal changes.

The 6502's low cost of $25 per unit at launch made it accessible for a wide range of applications.

The 6502's 8-bit data bus allowed for efficient communication between the CPU and other chips.

The 6502's clock pulse efficiency allowed it to perform more work per cycle compared to other CPUs of the era.

The 6502 required fewer clock cycles on average to complete an instruction, contributing to its performance.

The 6502's lack of built-in multiply and divide instructions led to innovative methods for these operations, such as bit shifting and lookup tables.

The 65c02 variant added new opcodes, enhancing the programming experience and execution speed.

The 65c816, a 16-bit variant of the 6502, was capable of addressing up to 16 MB of RAM and offered significant performance improvements.

The 6502's legacy continues in the modern day, with applications in hobbyist computing and life-support systems.

The 6502's simplicity and efficiency made it a favorite among programmers and a driving force in the personal computing revolution.

Transcripts

00:11

I have made countless videos about old computersĀ  from the 1980s, but in this episode we're goingĀ Ā 

00:16

to have a look at the processor that poweredĀ  them all, or at least most of them. And thenĀ Ā 

00:21

at the end of the video we're going to haveĀ  a quick chat with Bill Mensch, one of theĀ Ā 

00:24

original creators of the 6502 microprocessor The 1980s brought us affordable home computersĀ Ā 

00:30

for the first time ever, arcadeĀ  machines, and of course video gameĀ Ā 

00:35

consoles. There was one microprocessor thatĀ  seemed to be ubiquitous. One processor thatĀ Ā 

00:37

seemingly powered an entire generation. AndĀ  that processor was the 6502 by MOS Technology.Ā 

00:44

I want to start with the standard 6502. ThereĀ  were at least a dozen variants of it that wereĀ Ā 

00:49

more or less compatible, but might notĀ  be pin-compatible, and we'll come backĀ Ā 

00:53

to those later. So, let's start by having a lookĀ  at some of the computers that used the official,Ā Ā 

00:57

standard 6502. These would be the Commodore PET,Ā  and the VIC-20 The original Apple II and II+. AlsoĀ Ā 

01:06

the Atari 400 and 800 home computers, the OricĀ  Atmos, most of the Acorn computers like the AtomĀ Ā 

01:12

and Electron series, and of course the BBC micro. There were also dozens of arcade machines thatĀ Ā 

01:18

used the 6502, more than I want to cover here.Ā  But if you've ever played Asteroids, Centipede,Ā Ā 

01:24

Missile Command, Tempest, crystal castles, orĀ  ever really stepped into an arcade of any sort,Ā Ā 

01:31

you've probably played someĀ  machines that ran on the 6502.Ā 

01:35

All of these systems used a standard 6502Ā  processor. And what I mean by that is,Ā Ā 

01:39

you can take the CPU out of say a VIC-20,Ā  stick it in a very different kind of computer,Ā Ā 

01:44

such as an Apple II, and it will just work.Ā  You can even pull the 6502 out of a CommdoreĀ Ā 

01:49

disk drive and stick it in an Atari 400, and itĀ  would work just fine. It's strange today to thinkĀ Ā 

01:55

of all of these different incompatibleĀ  computers running the same exact chip.Ā 

02:01

However, the scope of the 6502 reachesĀ  far beyond these. When you start lookingĀ Ā 

02:05

at the variants, the list becomes huge. So, what is a variant exactly? Well, theseĀ Ā 

02:10

are other versions of the 6502 that have eitherĀ  added some extra features, or in some cases evenĀ Ā 

02:16

removed features in order to make the chip eitherĀ  smaller or cheaper. They all run the same machineĀ Ā 

02:22

code as the original, but they aren't necessarilyĀ  pin compatible, meaning you can't pull one outĀ Ā 

02:27

of one type of machine and then stick it in aĀ  different kind of machine and expect it to work.Ā 

02:31

Computers that used variants would be theĀ  Commodore 64 and 128, and the Plus/4. AlsoĀ Ā 

02:38

Apple used variants in the Apple III and IIgs.Ā  Atari used them in the XL and XE series of homeĀ Ā 

02:44

computers, and even inside their disk drives. Another popular use of the 6502 was of course,Ā Ā 

02:49

in game consoles. This would include the AtariĀ  2600, 5200, 7800, and the Lynx handheld. MoreĀ Ā 

02:56

importantly Nintendo used a variant in the NES, asĀ  well as the Super Nintendo, and the TurboGrafx 16.Ā 

03:04

But what might surprise you would be some ofĀ  the not so obvious places you can find 6502Ā Ā 

03:09

processors. Ever played with a Furby, yeah, thoseĀ  run on a 6502. How about a Tamagotchi, surprise,Ā Ā 

03:15

those run on a 6502. In fact, there are countlessĀ  toys that have a 6502 core, but they are reallyĀ Ā 

03:22

hard to catalog for you because they are usuallyĀ  embedded into an epoxy blob these days, making itĀ Ā 

03:26

really hard to tell just by opening up a toy. Here's one that may surprise you. If you haveĀ Ā 

03:32

a pacemaker or any sort of implanted technologyĀ  in your body, it is very likely running a 6502Ā Ā 

03:37

inside. There are even 6502 processorsĀ  orbiting the planet inside satellites,Ā Ā 

03:42

and I believe they were used in few minorĀ  systems on the space shuttle and internationalĀ Ā 

03:46

space station, although I don't know ifĀ  there are still any in use there today.Ā 

03:50

And apparently the terminators of the futureĀ  also run on 6502 as the computer code seen onĀ Ā 

03:56

screen is 6502 assembly instructions,Ā  and if Futurama is to be believed,Ā Ā 

04:00

then a thousand years from now, robots likeĀ  Bender will be operating on 6502 processors.Ā 

04:06

The point is, unless you have been living underĀ  a rock your whole life, everyone on the planetĀ Ā 

04:10

has at some point interacted with this processor. But, let's go back in time to the beginning. BackĀ Ā 

04:15

to 1975. Many notable things were happening.Ā  Gerald Ford was President of the USA. DiscoĀ Ā 

04:21

music was at its peak. The Rubiks cube wentĀ  on sale. The movie Jaws just came out. And,Ā Ā 

04:27

the Vietnam war was coming to an end. Oh,Ā  and The 8-Bit Guy was born, that's me.Ā 

04:33

But in the world of technolgy, there wereĀ  also many exciting things happening thatĀ Ā 

04:37

year. Video Cassette Recorders for home usersĀ  entered the market. The Altrair home computerĀ Ā 

04:42

kit was introduced. A little software companyĀ  called Microsoft was started. And of course,Ā Ā 

04:47

more importantly for the purposes of thisĀ  video, the 6502 Microprocessor went on sale.Ā 

04:53

For the first year, it was being sold for $25Ā  a unit, which was crazy cheap compared to itsĀ Ā 

04:57

nearest competitor, the Motorola 6800, whichĀ  sold for $175 a unit. At this time it was mostlyĀ Ā 

05:04

being used in hobby and enginering projectsĀ  like the KIM-1 computer, and later in SteveĀ Ā 

05:09

Wozniak's little computer, the Apple 1. But, let's skip forward to 1977, a yearĀ Ā 

05:15

mostly remembered for the debut of the Star WarsĀ  franchise, was also the year the 6502 really tookĀ Ā 

05:21

off. Computers like the Apple II and CommodoreĀ  PET entered the market. Two of the big-3 homeĀ Ā 

05:26

computers of that year used the 6502. But theĀ  real volume would come, not from a home computer,Ā Ā 

05:32

but from the Atari 2600 video game console.Ā  Atari would sell nearly 400,000 units of theĀ Ā 

05:38

2600 in 1977 alone, and eventually over 30Ā  million of them over the life of the product.Ā 

05:45

Needless to say, this was just the tip of theĀ  iceberg. but now let's have a look at some of theĀ Ā 

05:50

features of this chip, and see how it worked. I want to start by talking about how the CPUĀ Ā 

05:54

communicates with other chips. 8 of the pins onĀ  the CPU represent the data bus. Each of theseĀ Ā 

06:00

can be either on or off, which represent a 1 orĀ  zero. Hence, this is an an 8-bit data bus. So,Ā Ā 

06:06

for illustration we'll connect this to theĀ  data bus of a RAM chip. This way the CPU andĀ Ā 

06:10

the RAM chip can send and receive 8-bit numbers. But there's another important line that the CPUĀ Ā 

06:15

controls. This is the read/write line. IfĀ  the line is on, its means to read and thusĀ Ā 

06:20

the data is expected to travel this direction.Ā  If the line is off, then it means write, andĀ Ā 

06:25

the data will travel in this direction instead. And so this line also has to connect to the RAMĀ Ā 

06:30

chip so both the CPU and the RAM chip understandĀ  the direction data is flowing at any given time.Ā Ā 

06:36

OK, hopefully all of this makes sense so far. OfĀ  course, most any motherboard is going to be farĀ Ā 

06:41

more complicated than this, because there willĀ  be a lot more chips like I/O chips, video chips,Ā Ā 

06:45

etc. And they all connect to the same data bus. So the question is, how do they all talk overĀ Ā 

06:50

the same data bus at the same time withoutĀ  signals colliding with each other? Well,Ā Ā 

06:54

they don't. They are all allowed to listenĀ  to the bus, but only allowed to talk on theĀ Ā 

06:58

bus when the CPU wants to talk to them. So howĀ  does that work? Well, each chip on the bus hasĀ Ā 

07:04

a CS line. It stands for Chip Select. SometimesĀ  it may be called an Enable line. Either way,Ā Ā 

07:09

it does the same thing. When this line isĀ  activated, that means the chip is allowedĀ Ā 

07:13

to talk on the bus. That chip could be a RAMĀ  chip, ROM chip, I/O chip, video chip, whatever.Ā 

07:18

So the next question is, what determines whenĀ  that chip is activated? OK, we have the data bus,Ā Ā 

07:23

and the read/write line. But we alsoĀ  have something called the address bus,Ā Ā 

07:27

which on the 6502 is 16 bits. So, while the dataĀ  bus can communicate in numbers between 0 and 255,Ā Ā 

07:33

the address bus can represent numbers between 0Ā  and 65,535, or another way of saying that is 64Ā Ā 

07:39

Kilobytes. The size of the address bus determinsĀ  the maximum memory of the computer, not countingĀ Ā 

07:44

banking schemes, which we can get into later. Have you ever wondered why memory modules,Ā Ā 

07:48

when they increase to the next size, are alwaysĀ  double the previous size? They increase in powersĀ Ā 

07:53

of two. Well, the reason for that has to do withĀ  binary addressing. So, imagine you have a RAM chipĀ Ā 

07:58

that is 16 megabytes in size. It would need 24Ā  address lines to be able to access all of thatĀ Ā 

08:03

RAM. And that means a minimum address of zero, orĀ  a maximum address of, well, a bunch of ones. So,Ā Ā 

08:09

if you wanted to make the chip bigger, there'sĀ  no way to really add fractional amounts of RAM.Ā Ā 

08:14

You would have to add an additional addressĀ  line. In doing so, you've also added anotherĀ Ā 

08:18

number to your binary number, which will alwaysĀ  result in multiplying the max value by two.Ā 

08:23

So, back to our CPU address bus. The way thisĀ  works is it goes into a bunch of decoding logic,Ā Ā 

08:28

which I'm not going to get into here,Ā  but that logic will take the address andĀ Ā 

08:31

determine which of the chips will be selected,Ā  whether it is RAM, ROM, or a video chip, etc.Ā 

08:37

Now, much of what I've shown here could be appliedĀ  to most any CPU. But now I want to tell you a fewĀ Ā 

08:42

things that sets the 6502 apart. So, let's compareĀ  with the Z80 , another popular CPU of the era. ItĀ Ā 

08:48

was quite common for 6502 systems to run atĀ  1 Mhz, and Z80 systems to run at 4 mhz. Now,Ā Ā 

08:55

you might be tempted to think the Z80 wouldĀ  be 4 times faster. But it's not. Why is that?Ā 

09:01

Well, for one thing let's look at the clock pulse.Ā  Imagine this is your 1 mhz clock pulse. Most CPUsĀ Ā 

09:07

would only be doing work at the top of the clockĀ  pulse like this. However, the 6502 also does workĀ Ā 

09:13

on the bottom of the clock pulse like this,Ā  essentially doing twice as much work per clockĀ Ā 

09:17

cycle than a typical CPU. But that isn't the onlyĀ  thing that makes a difference. Most instructionsĀ Ā 

09:23

require more than one clock pulse to complete andĀ  the 6502 requires fewer cycles on average thanĀ Ā 

09:28

other CPUs of the era to complete an instruction. The Z80 was especially inefficient because,Ā Ā 

09:34

despite being an 8-bit CPU, it's ALU, orĀ  "Arithmetic Logic Unit" is only 4 bit,Ā Ā 

09:40

and thus most calculations require extraĀ  clock cyclces to complete any 8-bit math.Ā 

09:45

So, let's compare 4 common CPUs from the 1980sĀ  at their most common clock frequencies. If youĀ Ā 

09:50

look at raw performance, the 6502 actuallyĀ  competes well against the other CPUs evenĀ Ā 

09:55

at its much lower clock speed of 1 Mhz.Ā  The moment you double it to even 2 Mhz,Ā Ā 

10:00

it suddenly outperforms just about everythingĀ  except the 68000. Most systems ran at 1 Mhz,Ā Ā 

10:06

but there were some that ran just a bit faster. Atari 2600 ran at 1.19 MhzĀ 

10:13

Basically all subsequent Atari computersĀ  and game consoles ran at 1.79 Mhz.Ā 

10:19

interestingly enough, the originalĀ  Nintendo also ran at 1.79 MhzĀ 

10:24

Apple III ran even faster at 1.8 Mhz The BBC Micro ran at 2.0 MhzĀ 

10:30

as did the Commodore 128,Ā  but only in 80 columns mode.Ā 

10:35

The Apple IIgs ran at 2.8 Mhz The Super Nintendo 3.58 MhzĀ 

10:41

And the fastest machines from the time periodĀ  that I know of are the Apple IIc Plus and someĀ Ā 

10:46

clones like Laser 128 ex2, which ran at 4Ā  Mhz. I know 4 Mhz doesn't sound like a lot,Ā Ā 

10:53

but that was some serious speed. unfortunaetly,Ā  there was little to no software that really tookĀ Ā 

10:57

advantage of that. So the best examples weĀ  really have of what could be done at theĀ Ā 

11:01

time would be to look at the Super Nintendo. The problem is, it's hard to say exactly whatĀ Ā 

11:06

aspects of these games you can really creditĀ  the CPU, versus some of the advanced graphicsĀ Ā 

11:11

co-processors that were also in the system. InĀ  fact, some of these games, like starfox, even usedĀ Ā 

11:16

a 3D coprocessor located in the cartridge itself. The Apple IIgs might be a better system to lookĀ Ā 

11:22

at since it had much less in terms of graphicsĀ  acceleration, thus relying primarily on the CPUĀ Ā 

11:28

for most of the work. of course, anotherĀ  problem is the Super Nintendo and AppleĀ Ā 

11:33

IIgs are technically running 65816 CPUs,Ā  which is the 16-bit version of the 6502,Ā Ā 

11:39

which we're going to come back to here in a littleĀ  bit. That being said, one interesting comparisonĀ Ā 

11:44

is Wolfenstein 3D. This is the SNES version.Ā  And while there is some amount of graphicsĀ Ā 

11:50

acceleration on the SNES, the CPU is reallyĀ  doing the heavy lifting of rendering this game.Ā 

11:55

Now let's look at the Apple IIgs version. It usesĀ  the exact same processor, but lacks most of theĀ Ā 

12:00

accelerated graphics features. That's why theĀ  game is scaled down to the center of the screen,Ā Ā 

12:05

even though technically the level of detailĀ  is exactly the same as the SNES version. AndĀ Ā 

12:10

you may notice it runs a little slower, whichĀ  makes sense because the CPU in the Apple IIgsĀ Ā 

12:15

is slower. But now check this out. This is theĀ  same version but here the Apple IIgs has an 8 MhzĀ Ā 

12:21

accellerator in it. So, same type of processor,Ā  just running almost 3 times faster. In fact,Ā Ā 

12:26

with this CPU you can expand the rest of theĀ  screen out and it still plays relatively decently.Ā 

12:33

Modern versions of the 6502, made byĀ  WDC are actually rated to run at 14 Mhz,Ā Ā 

12:39

and I've heard of people overclocking them to runĀ  even faster. The commander X16 runs at 8 Mhz, andĀ Ā 

12:45

thus might be a good example of what can be done. Planet X16, which is a real-time-strategy game IĀ Ā 

12:50

wrote for the Commander X16, is a somewhatĀ  interesting example. Believe it or not,Ā Ā 

12:54

it runs just about perfectly, even if I jumper theĀ  computer down to 4 Mhz. And that's why we're alsoĀ Ā 

13:00

working on a port for the Super Nintendo whichĀ  is close enough to that speed. I hope to showĀ Ā 

13:04

you more of this in a later episode, but I thinkĀ  it will be a very interesting game for the SNES.Ā 

13:10

A better example might be the KG3D demo onĀ  the Commander X16, running a bog standardĀ Ā 

13:15

8-bit 6502 at 8 mhz. As you can see, this 3DĀ  environment runs very smoothly at 8 Mhz. Now,Ā Ā 

13:23

for those that grew up with IBM PCs, imagineĀ  trying to run something like this on a turbo-XTĀ Ā 

13:28

at 8 mhz. It's just not going to happen. AndĀ  so, I hope this better illustrates that CPUĀ Ā 

13:34

megahertz isn't a good method for comparingĀ  speed between different types of CPUs.Ā 

13:39

Let's switch gears for a moment and talk aboutĀ  some technical details, specifically math. So,Ā Ā 

13:45

a lot of people might ask the question, "if theĀ  processor can only deal with 8 bit numbers as inĀ Ā 

13:49

numbers from 0 to 255 how can it possibly doĀ  math operations on numbers larger than that?"Ā 

13:55

Imagine you have two 16-bit numbers you need toĀ  add together. Well, it can't do it all at once.Ā Ā 

14:00

So, as a programmer you'll need to add the leastĀ  significant bytes together and get the result. ButĀ Ā 

14:05

adding these two values exceeds 255, so that willĀ  set the carry bit. So the next addition you do,Ā Ā 

14:10

over here will take that into account andĀ  there you go, you'll get your 16 bit result.Ā 

14:16

So really, the only downside to working withĀ  larger numbers on the 8bit CPU is that itĀ Ā 

14:20

does require more instructions, which makesĀ  the code longer and more cycle counts thanĀ Ā 

14:25

performing the same operation on, say a 16bitĀ  CPU. Well, one thing you may find particularlyĀ Ā 

14:30

interesting is the 6502 actually has noĀ  instructions for multiply or divide. But,Ā Ā 

14:36

I'm sure you've guessed, there is a way toĀ  accomplish that. Actually, more than one way.Ā 

14:40

The easiest way to multiply is with bit shifting.Ā  There is an instruction to shift all of theĀ Ā 

14:44

bits to the left or right. So, take this binaryĀ  number, which is equal to 26 in decimal. If youĀ Ā 

14:49

shift everything to the left by one bit, then youĀ  essentially multiplied the number by two. You canĀ Ā 

14:54

do it again, and now you've multiplied by 4, andĀ  again and now you've multiplied by 8. Likewise,Ā Ā 

14:59

you can shift a number to the right, and you canĀ  divide by 2, divide by 4, divide by 8, or hereĀ Ā 

15:05

even divide by 16. So, multiplying or dividingĀ  by powers of 2 is very easy to do, and very fast.Ā 

15:12

But let's take the original number and let's sayĀ  you need to multiply it by a number that is not aĀ Ā 

15:16

power of 2, such as the number 6. Well, you canĀ  accomplish that by shifting twice to the left,Ā Ā 

15:21

that gets you multiply by 4. Then you takeĀ  the original number and shift it just onceĀ Ā 

15:26

to the left, that multiplies by 2, and thenĀ  you can add those together, and you haveĀ Ā 

15:30

your result. This method is also fairly fast. And of course, the last method is by simplyĀ Ā 

15:35

using a chart. You just store all of the resultsĀ  in RAM as part of your code. And then let's sayĀ Ā 

15:40

you need to multiply 5 times 9, you can just lookĀ  up the answer in the table, and there you have it.Ā 

15:45

So, you might think these methods are overlyĀ  complicated or slow. But, here's a littleĀ Ā 

15:49

interesting anecdote for you. When I startedĀ  coding Planet X3 on the 8088 microprocessor, atĀ Ā 

15:55

first I was really excited that I finally had useĀ  of built-in commands for multiply and divide. But,Ā Ā 

16:01

one of the things I realized once I started tryingĀ  to optimize the game for speed is that using bitĀ Ā 

16:06

shifts or lookup tables was actually significantlyĀ  faster than using the built-in multiply and divideĀ Ā 

16:11

commands. So, I ended up actually strippingĀ  out all of those multiply and divide commandsĀ Ā 

16:15

and replacing them with the same techniquesĀ  I had been using all along on the 6502. So,Ā Ā 

16:20

it turns out um those multiply and divideĀ  commands really aren't all that useful after all.Ā 

16:25

Let's take a look at how the regular 6502 comparesĀ  to some of the variants. The Atari 2600 used aĀ Ā 

16:31

processor known as the 6507, which as you canĀ  see is a smaller package having fewer pins. I'dĀ Ā 

16:37

like to draw your attention to the address bus.Ā  As you can see there are only zero through 12,Ā Ā 

16:41

instead of 0 through 15. That reduces theĀ  addressable memory down to 8 kilobytesĀ Ā 

16:47

instead of the usual 64. That is also why AtariĀ  2600 cartridges are typically limited to 8 KB,Ā Ā 

16:53

unless clever banking schemes are used. Now let's look at the 6502C, otherwiseĀ Ā 

16:58

called the Sally chip. This chip was used inĀ  Later Atari computers like the XL and XE series,Ā Ā 

17:04

and game consoles like the 7800. It's basicallyĀ  the same as a regular 6502. These 4 pins overĀ Ā 

17:10

here are re-arranged. The main reason for thisĀ  is that they wanted to add the HALT signal soĀ Ā 

17:15

that the CPU could temporarily be haltedĀ  so that the video circuits could use DMA.Ā 

17:21

Now let's look at the 6510, which was used in theĀ  Commodore 64. As you can see, basically every pinĀ Ā 

17:27

is in a different place. But the main differenceĀ  is these P0 through P5. These are essentiallyĀ Ā 

17:32

general purpose IO pins. In the Commodore 64 theyĀ  are used for memory banking. This was essentiallyĀ Ā 

17:38

a cost saving measure to add this into the CPUĀ  as it eliminated extra circuits on the board.Ā 

17:44

OK, so I'm not going to cover every variantĀ  as that would take forever. You can see hereĀ Ā 

17:48

on Wikipedia a list of all of the variationsĀ  of the CPU. But I just wanted to give you anĀ Ā 

17:53

idea of the ways in which most of them differ. But, I do want to take a look at the WesternĀ Ā 

17:58

Design Center 65c02. This launched in 1983 andĀ  it's the only variant to my knowledge that isĀ Ā 

18:04

still in production today. This CPU was used inĀ  the Apple IIe, and IIc, Laser 128, and the AtariĀ Ā 

18:11

Lynx, among others. One of the big differencesĀ  is the instruction set. This is the standard 6502Ā Ā 

18:17

instruction set. There are some undocumentedĀ  opcodes, but we won't get into that. TheĀ Ā 

18:21

65c02 added these new opcodes. Most of these areĀ  designed to make life easier on the programmer,Ā Ā 

18:27

as well as make execution a little faster. OlderĀ  code will still run on this CPU, it just won't beĀ Ā 

18:33

making use of any of these new instructions. In fact, I want to show you something a lotĀ Ā 

18:37

of people don't know about. This is an ordinaryĀ  Commodore VIC-20, and I'm going to remove it'sĀ Ā 

18:42

CPU. It's just a standard 6502, which is to beĀ  expected. And here we have a brand new 65c02Ā Ā 

18:49

from Western Design Center. And what I'm goingĀ  to do is insert this into the VIC-20, and powerĀ Ā 

18:54

it on. And well, if you thought it was goingĀ  to work, then I guess you'll be disappointed.Ā 

19:00

The reason it doesn't work has nothing to do withĀ  the new opcodes, but rather the pin arrangement.Ā Ā 

19:04

If you compare the two processors, you'll see theyĀ  are almost identical pin arrangements. In fact,Ā Ā 

19:08

only these 3 pins are different. I'm not goingĀ  to go into great detail on what these do. But,Ā Ā 

19:14

let's see if we can make this workĀ  in the VIC-20. I'll start by bendingĀ Ā 

19:17

up two of those pins that were different.Ā  I'm just going to leave one disconnected,Ā Ā 

19:20

and the other I'm going to use a resistorĀ  and tie it to 5V, pulling it high. I know,Ā Ā 

19:26

it doesn't look terribly elegant. But let's stickĀ  it back into the VIC-20 now and see what happens.Ā 

19:31

Check it out, it works. At this point the VIC-20Ā  now has additional instructions available to it ifĀ Ā 

19:37

you wanted to write code to support it. And evenĀ  though this CPU can run at 14 mhz, it is obviouslyĀ Ā 

19:43

only going to run at the clock speed the VIC-20Ā  gives it, which is still 1 mhz. So there isn't aĀ Ā 

19:48

huge advantage to using this. I run a number ofĀ  games and didn't have any compatibility issues,Ā Ā 

19:55

although I'm sure there's probably at least oneĀ  or two out there that were using some undocumentedĀ Ā 

19:58

opcodes that might fail with this CPU inside. OK, now let's take a look at the 65c816. ThisĀ Ā 

20:06

chip debuted in 1985, and it is a significantĀ  upgrade to the 6502. This chip is 16-bit,Ā Ā 

20:13

sort of. You see, there's no standard way toĀ  define how many bits a CPU is. Some peopleĀ Ā 

20:18

judge it based on how wide the data-bus is. InĀ  this case, the data-bus is still 8-bit, just likeĀ Ā 

20:24

the 6502. But internally, it can do 16-bit math. It also has a ton of other new features. In fact,Ā Ā 

20:31

here are those opcodes we lookedĀ  at earlier for the 65c02. Well,Ā Ā 

20:35

the 816 supports all of these opcodes. In fact,Ā  when it boots up, it starts in 8-bit mode,Ā Ā 

20:41

thus essentially operating exactly like the 65c02.Ā  There are a few small differencees, I'm sure someĀ Ā 

20:47

of the keyboard warriors will want to point out.Ā  For example, Some 65C02s made by rockwell and WDC,Ā Ā 

20:53

had these extra instructions here. I didn't showĀ  them earlier because not all varients supportedĀ Ā 

20:58

these, and they aren't used very often. But theĀ  816 definitely doesn't support these and insteadĀ Ā 

21:03

adds all of these when operating in 16-bit mode. When performing 16-bit math, that means insteadĀ Ā 

21:10

of requing 6 or 7 instructions to handleĀ  problems like this one half at a time,Ā Ā 

21:14

it can do the whole thing in a singleĀ  instruction. This sort of thing can reallyĀ Ā 

21:18

speed up execution for certain types of software. But, perhaps a more important aspect of the chipĀ Ā 

21:23

is the larger address bus, let me show you howĀ  that works. The pin arrangement on the 816 is veryĀ Ā 

21:29

similar to the 6502, but it's a little bit moreĀ  complicated to get to work in an older computerĀ Ā 

21:34

because as you can see there are now 9 pins thatĀ  are different from the original. but you may beĀ Ā 

21:39

counting up the address lines and seeing thatĀ  there are still only 0 through 15. So how canĀ Ā 

21:44

it access more than 64K, you might ask? Well,Ā  when you put the chip into the correct mode,Ā Ā 

21:48

the data-bus pins will pull doubleĀ  duty. So when the clock cycle is high,Ā Ā 

21:52

they are data lines like usual. but when theĀ  clock is low, they are become address lines 16Ā Ā 

21:57

through 23. Thus giving it a 24-bit address,Ā  capable of addressing up to 16 MB of RAM, aĀ Ā 

22:04

massive amount more than a typical 8-bit computer. So, can you install one of these into somethingĀ Ā 

22:09

like a VIC-20? Well, sort of. You're goingĀ  to need a ltitle adapter board like this one,Ā Ā 

22:14

which are remarkably hard to find at the moment.Ā  But in theory you can pop this into your VIC-20Ā Ā 

22:18

or other 8-bit system and instantly haveĀ  a 16-bit capable computer, except thatĀ Ā 

22:23

you won't have access to the extra RAM. Perhaps a better example, something I canĀ Ā 

22:28

actually show, is the Commander X16. By defaultĀ  it comes with a 65c02, but it actually supportsĀ Ā 

22:34

the 816. I keep one around for testing andĀ  I have a big label on it so I don't get itĀ Ā 

22:37

confused with my other CPUs. But yeah, theĀ  X16 runs just fine with the 816 installed,Ā Ā 

22:42

and in theory if people wanted to write code thatĀ  made use of the 16-bit aspect of it, they could.Ā 

22:48

I think the 816 was a really great processor,Ā  but it only ever saw widespread use inĀ Ā 

22:53

the Apple IIgs and the Super Nintendo. So, the last thing I have for you guys is,Ā Ā 

22:57

I finally man managed to sit down andĀ  have a conversation with Bill Mensch,Ā Ā 

23:01

one of the original creators of the 6502 and theĀ  816 processor, and I had a few questions for him.Ā 

23:07

So, Bill, tell me who are the current, modern-dayĀ  customers of the 6502. OK, so we have a lot ofĀ Ā 

23:15

interest in your world, meaning the hobby world.Ā  And so we sell boards into that. and we sell chipsĀ Ā 

23:23

into that. And as you know, you and Ben Eater,Ā  Ben Eater has been especially active in thatĀ Ā 

23:34

world. And then we have some others, Stefany IĀ  think you know. But in any event. I find it hardĀ Ā 

23:39

to believe that just the retro market keeps theĀ  whole 6502 business alive. There's got to be moreĀ Ā 

23:45

other modern customers. And the other thing thatĀ  we still get royalties off of is life-support. so,Ā Ā 

23:53

we keep millions of people alive oneĀ  heartbeat at a time, with the 65c02. Really?Ā 

24:02

Why do you feel like the 6502 architecture didn'tĀ  last much beyond the 16-bit era with like theĀ Ā 

24:11

Apple IIgs and Super Nintendo? Is it just becauseĀ  everyone was going to MS-DOS compatibility,Ā Ā 

24:17

or was there some other reason? Well, IĀ  specifically was recommending ARM. OK. So whenĀ Ā 

24:26

my licensees asked what I was doing at 32-bit,Ā  I said, "Well, I have some specifications forĀ Ā 

24:37

32 bit. I'm happy to share them with you.Ā  But, I don't think that's what you want."Ā 

24:42

Well, if you've made it this far then you'veĀ  probably learned more about the 6502 than youĀ Ā 

24:46

probably ever wanted to know. But, hopefully atĀ  least you have a little bit of understanding ofĀ Ā 

24:50

the significant role that the CPU has playedĀ  over the last 40 years and also why it is myĀ Ā 

24:55

favorite CPU. But, that's all I have forĀ  now, so as always thanks for watching!