From cf982746c214c56cb51a96558a1e40e1ebb524e2 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 26 Jan 2016 02:41:58 -0800 Subject: [PATCH] LR35902: Fix RET timing --- src/lr35902/isa-lr35902.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lr35902/isa-lr35902.c b/src/lr35902/isa-lr35902.c index 15b2d8ec1..a1804e400 100644 --- a/src/lr35902/isa-lr35902.c +++ b/src/lr35902/isa-lr35902.c @@ -100,11 +100,15 @@ DEFINE_INSTRUCTION_LR35902(CALLUpdateSPH, DEFINE_CONDITIONAL_INSTRUCTION_LR35902(CALL) +DEFINE_INSTRUCTION_LR35902(RETFinish, + cpu->sp += 2; /* TODO: Atomic incrementing? */ + cpu->executionState = LR35902_CORE_STALL;) + DEFINE_INSTRUCTION_LR35902(RETUpdateSPL, cpu->pc |= cpu->bus << 8; - cpu->sp += 2; /* TODO: Atomic incrementing? */ cpu->memory.setActiveRegion(cpu, cpu->pc); - cpu->executionState = LR35902_CORE_STALL;) + cpu->executionState = LR35902_CORE_OP2; + cpu->instruction = _LR35902InstructionRETFinish;) DEFINE_INSTRUCTION_LR35902(RETUpdateSPH, if (cpu->condition) {