Skip to content

Fix NMI servicing reading the vector twice, and characterize JMP ($xxFF) behavior - #285

Merged
highbyte merged 3 commits into
masterfrom
fix/nmi-vector-double-read
Aug 12, 2026
Merged

Fix NMI servicing reading the vector twice, and characterize JMP ($xxFF) behavior#285
highbyte merged 3 commits into
masterfrom
fix/nmi-vector-double-read

Conversation

@highbyte

Copy link
Copy Markdown
Owner

Summary

Three small NMOS-baseline correctness items (groundwork for the upcoming CPU model architecture work):

  • Fix NMI double vector read. ProcessInterrupts fetched the NMI vector once purely for a debug log line, then ProcessHardwareNMI fetched it again — two real reads of $FFFA/$FFFB per serviced NMI where hardware performs one. The reads go through the current memory mapping, so the duplicate was observable by mapped handlers. The vector is now read exactly once; the log line runs after entry and reuses PC (the vector target).
  • Gate the NMI debug logging. The LogDebug call and its string.Join allocation now only run when debug logging is enabled, matching the existing unknown-opcode guard pattern.
  • Characterization test for JMP ($xxFF). The emulator currently resolves indirect JMP linearly (CMOS/65C02-style); real NMOS hardware has the page-wrap bug. A new test pins the current behavior and documents it as a known NMOS deviation, so the planned per-model fix lands as a visible, deliberate change instead of a silent one.

Tests

  • New: NMI_Servicing_Reads_Each_Vector_Byte_Exactly_Once (counting MapReaders on the vector bytes; fails against the previous code).
  • New: JMP_IND_With_Pointer_At_Page_End_Currently_Reads_Linearly_Known_NMOS_Deviation.
  • Full suite green: 1813 tests passed, 0 warnings, all 70 projects.

@sonarqubecloud

Copy link
Copy Markdown

@highbyte
highbyte merged commit 3edc7d6 into master Aug 12, 2026
10 checks passed
@highbyte
highbyte deleted the fix/nmi-vector-double-read branch August 12, 2026 08:53
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