mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-06-04 18:45:27 +00:00
Added better error-reporting to the emulator.
This commit is contained in:
parent
ed7ca9a227
commit
890c2b7b79
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1813,7 +1813,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "svc16"
|
name = "svc16"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "svc16"
|
name = "svc16"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Jan Neuendorf"]
|
authors = ["Jan Neuendorf"]
|
||||||
description = "An emulator for a simple virtual computer"
|
description = "An emulator for a simple virtual computer"
|
||||||
|
@ -36,8 +36,8 @@ pub enum EngineError {
|
|||||||
#[error("Division by zero")]
|
#[error("Division by zero")]
|
||||||
ZeroDivision,
|
ZeroDivision,
|
||||||
|
|
||||||
#[error("Invalid instruction")]
|
#[error("Invalid instruction {0}")]
|
||||||
InvalidInstruction,
|
InvalidInstruction(u16),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Engine {
|
impl Engine {
|
||||||
@ -216,7 +216,7 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
self.advance_inst_ptr();
|
self.advance_inst_ptr();
|
||||||
}
|
}
|
||||||
_ => return Err(EngineError::InvalidInstruction),
|
_ => return Err(EngineError::InvalidInstruction(opcode)),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,11 @@ fn main() -> Result<()> {
|
|||||||
let engine_start = Instant::now();
|
let engine_start = Instant::now();
|
||||||
while !engine.wants_to_sync() && ipf <= cli.max_ipf && !paused {
|
while !engine.wants_to_sync() && ipf <= cli.max_ipf && !paused {
|
||||||
match engine.step() {
|
match engine.step() {
|
||||||
Err(_) => {
|
Err(e) => {
|
||||||
handle_event_loop_error(&elwt, "Invalid operation");
|
handle_event_loop_error(
|
||||||
|
&elwt,
|
||||||
|
format!("{} (after {} instructions)", e, ipf),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user