From 9570d3b4a0b5e8d01a218743973feebd21115661 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 6 Oct 2026 21:47:52 +0200 Subject: readrom: accept ranges for the --disassemble flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- crates/readrom/README.md | 15 ++++++++++++++- crates/readrom/src/main.rs | 10 ++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'crates') 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. -- cgit v1.2.3