implement error type and new ideas

This commit is contained in:
2026-08-17 21:32:01 +02:00
parent 34078089f1
commit c21c4af378
5 changed files with 246 additions and 135 deletions
+13 -5
View File
@@ -5,7 +5,10 @@ use crate::{
mem::Memory,
registers::Registers,
},
utils::access::is_address_error,
utils::{
access::is_address_error,
error::{Error, Severity, Type::UnhandledInstruction},
},
};
pub struct Interpreter {
@@ -59,16 +62,21 @@ impl Cpu for Interpreter {
Some(instr)
}
fn execute(&mut self, mem: &Memory) -> Result<u32, String> {
fn step(&mut self, mem: &Memory) -> Result<u32, Error> {
if let Some(instr) = self.fetch_then_advance(mem) {
self.decode(instr)?;
self.decode_execute(instr)?;
}
Ok(1)
}
fn decode(&mut self, instr: Instruction) -> Result<(), String> {
todo!("decode")
fn decode_execute(&mut self, instr: Instruction) -> Result<(), Error> {
match instr.opcode() {
_ => Err(Error {
severity: Severity::Error,
err_type: UnhandledInstruction(instr),
}),
}
}
fn reset(&mut self) {