Basic hello world, running the CPU

This commit is contained in:
2022-02-26 01:42:32 -06:00
parent 889f85f1dd
commit 81b805f338
5 changed files with 103 additions and 21 deletions
+24
View File
@@ -240,6 +240,30 @@ impl CPU {
self.pc + instruction.length as i32
}
}
pub fn tick(&mut self) {
if self.halted { return }
match self.fetch() {
Ok(instr) => {
//println!("Instr: {}", instr.opcode);
self.pc = self.execute(instr)
}
Err(invalidOpcode) => {
self.halted = true;
println!("Error: {}", invalidOpcode)
}
}
}
pub fn start(&mut self) {
self.halted = false
}
pub fn running(&self) -> bool {
!self.halted
}
}
impl Opcode {