mirror of https://github.com/mgba-emu/mgba.git
Add ability to run Thumb code
This commit is contained in:
parent
9a0d14645b
commit
7e5de27f43
|
@ -106,3 +106,10 @@ void ARMReset(struct ARMCore* cpu) {
|
||||||
cpu->board->reset(cpu->board);
|
cpu->board->reset(cpu->board);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ARMRun(struct ARMCore* cpu) {
|
||||||
|
if (cpu->executionMode) {
|
||||||
|
ThumbStep(cpu);
|
||||||
|
} else {
|
||||||
|
ARMStep(cpu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -116,4 +116,6 @@ void ARMAssociateBoard(struct ARMCore* cpu, struct ARMBoard* board);
|
||||||
void ARMReset(struct ARMCore* cpu);
|
void ARMReset(struct ARMCore* cpu);
|
||||||
void ARMSetPrivilegeMode(struct ARMCore*, enum PrivilegeMode);
|
void ARMSetPrivilegeMode(struct ARMCore*, enum PrivilegeMode);
|
||||||
|
|
||||||
|
void ARMRun(struct ARMCore* cpu);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
|
|
||||||
static const ThumbInstruction _thumbTable[0x400];
|
static const ThumbInstruction _thumbTable[0x400];
|
||||||
|
|
||||||
|
void ThumbStep(struct ARMCore* cpu) {
|
||||||
|
uint32_t address = cpu->gprs[ARM_PC];
|
||||||
|
cpu->gprs[ARM_PC] = address + WORD_SIZE_THUMB;
|
||||||
|
address -= WORD_SIZE_THUMB;
|
||||||
|
uint16_t opcode = ((uint16_t*) cpu->memory->activeRegion)[(address & cpu->memory->activeMask) >> 1];
|
||||||
|
ThumbInstruction instruction = _thumbTable[opcode >> 6];
|
||||||
|
instruction(cpu, opcode);
|
||||||
|
}
|
||||||
|
|
||||||
// Instruction definitions
|
// Instruction definitions
|
||||||
// Beware pre-processor insanity
|
// Beware pre-processor insanity
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ int main(int argc, char** argv) {
|
||||||
gba.memory.d.setActiveRegion(&gba.memory.d, gba.cpu.gprs[ARM_PC]);
|
gba.memory.d.setActiveRegion(&gba.memory.d, gba.cpu.gprs[ARM_PC]);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 1024 * 1024 * 16; ++i) {
|
for (i = 0; i < 1024 * 1024 * 16; ++i) {
|
||||||
ARMStep(&gba.cpu);
|
ARMRun(&gba.cpu);
|
||||||
}
|
}
|
||||||
GBADeinit(&gba);
|
GBADeinit(&gba);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Reference in New Issue