aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-09-07 23:19:53 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-09-07 23:19:53 +0200
commite2a20dedc354c0b8d2e5253ffd4ac22d2b2898aa (patch)
tree4bfd91230b7834feb97d8a0cbb7b73ed10e5de29
parenta17bd972a99007099057d7901b88732b22d08270 (diff)
downloadtools.nes-e2a20dedc354c0b8d2e5253ffd4ac22d2b2898aa.tar.gz
tools.nes-e2a20dedc354c0b8d2e5253ffd4ac22d2b2898aa.zip
vnf: display also the break mark on report()
When reporting the final instruction, if that was actually a brk (and hence we stopped because of it), show the breaking mark as that could be relevant when debugging. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--lib/vnf/src/lib.rs10
-rwxr-xr-xscripts/test-e2e.sh6
-rw-r--r--tests/expected/runrom/halt.txt11
-rw-r--r--tests/runrom/halt.s20
4 files changed, 46 insertions, 1 deletions
diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs
index c9ae1a0..534fc1c 100644
--- a/lib/vnf/src/lib.rs
+++ b/lib/vnf/src/lib.rs
@@ -577,7 +577,15 @@ impl Machine {
}
if !self.active {
- println!("<end>");
+ if matches!(
+ self.current_instruction.identifier,
+ InstructionIdentifier::Brk
+ ) && let Some(brk) = self.status_register.break_mark
+ {
+ println!("<end> (break mark = ${:02X})", brk);
+ } else {
+ println!("<end>");
+ }
}
}
diff --git a/scripts/test-e2e.sh b/scripts/test-e2e.sh
index 2dce6fb..4df7128 100755
--- a/scripts/test-e2e.sh
+++ b/scripts/test-e2e.sh
@@ -288,6 +288,12 @@ echo "test: runrom => stack.nes"
diff tests/out/stack.txt tests/expected/runrom/stack.txt
exit_code=$((exit_code + $?))
+echo "test: runrom => halt.nes"
+./target/debug/nasm -Werror -o tests/out/halt.nes tests/runrom/halt.s
+./target/debug/runrom --dump-memory tests/out/halt.nes > tests/out/halt.txt
+diff tests/out/halt.txt tests/expected/runrom/halt.txt
+exit_code=$((exit_code + $?))
+
echo "test: runrom => cmp.nes"
./target/debug/nasm -Werror --asan -o tests/out/cmp.nes tests/runrom/cmp.s
./target/debug/runrom --function --dump-memory tests/out/cmp.nes > tests/out/cmp.txt
diff --git a/tests/expected/runrom/halt.txt b/tests/expected/runrom/halt.txt
new file mode 100644
index 0000000..8e4d83e
--- /dev/null
+++ b/tests/expected/runrom/halt.txt
@@ -0,0 +1,11 @@
+<start> PC: $8000, cycles: 7, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----I--
+ [STACK]: 02 80 00 00
+ [STACK]: 34 02 80 00 00
+brk PC: $8000, cycles: 14, registers: [a: $00, x: $00, y: $00, sp: $FA], status: --B-I--
+<end> (break mark = $42)
+
+== Memory dump ==
+
+[$2FB] = $34 [reads=0, writes=1]
+[$2FC] = $02 [reads=0, writes=1]
+[$2FD] = $80 [reads=0, writes=1]
diff --git a/tests/runrom/halt.s b/tests/runrom/halt.s
new file mode 100644
index 0000000..06d0bef
--- /dev/null
+++ b/tests/runrom/halt.s
@@ -0,0 +1,20 @@
+.segment "HEADER"
+ .byte 'N', 'E', 'S', $1A
+ .byte $02, $01
+ .byte $00
+ .byte $00
+
+.segment "CHARS"
+.byte 0
+
+.segment "VECTORS"
+ .addr reset, reset, reset
+
+.segment "CODE"
+;; asan:stack full
+
+.proc reset
+ brk
+ .byte $42
+ rts
+.endproc