diff --git a/cpu/decoder.cpp b/cpu/decoder.cpp index 0578d4f..fe54a2e 100644 --- a/cpu/decoder.cpp +++ b/cpu/decoder.cpp @@ -86,12 +86,13 @@ void Cpu::executeInstruction() else if((op & 0xC0) == 0x80) // ADD, ADC, SUB, ABC, CP, AND, OR, XOR { AluOp aluop = (AluOp)((op >> 3) & 0x3); + u8 reg = op & 0x7; u8 rhs; - switch(op & 0x7) + switch(reg) { case 0x6: rhs = bus->read8(state.HL); mcycles = 2; break; - default: rhs = state.reg8(op & 0x7); break; + default: rhs = state.reg8(reg); break; } aluop8(aluop, rhs);