Skip to content

Fix 5xy0 comparison & full font load (+ opcode tests)#2

Open
bvlik wants to merge 4 commits into
mainfrom
fix/opcode-5xy0-and-fontset
Open

Fix 5xy0 comparison & full font load (+ opcode tests)#2
bvlik wants to merge 4 commits into
mainfrom
fix/opcode-5xy0-and-fontset

Conversation

@bvlik

@bvlik bvlik commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes two emulation bugs in emul8/emul8.go and adds the first opcode test suite.

Bug 1 — 5xy0 comparison inverted

5xy0 ("skip next if Vx == Vy") was implemented with !=, i.e. it behaved like
9xy0. Any ROM relying on SE Vx, Vy would branch the wrong way. Fixed to ==.

Bug 2 — only 10 of 80 font bytes loaded

InitiateChip8 copied fontSet with for i := 0; i < 10, loading just glyphs 0 and
1. Fx29 addresses each glyph at Vx*5, so glyphs 2F pointed at zeroed memory and
rendered blank. Now loads the full 80-byte set.

Tests — emul8/emul8_test.go (standard testing, white-box)

Covers 6xnn/7xnn, 5xy0/9xy0, 8xy4 carry, 8xy5 borrow, Annn/Bnnn, Fx33
BCD, Fx55/Fx65 store-load, 2nnn/00EE call-return, and 3xnn/4xnn. Two are
regression tests pinning the fixes above. CI now runs go test ./... alongside build/vet.

How to verify

go test ./...

bvlik added 4 commits June 21, 2026 18:30
- 5xy0 skipped when Vx != Vy; the CHIP-8 spec skips when Vx == Vy (9xy0 is the
  'not equal' variant). Inverted comparison fixed.
- InitiateChip8 copied only 10 of the 80 font bytes, leaving glyphs 2..F blank
  while Fx29 addresses them at Vx*5. Load the whole fontSet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant