(BIG CHANGE) memory handling has changed, MMIO is now a 2 level page table, misaligned access supported, addresses not internally split to page and offset immediately, all load/store instructions implemented. Might still have bugs

This commit is contained in:
2025-12-26 14:20:27 +01:00
parent 6d9efb7eb8
commit 528b519ce9
9 changed files with 478 additions and 456 deletions

View File

@@ -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;
}
};