From b6f0f4416fda35db9e720dd6cde92c391ad175ee Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Tue, 29 Aug 2023 23:06:05 +0200 Subject: [PATCH] cpu/decoder - Implement ADD SP, e8 --- cpu/decoder.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cpu/decoder.cpp b/cpu/decoder.cpp index 640e714..0a599e0 100644 --- a/cpu/decoder.cpp +++ b/cpu/decoder.cpp @@ -455,6 +455,18 @@ void Cpu::executeInstruction() state.IME = IME_SCHEDULED; break; + case 0xE8: // ADD SP, e8 + u32 lhs = state.SP; + s32 rhs = (s8)readPC8(); + u32 low_add = (lhs & 0x0FFF) + (rhs & 0x0FFF); + state.halfcarry = (low_add & 0x1000); + u32 res32 = lhs + rhs; + state.carry = (res32 & 0x10000); + state.SP = (u16)res32; + state.subtract = false; + state.zero = false; + mcycles = 4; + default: panic("Unknown opcode 0x%x\n",op); }