diff --git a/src/main.rs b/src/main.rs index 3e67949..545ff9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -268,6 +268,13 @@ fn main() -> Result<(), anyhow::Error> { .help("The format to print the values in ()"), ) + .arg( + Arg::new("phys") + .long("phys") + .short('p') + .action(ArgAction::SetTrue) + .help("Peek physical memory instead of virtual memory"), + ) .arg(Arg::new("addr").required(true)) .about("Peek a memory address"), |args, state| { @@ -291,14 +298,27 @@ fn main() -> Result<(), anyhow::Error> { } let mut data = Vec::new(); let bus = state.cpu.bus_mut(); - for i in 0..count { - match size { - peek::Size::Byte => data.push(bus.read_byte(addr + i)? as u32), - peek::Size::Word => data.push(bus.read_word(addr + (i * 2))? as u32), - peek::Size::LongWord => data.push( - (bus.read_word(addr + (i * 4))? as u32) << 16 - | (bus.read_word(addr + (i * 4) + 2)? as u32), - ), + if args.get_flag("phys") { + for i in 0..count { + match size { + peek::Size::Byte => data.push(bus.read_byte_phys(addr + i)? as u32), + peek::Size::Word => data.push(bus.read_word_phys(addr + (i * 2))? as u32), + peek::Size::LongWord => data.push( + (bus.read_word_phys(addr + (i * 4))? as u32) << 16 + | (bus.read_word_phys(addr + (i * 4) + 2)? as u32), + ), + } + } + } else { + for i in 0..count { + match size { + peek::Size::Byte => data.push(bus.read_byte(addr + i)? as u32), + peek::Size::Word => data.push(bus.read_word(addr + (i * 2))? as u32), + peek::Size::LongWord => data.push( + (bus.read_word(addr + (i * 4))? as u32) << 16 + | (bus.read_word(addr + (i * 4) + 2)? as u32), + ), + } } } Ok(Some(