thecodingidiot.com

f03c-writing-6502-assembly

Writing 6502 Assembly

The Instruction Set

In 1975, Chuck Peddle[1] and a team at MOS Technology introduced the 6502 at the Western Electronic Show and Convention. They sold it at the booth for 25.CompetingchipsfromIntelandMotorolacost25. Competing chips from Intel and Motorola cost 150 to $300. The price difference was not a discount — it was a different calculation.

Chuck Peddle — In 1977
Chuck Peddle — In 2013

Peddle's team had left Motorola specifically to build a cheap CPU for the personal computing market that Motorola had decided was not worth their time. They were right about the market.

The 6502 is in the Apple I and Apple II, the Atari 2600, the Commodore PET, the VIC-20, the Commodore 64, the BBC Micro, the Nintendo Entertainment System. It powered personal computing from 1975 through the end of the 1980s — every important machine of that era ran on this instruction set or a compatible variant.

In 1984, The Terminator[2] needed to show what a machine sees. The filmmakers scrolled code across a red screen — widely identified as real Apple II software and actual 6502 assembly. The chip had become so ubiquitous that Hollywood reached for it as the visual shorthand for machine intelligence.

The Terminator (1984) — 6502 assembly scrolling on the HUD display
The Terminator (1984) — close-up of the assembly code on screen
The Terminator (1984) — another frame of the 6502 assembly sequence

This chapter writes it.

The implementation pages build five programs on the breadboard from the previous chapter, adding a 65C22[3] VIA chip for GPIO[4]. Each program introduces a new part of the instruction set: the counter covers memory and arithmetic, the LED covers output, the button covers input, the tone covers timing, and the game loop ties them together. Start at Setup.

Implementation

Setup

Begin Implementation
  1. 0Setup
  2. 1Registers and Addressing
  3. 2Counter and LED
  4. 3Button Input
  5. 4The Tone
  6. 5The Game Loop

Footnotes

  1. Chuck Peddle - Wikipedia

  2. The Terminator (film) | Terminator Wiki | Fandom

  3. WDC 65C22 - Wikipedia

  4. General-purpose input/output - Wikipedia