From e893d2b9f5b25eb34c8aa758a50163881fbc0dd1 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Tue, 29 Aug 2023 23:04:31 +0200 Subject: [PATCH] cpu/decoder - Use variable instead calculating twice --- cpu/decoder.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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);