found a cause of a memory bug in emulator - fix is TODO (#6) - continued working on brainf interpreter. we really need better debugging tools tbh.

This commit is contained in:
2025-06-23 00:31:09 +01:00
parent b8091222a4
commit ddd0c27893
6 changed files with 125 additions and 62 deletions
+3
View File
@@ -72,6 +72,9 @@ impl MemoryUnit for MainStore {
fn read_word(&mut self, addr: u32) -> u32 {
let (block_addr, offset) = Self::segment_addr(addr);
println!("reading word from {block_addr:x?} + {offset}");
let block = self.mut_block(block_addr);
let mut bytes = [0; 4];
bytes[0] = block.data[offset as usize];
@@ -21,6 +21,10 @@ pub struct Processor {
pub dustbin: u32,
}
fn log(message: &str) {
println!("\x1b[32mINFO:\x1b[0m {message}");
}
#[allow(clippy::needless_pass_by_ref_mut)]
impl Processor {
#[must_use]
@@ -62,12 +66,10 @@ impl Processor {
// Decode and execute the instruction.
let instruction = Instruction::decode(val)?;
println!("Executing instruction: {instruction}");
log(&instruction.to_string());
instruction.execute(self);
println!("ok!");
Ok((addr, instruction))
}