aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-10-06 21:47:52 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-10-06 21:48:13 +0200
commit9570d3b4a0b5e8d01a218743973feebd21115661 (patch)
tree2a44901256071146929ebb15e728221fd6b54233
parente71a73d0875c416507a3207bdec6fee145a79f68 (diff)
downloadtools.nes-9570d3b4a0b5e8d01a218743973feebd21115661.tar.gz
tools.nes-9570d3b4a0b5e8d01a218743973feebd21115661.zip
readrom: accept ranges for the --disassemble flag
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--crates/readrom/README.md15
-rw-r--r--crates/readrom/src/main.rs10
2 files changed, 20 insertions, 5 deletions
diff --git a/crates/readrom/README.md b/crates/readrom/README.md
index a1175fe..050b2d6 100644
--- a/crates/readrom/README.md
+++ b/crates/readrom/README.md
@@ -31,7 +31,19 @@ $A2F8: 24 20 bit $20
Note that hexadecimal values can also be formatted like this `0xa2fb` or simply
`a2fb`, whatever feels more convenient to use. In any case, they should be
-written as a 16-bit address.
+written as a 16-bit address. This flag also accepts ranges. Hence, we can also
+try the following:
+
+```
+$ readrom -d '$a2f8-$a300' jetpac.NTSC.nes
+# => output
+$A2F8: 24 20 bit $20
+$A2FA: 30 01 bmi $01
+$A2FC: 40 rti
+$A2FD: 48 pha
+$A2FE: 8A txa
+$A2FF: 48 pha
+```
All of that being said, poking for addresses can be tedious. That's why you can
also pass names that you already know. For that, you will need to also pass the
@@ -168,6 +180,7 @@ Then:
```
$ readrom -d nmi -n .nasm/ --mmc "kind=mmc3; prg_rom_mode=0; r6=0; r7=1" blink.nes
+# => output
$E138: 24 20 bit $20
$E13A: 10 2A bpl @next
$E13C: 48 pha
diff --git a/crates/readrom/src/main.rs b/crates/readrom/src/main.rs
index d3701d0..81b7e09 100644
--- a/crates/readrom/src/main.rs
+++ b/crates/readrom/src/main.rs
@@ -457,10 +457,12 @@ fn do_disassemble(
}
// If this is just a numeric value, take it as is.
- if let Some(address) = address
- && let Some(start) = parse_hex_value(address)
- {
- return print_range(bytes, start, None, memories, addresses, raw, None);
+ if let Some(address) = address {
+ let (start_addr, end_addr) = address.split_once('-').unwrap_or((address, ""));
+ if let Some(start) = parse_hex_value(start_addr) {
+ let end = parse_hex_value(end_addr);
+ return print_range(bytes, start, end, memories, addresses, raw, None);
+ }
}
// Otherwise, print the full range if possible.