LR35902: Implement HALT, RETI and CPL

This commit is contained in:
Jeffrey Pfau 2016-01-17 03:35:16 -08:00
parent 7a91b4a98a
commit 67050e44dd
2 changed files with 16 additions and 3 deletions

View File

@ -57,7 +57,7 @@
DECLARE_INSTRUCTION_LR35902(EMITTER, INCL), \
DECLARE_INSTRUCTION_LR35902(EMITTER, DECL), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDL_), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, CPL_), \
DECLARE_INSTRUCTION_LR35902(EMITTER, JRNC), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDSP), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDDHLA), \
@ -128,7 +128,7 @@
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_E), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_H), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_L), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, HALT), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_A), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_B), \
DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_C), \
@ -227,7 +227,7 @@
DECLARE_INSTRUCTION_LR35902(EMITTER, SUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, RETC), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, RETI), \
DECLARE_INSTRUCTION_LR35902(EMITTER, JPC), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
DECLARE_INSTRUCTION_LR35902(EMITTER, CALLC), \

View File

@ -121,6 +121,13 @@ DEFINE_INSTRUCTION_LR35902(RETUpdateSPH,
cpu->executionState = LR35902_CORE_MEMORY_LOAD; \
cpu->instruction = _LR35902InstructionRETUpdateSPH;)
DEFINE_INSTRUCTION_LR35902(RETI,
cpu->condition = true;
cpu->index = cpu->sp;
cpu->executionState = LR35902_CORE_MEMORY_LOAD;
cpu->irqh.setInterrupts(cpu, true);
cpu->instruction = _LR35902InstructionRETUpdateSPH;)
DEFINE_CONDITIONAL_INSTRUCTION_LR35902(RET)
#define DEFINE_AND_INSTRUCTION_LR35902(NAME, OPERAND) \
@ -520,6 +527,11 @@ DEFINE_INSTRUCTION_LR35902(CCF,
cpu->f.h = 0;
cpu->f.n = 0;)
DEFINE_INSTRUCTION_LR35902(CPL_,
cpu->a ^= 0xFF;
cpu->f.h = 1;
cpu->f.n = 1;)
#define DEFINE_POPPUSH_INSTRUCTION_LR35902(REG, HH, H, L) \
DEFINE_INSTRUCTION_LR35902(POP ## REG ## Delay, \
cpu-> L = cpu->bus; \
@ -554,6 +566,7 @@ DEFINE_POPPUSH_INSTRUCTION_LR35902(AF, A, a, f.packed);
DEFINE_INSTRUCTION_LR35902(DI, cpu->irqh.setInterrupts(cpu, false));
DEFINE_INSTRUCTION_LR35902(EI, cpu->irqh.setInterrupts(cpu, true));
DEFINE_INSTRUCTION_LR35902(HALT, cpu->cycles = cpu->nextEvent);
DEFINE_INSTRUCTION_LR35902(STUB, cpu->irqh.hitStub(cpu));