KIM LED DEMO

A.C. Wright 6502
Binary Counter
Overview
Counts 0 through 255 in binary on the 8 breadboard LEDs, stepping about once every 500 ms. At $FF the count rolls back to $00 and repeats forever. Press ESC on the keypad to stop and return to the KC Monitor.
Program Details
Load address$0800 — Program RAM
Run address$0800 — press ▲ there
Program size18 bytes
LED register$9400 — 74HC373 latch
ZP counter$36 — free user zero page
Step delay~500 ms via SysDelay at $A075
Type-In Bytes — Load at $0800
ADDR +0 +1 +2 +3 +4 +5 +6 +7
$0800 6436 A536 8D00 94A9
$0808 32A2 0020 75A0 E636
$0810 80F0
How To Run
1 Press Reset — KC Monitor starts; the LCD shows the current address and byte.
2 Key in 0 8 0 0 on the hex pad to navigate to address $0800.
3 Press INS to enter data-edit mode.
4 Key each byte as two hex digits (e.g., 6 4 for $64), then press to step to the next address. Repeat for all 18 bytes.
5 Press INS to exit data-edit mode.
6 Key in 0 8 0 0 to return to the start address.
7 Press to run — the LEDs begin counting in binary!
8 Press ESC to stop and return to the monitor.
Assembly Source
; KIM LED Demo — Binary Counter ; Assemble at $0800 · Run: press ▲ at $0800 ; ; Equates ───────────────────────────────── LED = $9400 ; 74HC373 LED latch CNT = $36 ; zero-page counter (user ZP) ; ; Code ─────────────────────────────────── Start: stz CNT ; $64 36 — zero the counter Loop: lda CNT ; $A5 36 — load current count sta LED ; $8D 00 94 — display on LEDs lda #50 ; $A9 32 — 50 centiseconds ldx #0 ; $A2 00 — SysDelay high byte jsr $A075 ; $20 75 A0 — wait ~500 ms inc CNT ; $E6 36 — next value bra Loop ; $80 F0 — repeat forever
Notes
SysDelay — Kernal routine at $A075. Pass the centisecond count in A (low byte) and X (high byte) before the JSR. 50 cs ≈ 500 ms.
Reading the LEDs — bit 0 (value $01) is the rightmost LED; bit 7 (value $80) is the leftmost. Store $AA at $9400 in edit mode to see an alternating pattern.
Natural wrapINC CNT on a zero-page byte overflows cleanly from $FF back to $00 with no extra code needed.
Zero-page $36 is in the free user area ($36–$FF). No conflict with system variables.