fox32: Dump RAM if bad opcode
This commit is contained in:
parent
a8ff66c3a0
commit
7f796dd989
|
@ -268,6 +268,8 @@ impl Cpu {
|
|||
println!("{:#010X}: bad opcode {:#06X}", self.instruction_pointer, opcode);
|
||||
println!("size instr . cond dest src");
|
||||
println!("{:02b} {:06b} {:01b} {:03b} {:02b} {:02b}", size, instruction, empty, condition, destination, source);
|
||||
println!("dumping RAM");
|
||||
self.bus.memory.dump();
|
||||
panic!("bad opcode");
|
||||
}
|
||||
}
|
||||
|
@ -2852,4 +2854,4 @@ impl Instruction {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::error;
|
|||
use std::cell::UnsafeCell;
|
||||
use std::sync::Arc;
|
||||
use std::io::Write;
|
||||
use std::fs::File;
|
||||
|
||||
pub const MEMORY_RAM_SIZE: usize = 0x04000000; // 64 MiB
|
||||
pub const MEMORY_ROM_SIZE: usize = 0x00080000; // 512 KiB
|
||||
|
@ -54,6 +55,11 @@ impl Memory {
|
|||
pub fn ram(&self) -> &mut MemoryRam { &mut self.inner().ram }
|
||||
pub fn rom(&self) -> &mut MemoryRom { &mut self.inner().rom }
|
||||
|
||||
pub fn dump(&self) {
|
||||
let mut file = File::create("memory.dump").expect("failed to open memory dump file");
|
||||
file.write_all(self.ram()).expect("failed to write memory dump file");
|
||||
}
|
||||
|
||||
pub fn read_8(&self, address: u32) -> u8 {
|
||||
let address = address as usize;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user