diff --git a/src/emulator/main.rs b/src/emulator/main.rs index 510ee7d..7c9fffb 100644 --- a/src/emulator/main.rs +++ b/src/emulator/main.rs @@ -116,20 +116,20 @@ fn tick(state: &mut EmulatorState) { 0x37 => state.cc.c = true, // STC 0x3f => state.cc.c = !state.cc.c, // CMC - 0x80..=0x87 => arithmetic::add_reg(register_from_num(instruction & 0xf), false, state), // ADD - 0x88..=0x8f => arithmetic::add_reg(register_from_num(instruction & 0xf), state.cc.c, state), // ADC + 0x80..=0x87 => arithmetic::add_reg(register_from_num(instruction & 0x7), false, state), // ADD + 0x88..=0x8f => arithmetic::add_reg(register_from_num(instruction & 0x7), state.cc.c, state), // ADC 0xc6 => arithmetic::add(next_byte(), false, state), // ADI 0xce => arithmetic::add(next_byte(), state.cc.c, state), // ACI - 0x90..=0x97 => arithmetic::sub_reg(register_from_num(instruction & 0xf), false, state), // SUB - 0x98..=0x9f => arithmetic::sub_reg(register_from_num(instruction & 0xf), state.cc.c, state), // SBB + 0x90..=0x97 => arithmetic::sub_reg(register_from_num(instruction & 0x7), false, state), // SUB + 0x98..=0x9f => arithmetic::sub_reg(register_from_num(instruction & 0x7), state.cc.c, state), // SBB 0xd6 => arithmetic::sub(next_byte(), false, state), // SUI 0xde => arithmetic::sub(next_byte(), state.cc.c, state), // SBI - 0xa0..=0xa7 => arithmetic::and_reg(register_from_num(instruction & 0xf), state), // ANA - 0xa8..=0xaf => arithmetic::xor_reg(register_from_num(instruction & 0xf), state), // XRA - 0xb0..=0xb7 => arithmetic::or_reg(register_from_num(instruction & 0xf), state), // ORA - 0xb8..=0xbf => arithmetic::cmp_reg(register_from_num(instruction & 0xf), state), // CMP + 0xa0..=0xa7 => arithmetic::and_reg(register_from_num(instruction & 0x7), state), // ANA + 0xa8..=0xaf => arithmetic::xor_reg(register_from_num(instruction & 0x7), state), // XRA + 0xb0..=0xb7 => arithmetic::or_reg(register_from_num(instruction & 0x7), state), // ORA + 0xb8..=0xbf => arithmetic::cmp_reg(register_from_num(instruction & 0x7), state), // CMP 0xe6 => arithmetic::and(next_byte(), state), // ANI 0xee => arithmetic::xor(next_byte(), state), // XRI 0xf6 => arithmetic::or(next_byte(), state), // ORI diff --git a/src/emulator/structs.rs b/src/emulator/structs.rs index 2a4171f..7248023 100644 --- a/src/emulator/structs.rs +++ b/src/emulator/structs.rs @@ -51,6 +51,7 @@ pub enum Register { } /// Returns a Register enum based on the input number 0..7 in the order B,C,D,E,H,L,M,A +#[track_caller] pub fn register_from_num(b: u8) -> Register { match b { 0 => Register::B,