LR35902: Implement more LD A memory instructions
Jeffrey Pfau jeffrey@endrift.com
Sat, 16 Jan 2016 16:00:56 -0800
2 files changed,
26 insertions(+),
9 deletions(-)
M
src/lr35902/emitter-lr35902.h
→
src/lr35902/emitter-lr35902.h
@@ -20,23 +20,23 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, LDB_), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_BC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECBC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDC_), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDDE), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDDE_A), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCDE), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCD), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECD), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, LDD_), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, JR), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_DE), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECDE), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCE), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECE), \@@ -52,7 +52,7 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, LDH_), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, JRZ), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_IHL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECHL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECL), \@@ -68,7 +68,7 @@ DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_), \
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ DECLARE_INSTRUCTION_LR35902(EMITTER, JRC), \ DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ - DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \ + DECLARE_INSTRUCTION_LR35902(EMITTER, LDA_DHL), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECSP), \ DECLARE_INSTRUCTION_LR35902(EMITTER, INCA), \ DECLARE_INSTRUCTION_LR35902(EMITTER, DECA), \
M
src/lr35902/isa-lr35902.c
→
src/lr35902/isa-lr35902.c
@@ -207,12 +207,15 @@ DEFINE_INSTRUCTION_LR35902(LDHL_, \
cpu->executionState = LR35902_CORE_READ_PC; \ cpu->instruction = _LR35902InstructionLDHL_Bus;) +#define DEFINE_ALU_INSTRUCTION_LR35902_MEM(NAME, REG) \ + DEFINE_INSTRUCTION_LR35902(NAME ## REG, \ + cpu->executionState = LR35902_CORE_MEMORY_LOAD; \ + cpu->index = LR35902Read ## REG (cpu); \ + cpu->instruction = _LR35902Instruction ## NAME ## Bus;) + #define DEFINE_ALU_INSTRUCTION_LR35902(NAME) \ DEFINE_ ## NAME ## _INSTRUCTION_LR35902(Bus, cpu->bus); \ - DEFINE_INSTRUCTION_LR35902(NAME ## HL, \ - cpu->executionState = LR35902_CORE_MEMORY_LOAD; \ - cpu->index = LR35902ReadHL(cpu); \ - cpu->instruction = _LR35902Instruction ## NAME ## Bus;) \ + DEFINE_ALU_INSTRUCTION_LR35902_MEM(NAME, HL) \ DEFINE_INSTRUCTION_LR35902(NAME, \ cpu->executionState = LR35902_CORE_READ_PC; \ cpu->instruction = _LR35902Instruction ## NAME ## Bus;) \@@ -240,6 +243,8 @@ DEFINE_ALU_INSTRUCTION_LR35902(LDH_);
DEFINE_ALU_INSTRUCTION_LR35902(LDL_); DEFINE_ALU_INSTRUCTION_LR35902_NOHL(LDHL_); DEFINE_ALU_INSTRUCTION_LR35902(LDA_); +DEFINE_ALU_INSTRUCTION_LR35902_MEM(LDA_, BC); +DEFINE_ALU_INSTRUCTION_LR35902_MEM(LDA_, DE); DEFINE_INSTRUCTION_LR35902(LDBCDelay, \ cpu->c = cpu->bus; \@@ -304,6 +309,18 @@ LR35902WriteHL(cpu, cpu->index - 1); \
cpu->bus = cpu->a; \ cpu->executionState = LR35902_CORE_MEMORY_STORE; \ cpu->instruction = _LR35902InstructionNOP;) + +DEFINE_INSTRUCTION_LR35902(LDA_IHL, \ + cpu->index = LR35902ReadHL(cpu); \ + LR35902WriteHL(cpu, cpu->index + 1); \ + cpu->executionState = LR35902_CORE_MEMORY_LOAD; \ + cpu->instruction = _LR35902InstructionLDA_Bus;) + +DEFINE_INSTRUCTION_LR35902(LDA_DHL, \ + cpu->index = LR35902ReadHL(cpu); \ + LR35902WriteHL(cpu, cpu->index - 1); \ + cpu->executionState = LR35902_CORE_MEMORY_LOAD; \ + cpu->instruction = _LR35902InstructionLDA_Bus;) DEFINE_INSTRUCTION_LR35902(LDIAFinish, \ cpu->index |= cpu->bus << 8;