Seyed Masoud Hosseini · Overview · Study log · Ideas · Transcript · RSS feed

Embedded Systems, 6502 breadboard computer · Lecture 1 of 29 · 27:24

Part 1: 'Hello, world' from scratch on a 6502

“Hello, world” from scratch on a 6502 — Part 1 on YouTube

Study guide

What this lecture covers

This is the first video in a series that builds a working computer around the classic 6502 microprocessor, starting from a completely bare chip on a breadboard. The lecture answers a basic question: with no operating system, compiler, or existing computer to lean on, what does it actually take to get a microprocessor to do anything at all?

You'll see every pin on the 6502 wired up by hand, a clock signal supplied, and an Arduino used as a makeshift logic monitor to read the address and data buses. By the end, the chip is executing a trivial "no operation" loop, which sets up the next video's step of feeding it real instructions from a ROM chip.

Key ideas

  • VDD/VSS: the 6502's power and ground pins, wired directly to the breadboard's power and ground rails.
  • Input vs. output pins: inputs (like RDY, IRQB, reset) must be tied to a sensible voltage for the chip to run; outputs can be left unconnected while exploring.
  • Clock (PHI2): the 6502 needs a repeating clock signal to step through its operation; a manually adjustable clock module is used so individual pulses can be observed.
  • Static design: the modern W65C02 variant used here can hold its clock at any level without losing register contents, unlike the original 1975 chip.
  • Reset sequence: pulling reset low and releasing it starts a seven-clock-cycle sequence that loads the program counter from the reset vector.
  • Reset vector: the two bytes at addresses $FFFC and $FFFD tell the processor where to start executing code.
  • Read/write signal: a dedicated pin tells external circuitry whether the processor is currently reading from or writing to the data bus.
  • Opcode $EA: with the data bus resistors used in the video, the processor reads the same byte on every cycle, which happens to decode as the no-op instruction.

Walkthrough

Powering and wiring the bare chip (1:01)

The lecture goes pin by pin through the 6502 datasheet, connecting VDD and VSS to the power rails, then deciding what to do with each remaining pin. Inputs that matter for the chip to run, such as ready, the two interrupt lines, and bus enable, are tied high so they don't interfere. Outputs, including the sixteen address lines and status pins, are left unconnected for now since nothing depends on them yet.

Clock and reset wiring (4:07)

A separate 555-timer-based clock module (built in an earlier project) drives the PHI2 clock pin so pulses can be slowed down, halted, or single-stepped. The reset pin is tied high through a resistor with a push button to ground, so pressing the button forces a reset while releasing it lets the processor run normally.

Reading the address bus with an Arduino (8:18)

Rather than using a logic analyzer, which is overkill for a slow, hand-clocked circuit, the sixteen address lines are connected to digital input pins on an Arduino Mega. A simple sketch loops through the pins, reads each as a bit, and prints the 16-bit pattern to the serial monitor once per clock cycle, triggered by an interrupt on the clock line.

Adding the data bus and read/write signal (13:38)

The eight data bus pins and the read/write pin are wired to more Arduino inputs. The sketch is extended to accumulate the address and data bits into integers and print them as hexadecimal, along with an R or W showing whether the processor is reading or writing. At this point the data pins are unconnected, so the processor reads meaningless "garbage" whenever it tries to fetch data.

Hard-wiring a predictable data value (18:46)

Each data pin is tied to ground or 5 volts through a resistor so the processor always reads the same fixed byte ($EA) from the data bus. This makes the processor's behavior far more predictable: it starts counting addresses steadily instead of behaving erratically.

Tracing the reset sequence and first instructions (20:47)

Single-stepping the clock through a reset shows the seven-cycle reset sequence, followed by two reads from the reset vector addresses $FFFC and $FFFD. Because both reads return $EA, the program counter loads $EAEA, and the processor begins fetching from that address, where it keeps reading the same hard-wired byte. Looking it up in the datasheet's opcode table shows $EA decodes as the no-op instruction, so the processor simply loops doing nothing, advancing one address every two clock cycles.

Before you watch

  • Familiarity with binary and hexadecimal number systems will help when reading the address and data bus values.
  • Basic breadboard wiring and reading a component pinout from a datasheet are assumed.
  • No prior 6502 or assembly knowledge is needed; this video builds the foundation for the rest of the series.

Check your understanding

  1. Why does the processor read the same value from the data bus in the second half of the video, and how does that make its behavior more predictable?
  2. What are the reset vector addresses, and what role do they play immediately after reset?
  3. Why did the lecture choose an Arduino instead of a logic analyzer to observe the address and data buses?
  4. What does the read/write pin tell you about what the processor is doing on a given clock cycle?
  5. Why does the no-op instruction take two clock cycles to complete on this chip?

Chapters

From the YouTube description

Learn how computers work in this series where I build and program a basic computer with the classic 6502 microprocessor. More info: https://www.eater.net/6502

Part 2: https://www.youtube.com/watch?v=yl8vPW5hydQ
Part 3: https://www.youtube.com/watch?v=oO8_2JJV0B4
Part 4: https://www.youtube.com/watch?v=FY3zTUaykVo
Part 5: https://www.youtube.com/watch?v=xBjQVxVxOxc
Part 6: https://www.youtube.com/watch?v=i_wrxBdXTgM
Part 7: https://www.youtube.com/watch?v=omI0MrTWiMU

Support these videos on Patreon: https://www.patreon.com/beneater or https://eater.net/support for other ways to support.

------------------

Social media:
Website: https://www.eater.net
Twitter: https://x.com/beneater
Patreon: https://patreon.com/beneater
Reddit: https://www.reddit.com/r/beneater

Special thanks to these supporters for making this video possible:
Alex Catchpole
Armin Brauns
BakerStaunch
Beau-James Erion
Ben
Ben Dyson
Ben Kamens
Ben Williams
Bradley Pirtle
Christopher Blackmon
Clayton Parker Coleman
Daniel Tang
Dean Winger
Debilu Krastas
Dominic Kulmer
Dušan Dželebdžić
Eric Brummer
Eric Dynowski
Erik Broeders
Eugene Bulkin
fxshlein
HaykH
Ian Tait
Ivan Sorokin
JavaXP
Jay Binks
Jayne Gabriele
Jefferson Hunt
Jimmy Campbell
Joel Messerli
Joel Miller
Jordan Scales
Joshua King
Justin Duch
Kent Collins
Manne Moquist
Marcus Classon
Mats Fredriksson
Michael
Michael Burke
Michael Garland
Miguel Ríos
Nathan Wachholz
Nicholas Moresco
Onion Sniffer
Paul Pluzhnikov
Peter Simard
Randy True
Robert Butler
Sachin Chitale
Sergey Ten
SonOfSofaman
Stefan Nesinger
Stephen Smithstone
Steve Gorman
Thomas Ballinger
Vladimir Kanazir
xisente
Örn Arnarson

Part 2: How CPUs read machine code →