LR35902: Implement LD SP, HL and LD HL, SP+r8
Jeffrey Pfau jeffrey@endrift.com
Wed, 20 Jan 2016 20:09:34 -0800
2 files changed,
19 insertions(+),
2 deletions(-)
M
src/lr35902/emitter-lr35902.h
→
src/lr35902/emitter-lr35902.h
@@ -258,8 +258,8 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, PUSHAF), \ DECLARE_INSTRUCTION_LR35902(EMITTER, OR), \ DECLARE_INSTRUCTION_LR35902(EMITTER, RST30), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_SP), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDSP_HL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDAI), \ DECLARE_INSTRUCTION_LR35902(EMITTER, EI), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
M
src/lr35902/isa-lr35902.c
→
src/lr35902/isa-lr35902.c
@@ -214,6 +214,23 @@ DEFINE_INSTRUCTION_LR35902(LDHL_, \
cpu->executionState = LR35902_CORE_READ_PC; \ cpu->instruction = _LR35902InstructionLDHL_Bus;) +DEFINE_INSTRUCTION_LR35902(LDHL_SPDelay, + int diff = cpu->sp + (int8_t) cpu->bus; + LR35902WriteHL(cpu, diff); + cpu->executionState = LR35902_CORE_STALL; + cpu->f.z = 0; + cpu->f.n = 0; + cpu->f.c = !!(diff & 0xFFFF0000); + /* Figure out h flag*/) + +DEFINE_INSTRUCTION_LR35902(LDHL_SP, + cpu->executionState = LR35902_CORE_READ_PC; + cpu->instruction = _LR35902InstructionLDHL_SPDelay;) + +DEFINE_INSTRUCTION_LR35902(LDSP_HL, + cpu->sp = LR35902ReadHL(cpu); + cpu->executionState = LR35902_CORE_STALL;) + #define DEFINE_ALU_INSTRUCTION_LR35902_MEM(NAME, REG) \ DEFINE_INSTRUCTION_LR35902(NAME ## REG, \ cpu->executionState = LR35902_CORE_MEMORY_LOAD; \