mirror of https://github.com/mgba-emu/mgba.git
LR35902: Implement more LD forms
This commit is contained in:
parent
c3abc16a94
commit
0bfbc2079e
|
@ -11,8 +11,8 @@
|
|||
|
||||
#define DECLARE_LR35902_EMITTER_BLOCK(EMITTER) \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, NOP), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDBC), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDBC_A), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
|
@ -26,8 +26,8 @@
|
|||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDC_), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
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, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
|
@ -43,8 +43,8 @@
|
|||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDE_), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, JRNZ), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDIHLA), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
|
@ -59,12 +59,12 @@
|
|||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDL_), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, JRNC), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDSP), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDDHLA), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, LDHL_), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, JRC), \
|
||||
DECLARE_INSTRUCTION_LR35902(EMITTER, STUB), \
|
||||
|
|
|
@ -189,11 +189,6 @@ DEFINE_CONDITIONAL_INSTRUCTION_LR35902(RET)
|
|||
DEFINE_INSTRUCTION_LR35902(LDA_ ## NAME, \
|
||||
cpu->a = OPERAND;)
|
||||
|
||||
#define DEFINE_LD_INSTRUCTION_LR35902(NAME, OPERAND) \
|
||||
DEFINE_INSTRUCTION_LR35902(LD ## NAME, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLD ## NAME ## _Bus;)
|
||||
|
||||
#define DEFINE_ALU_INSTRUCTION_LR35902_NOHL(NAME) \
|
||||
DEFINE_ ## NAME ## _INSTRUCTION_LR35902(A, cpu->a); \
|
||||
DEFINE_ ## NAME ## _INSTRUCTION_LR35902(B, cpu->b); \
|
||||
|
@ -208,7 +203,7 @@ DEFINE_INSTRUCTION_LR35902(LDHL_Bus, \
|
|||
cpu->executionState = LR35902_CORE_MEMORY_MOVE_INDEX_STORE; \
|
||||
cpu->instruction = _LR35902InstructionNOP;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDHL, \
|
||||
DEFINE_INSTRUCTION_LR35902(LDHL_, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDHL_Bus;)
|
||||
|
||||
|
@ -246,6 +241,70 @@ DEFINE_ALU_INSTRUCTION_LR35902(LDL_);
|
|||
DEFINE_ALU_INSTRUCTION_LR35902_NOHL(LDHL_);
|
||||
DEFINE_ALU_INSTRUCTION_LR35902(LDA_);
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDBCDelay, \
|
||||
cpu->c = cpu->bus; \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDB_Bus;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDBC, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDBCDelay;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDBC_A, \
|
||||
cpu->index = LR35902ReadBC(cpu); \
|
||||
cpu->bus = cpu->a; \
|
||||
cpu->executionState = LR35902_CORE_MEMORY_MOVE_INDEX_STORE; \
|
||||
cpu->instruction = _LR35902InstructionNOP;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDDEDelay, \
|
||||
cpu->e = cpu->bus; \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDD_Bus;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDDE, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDDEDelay;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDDE_A, \
|
||||
cpu->index = LR35902ReadDE(cpu); \
|
||||
cpu->bus = cpu->a; \
|
||||
cpu->executionState = LR35902_CORE_MEMORY_MOVE_INDEX_STORE; \
|
||||
cpu->instruction = _LR35902InstructionNOP;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDHLDelay, \
|
||||
cpu->l = cpu->bus; \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDH_Bus;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDHL, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDHLDelay;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDSPFinish, cpu->sp |= cpu->bus << 8;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDSPDelay, \
|
||||
cpu->sp = cpu->bus; \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDSPFinish;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDSP, \
|
||||
cpu->executionState = LR35902_CORE_READ_PC; \
|
||||
cpu->instruction = _LR35902InstructionLDSPDelay;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDIHLA, \
|
||||
cpu->index = LR35902ReadHL(cpu); \
|
||||
LR35902WriteHL(cpu, cpu->index + 1); \
|
||||
cpu->bus = cpu->a; \
|
||||
cpu->executionState = LR35902_CORE_MEMORY_MOVE_INDEX_STORE; \
|
||||
cpu->instruction = _LR35902InstructionNOP;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDDHLA, \
|
||||
cpu->index = LR35902ReadHL(cpu); \
|
||||
LR35902WriteHL(cpu, cpu->index - 1); \
|
||||
cpu->bus = cpu->a; \
|
||||
cpu->executionState = LR35902_CORE_MEMORY_MOVE_INDEX_STORE; \
|
||||
cpu->instruction = _LR35902InstructionNOP;)
|
||||
|
||||
DEFINE_INSTRUCTION_LR35902(LDIAFinish, \
|
||||
cpu->index |= cpu->bus << 8;
|
||||
cpu->bus = cpu->a; \
|
||||
|
|
|
@ -138,6 +138,30 @@ static inline uint16_t LR35902ReadHL(struct LR35902Core* cpu) {
|
|||
return hl;
|
||||
}
|
||||
|
||||
static inline void LR35902WriteHL(struct LR35902Core* cpu, uint16_t hl) {
|
||||
STORE_16LE(hl, 0, &cpu->hl);
|
||||
}
|
||||
|
||||
static inline uint16_t LR35902ReadBC(struct LR35902Core* cpu) {
|
||||
uint16_t bc;
|
||||
LOAD_16LE(bc, 0, &cpu->bc);
|
||||
return bc;
|
||||
}
|
||||
|
||||
static inline void LR35902WriteBC(struct LR35902Core* cpu, uint16_t bc) {
|
||||
STORE_16LE(bc, 0, &cpu->bc);
|
||||
}
|
||||
|
||||
static inline uint16_t LR35902ReadDE(struct LR35902Core* cpu) {
|
||||
uint16_t de;
|
||||
LOAD_16LE(de, 0, &cpu->de);
|
||||
return de;
|
||||
}
|
||||
|
||||
static inline void LR35902WriteDE(struct LR35902Core* cpu, uint16_t de) {
|
||||
STORE_16LE(de, 0, &cpu->de);
|
||||
}
|
||||
|
||||
void LR35902Init(struct LR35902Core* cpu);
|
||||
void LR35902Deinit(struct LR35902Core* cpu);
|
||||
void LR35902SetComponents(struct LR35902Core* cpu, struct LR35902Component* master, int extra, struct LR35902Component** extras);
|
||||
|
|
Loading…
Reference in New Issue