NMI break-to-monitor support (freeze / inspect / resume)#37
Open
mbrukner wants to merge 1 commit into
Open
Conversation
Adds a hardware-NMI (RESTORE key + Foenix modifier) break-to-monitor
dispatch, letting a debugger freeze any running program, inspect it, and
resume it exactly.
hw_nmi (f256/jr.asm):
- Gate on the Foenix modifier; nested-break guard; decline a break into the
monitor itself (victim's slot 5 is the monitor's reserved RAM bank).
- Freeze the victim: save registers/SP/MMU/io, and save+clear the text and
color screen into reserved RAM banks.
- Copy the two-bank monitor image from flash into reserved RAM banks, map
both into the victim's LUT slots 4+5, and JSR the fixed break entry under
the victim's map so the monitor sees the victim's address space.
- On resume: restore the victim's slots, screen, io/MMU/SP/registers and
RTI back exactly. Resume is transparent to the victim's timers and a
free-running VIA IRQ:
* kernel.tick freezes the timebase while a break is active, so the
victim's frame timers do not expire and get freed underneath it;
* on resume, a stuck VIA T1 interrupt flag is cleared so the
edge-triggered interrupt controller latches the victim's next tick.
kernel/kernel.asm: tick checks platform.nmi_in_progress and skips the
timebase advance and delay.dispatch while a break handler is active; the
keyboard scan that follows in the frame IRQ still runs.
Hardware-verified on the F256K2.
Signed-off-by: Matthias Brukner <mbrukner@gmail.com>
mbrukner
force-pushed
the
pr/nmi-break-monitor
branch
from
July 17, 2026 12:41
5b4f936 to
0b69ed0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a hardware-NMI (RESTORE key + Foenix modifier) break-to-monitor dispatch, letting a debugger freeze any running program, inspect it, and resume it exactly. Two files change:
f256/jr.asm(thehw_nmidispatch, replacing the old debug stub) andkernel/kernel.asm(a one-line-guarded timebase freeze intick).What it does
hw_nmi:Resume transparency
Two subtleties are handled so resume is invisible to the victim:
tickchecksplatform.nmi_in_progressand skips the timebase advance +delay.dispatchwhile a break is active, so the victim's one-shot frame timers don't count down, expire, and get freed underneath it. The keyboard scan that followstickin the frame IRQ still runs, so the monitor keeps input.Testing
Hardware-verified on the F256K2: break into games (incl. VIA-timer- and kernel-timer-driven), DOS, and SuperBASIC; inspect and resume with no visible disturbance.
Notes
MaxPhysPageis lowered in that project).