summaryrefslogtreecommitdiff
path: root/src/core.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.rs')
-rw-r--r--src/core.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core.rs b/src/core.rs
index d5b254d..f46fd54 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -4,6 +4,8 @@
// This file is part of TRVE (https://gitea.taitep.se/taitep/trve)
// See LICENSE file in the project root for full license text.
+use std::fmt::format;
+
use crate::{
consts::{Addr, RegId, RegValue},
decode::Instruction,
@@ -29,17 +31,15 @@ impl Core {
pub fn run(&mut self) {
loop {
- let page = (self.pc / 4096) as usize;
- let offset = (self.pc % 4096 / 4) as u16;
if !self.pc.is_multiple_of(4) {
- self.throw_exception(ExceptionType::InstructionAccessMisaligned);
+ self.throw_exception(ExceptionType::InstructionAddressMisaligned);
break;
}
- let instr = match self.mem.read_word(page, offset) {
+ let instr = match self.mem.read_word(self.pc) {
Ok(i) => i,
- Err(_) => {
- self.throw_exception(ExceptionType::InstructionAccessFault);
+ Err(e) => {
+ self.throw_exception(e.to_exception_instr());
break;
}
};