Modern tools to learn old school MOS 6502 assembly language (2024-03-21)

We love EOR #$FF: 6502 Ponderables and Befuddlements and highly recommend it.
Here is how the book begins: “As I write, Apple is selling an M2 Ultra processor that has 134 billion transistors. In contrast, the humble 6502, released in 1975, has a mere 3,510. To the programmer, the 6502 offers bottom-up simplicity, without limiting top-down expressivity. And therein lies the appeal of 8-bit retro-computing: the hardware, firmware, and software can be completely understood and reshaped by motivated hobbyists – a microcosm for creativity.”

We love this passage - yes the simplicity of 6502 and expressivity is what has drawn us into the 8-bit retro-computing scene.

Most importantly - recommendations I found in the book and am currently enjoying:

Easy 6502

by Nick Morgan
with built-in exercises and examples such as:

LDA #$01
STA $0200
LDA #$05
STA $0201
LDA #$08
STA $0202

As it turns out (per Nick Morgan): “Bender in Futurama has a 6502 processor for a brain. Even the Terminator was programmed in 6502.”

image


dasm 8-bit macro assembler

image



The MOS Technology 6502 processor has a set of 56 instructions. Here’s a list of these instructions categorized by their operation:

Load/Store Operations

  • LDA (Load Accumulator)
  • LDX (Load X Register)
  • LDY (Load Y Register)
  • STA (Store Accumulator)
  • STX (Store X Register)
  • STY (Store Y Register)

Arithmetic

  • ADC (Add with Carry)
  • SBC (Subtract with Carry)

Increment & Decrement

  • INC (Increment Memory)
  • INX (Increment X Register)
  • INY (Increment Y Register)
  • DEC (Decrement Memory)
  • DEX (Decrement X Register)
  • DEY (Decrement Y Register)

Shifts

  • ASL (Arithmetic Shift Left)
  • LSR (Logical Shift Right)
  • ROL (Rotate Left)
  • ROR (Rotate Right)

Logical

  • AND (Logical AND)
  • ORA (Logical Inclusive OR)
  • EOR (Exclusive OR)
  • BIT (Bit Test)

Control

  • JMP (Jump)
  • JSR (Jump to Subroutine)
  • RTS (Return from Subroutine)
  • RTI (Return from Interrupt)

Branches

  • BCC (Branch if Carry Clear)
  • BCS (Branch if Carry Set)
  • BEQ (Branch if Equal)
  • BMI (Branch if Minus)
  • BNE (Branch if Not Equal)
  • BPL (Branch if Plus)
  • BVC (Branch if Overflow Clear)
  • BVS (Branch if Overflow Set)

Status Flag Changes

  • CLC (Clear Carry Flag)
  • SEC (Set Carry Flag)
  • CLI (Clear Interrupt Disable)
  • SEI (Set Interrupt Disable)
  • CLV (Clear Overflow Flag)
  • CLD (Clear Decimal Mode)
  • SED (Set Decimal Mode)

System Functions

  • BRK (Force Interrupt)
  • NOP (No Operation)

Register Transfers

  • TAX (Transfer Accumulator to X)
  • TXA (Transfer X to Accumulator)
  • TAY (Transfer Accumulator to Y)
  • TYA (Transfer Y to Accumulator)
  • TSX (Transfer Stack Pointer to X)
  • TXS (Transfer X to Stack Pointer)

These instructions are the foundation of programming for the 6502 processor, which was widely used in early home computers and video game consoles.