Change run to not disassemble instruction when cpu is stopped and show stopped status
This commit is contained in:
parent
9cdbe2e071
commit
cdb0f1d8d7
16
src/main.rs
16
src/main.rs
@ -88,7 +88,6 @@ fn main() -> Result<(), anyhow::Error> {
|
|||||||
last_peek_format: (peek::Format::Hex, peek::Size::Byte),
|
last_peek_format: (peek::Format::Hex, peek::Size::Byte),
|
||||||
};
|
};
|
||||||
if args.run {
|
if args.run {
|
||||||
let mut out = String::new();
|
|
||||||
while !state.cpu.stopped {
|
while !state.cpu.stopped {
|
||||||
match state.cpu.step() {
|
match state.cpu.step() {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
@ -98,11 +97,7 @@ fn main() -> Result<(), anyhow::Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out += &format!("{}\n", state.cpu);
|
println!("CPU stopped at PC {:#x}\n{}", state.cpu.pc(), state.cpu);
|
||||||
let pc = state.cpu.pc();
|
|
||||||
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
|
|
||||||
out.pop(); // Remove trailing newline
|
|
||||||
println!("{out}");
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Repl::<_, anyhow::Error>::new(state)
|
Repl::<_, anyhow::Error>::new(state)
|
||||||
@ -239,9 +234,14 @@ fn main() -> Result<(), anyhow::Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if state.cpu.stopped {
|
||||||
|
out += &format!("CPU stopped at PC {:#x}\n", state.cpu.pc());
|
||||||
|
}
|
||||||
out += &format!("{}\n", state.cpu);
|
out += &format!("{}\n", state.cpu);
|
||||||
let pc = state.cpu.pc();
|
if !state.cpu.stopped {
|
||||||
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
|
let pc = state.cpu.pc();
|
||||||
|
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
|
||||||
|
}
|
||||||
out.pop(); // Remove trailing newline
|
out.pop(); // Remove trailing newline
|
||||||
Ok(Some(out))
|
Ok(Some(out))
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user