copycat/src/main.rs

29 lines
1008 B
Rust

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
use copycat::memory::{Memory, KiB};
use copycat::processor::{Instruction, Processor};
use copycat::io::IoBus;
static BIOS_ROM: &[u8; 8 * KiB as usize] = include_bytes!("../roms/BIOS_IBM5150_24APR81_5700051_U33.BIN");
fn main() {
let mut mem = Memory::new(64 * KiB);
mem.add_tlb_entry(0xfe, BIOS_ROM.as_ptr().cast_mut().cast());
mem.add_tlb_entry(0xff, unsafe { BIOS_ROM.as_ptr().add(4 * KiB as usize) }.cast_mut().cast());
// mem.write(0xffff0, [0x90, 0x04, 0x69, 0xF4]);
let mut io = IoBus::default();
let mut cpu = Processor::default();
cpu.registers.dump();
while !cpu.halted {
let instr = Instruction::decode(&mem, &mut cpu.registers);
println!("{instr:?}");
cpu.exec(&mut mem, &mut io, &instr);
cpu.registers.dump();
}
}