**** Lexi · MY JOURNEY INTO 6502 ASSEMBLY ****

64K RAM SYSTEM  38911 BASIC BYTES FREE

READY. – What I Still Remember After 30 Years

Before I start relearning 6502 assembly, I want an honest starting point. No cheating, no looking things up: what do I actually still know after 30 years?

The answer fits on a beer mat.

Memory #1: making things black

I remember that this turns the border and the screen black:

6502 ASSEMBLY
        lda #$00        ; 0 = black
        sta $d020       ; border colour
        sta $d021       ; background colour

$D020 is the border, $D021 the background. Both live in the VIC-II, the C64’s video chip. Load a colour into the accumulator, store it there, done. Every intro I ever coded started like this.

And a small “aha” right away: I don’t need a second lda #$00 for the background. After the first sta, the value is still sitting in the accumulator. Storing doesn’t empty it.

Memory #2: the screen lives at $0400

I remembered that the screen starts at $0400 and ends at $07FF. When I double-checked, it turned out to be almost right:

AddressWhat it is
$0400 – $07E7screen memory: 40 × 25 = 1000 chars
$07F8 – $07FFsprite pointers (not characters!)
$D800 – $DBE7colour memory, one colour per char

So the last few bytes I had in mind aren’t screen at all, they’re sprite pointers. Writing characters there wouldn’t show anything, but it would mess with sprites. Good to know before I break something.

Putting both together

With just these two memories, I can already write a tiny program: black screen, and an “H” in the top-left corner.

hello-h.asm
        * = $c000       ; start with SYS 49152

        lda #$00
        sta $d020       ; border black
        sta $d021       ; background black

        lda #$08        ; screen code for "H"
        sta $0400       ; top-left corner
        lda #$01        ; white
        sta $d800       ; colour of that character
        rts

Two things here I had completely forgotten:

  1. Screen codes are not PETSCII. In screen memory, “A” is $01, “B” is $02 … so “H” is $08, not $48.
  2. Colour memory matters. Every character on screen has its own colour in $D800 onwards. If I don’t set it, my “H” might end up in the same colour as the background, and I’d be staring at an empty screen wondering what went wrong.

Where I stand

That’s it. That’s everything. Two addresses, one half-correct memory map, and a strong feeling that I used to know so much more.

The next step: actually type this into an assembler and see if it runs, or crashes. I’ll report back either way.

If you remember more than I do (which is very likely), or if I already got something wrong here, please tell me in the comments!

Comments

LOADING
READY.