diff --git a/src/cpu.rs b/src/cpu.rs index 13697ac..d28d16b 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -88,6 +88,7 @@ impl SharpSM83 { Opcode::NOP => self.no_op(), Opcode::LDRI8(dest) => self.ld_r_n8(dest, bus), Opcode::Unimplemented(_) => {} + _ => {} } } diff --git a/src/opcode.rs b/src/opcode.rs index bd5e61f..c647953 100644 --- a/src/opcode.rs +++ b/src/opcode.rs @@ -22,6 +22,7 @@ pub enum Opcode { NOP, LDRI8(Dest8Bit), + LdR8HLAddr, Unimplemented(u8), } @@ -39,7 +40,11 @@ impl Opcode { (0b00000000, 0b00000110) => { let reg_num = (data & 0b00111000) >> 3; let register = Dest8Bit::from_u8(reg_num); - Opcode::LDRI8(register) + if register == Dest8Bit::HLAddr { + Opcode::LdR8HLAddr + } else { + Opcode::LDRI8(register) + } } _ => Opcode::Unimplemented(data), } @@ -125,6 +130,12 @@ mod tests { assert_eq!(opcode, Opcode::LDRI8(destination)); } + #[test] + fn should_return_ld_r8_addr_hl_given_00110110() { + let opcode = Opcode::decode(0b00110110); + assert_eq!(opcode, Opcode::LdR8HLAddr); + } + #[test] fn should_return_b_when_given_0() { let register = Dest8Bit::from_u8(0);