From fd2095abf7ea5773c699bee90a1b897ed0ded39f Mon Sep 17 00:00:00 2001 From: Benjamin Kyd Date: Wed, 14 Jun 2023 21:38:06 +0100 Subject: [PATCH] Program dumping is now 32bit based --- src/main.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2ecfb7e..55b2599 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ -use std::{cell::RefCell, rc::Rc}; use std::fs::File; use std::io::BufReader; use std::io::Read; +use std::{cell::RefCell, rc::Rc}; mod bus; mod cpu; @@ -12,7 +12,6 @@ mod rv32; use crate::bus::*; use crate::cpu::*; - struct VMRV32I { bus: Rc>, cpu: cpu::CPU, @@ -38,7 +37,9 @@ impl VMRV32I { // put program at the base of DRAM for i in 0..buffer.len() { - self.bus.borrow_mut().store_8(i as u32 + bus::DRAM_BASE, buffer[i]); + self.bus + .borrow_mut() + .store_8(i as u32 + bus::DRAM_BASE, buffer[i]); } println!("VM > Program loaded to 0x{:08x}", self.cpu.get_pc()); @@ -47,11 +48,13 @@ impl VMRV32I { fn dump_prog(&mut self) { println!("VM > Dumping program (virtual addresses)"); for i in 0..12 { - println!( - "VM > 0x{:08x}: 0x{:02x}", - i, - self.bus.borrow_mut().load_8(i + bus::DRAM_BASE) - ); + if i % 4 == 0 { + println!( + "VM > 0x{:08x}: 0x{:08x}", + i, + self.bus.borrow_mut().load_32(i + bus::DRAM_BASE) + ); + } } }