Add ability to run Thumb code
Jeffrey Pfau jeffrey@endrift.com
Wed, 10 Apr 2013 23:34:50 -0700
4 files changed,
19 insertions(+),
1 deletions(-)
M
src/isa-thumb.c
→
src/isa-thumb.c
@@ -4,6 +4,15 @@ #include "isa-inlines.h"
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 // Beware pre-processor insanity
M
src/main.c
→
src/main.c
@@ -15,7 +15,7 @@ gba.cpu.gprs[ARM_PC] = 0x08000004;
gba.memory.d.setActiveRegion(&gba.memory.d, gba.cpu.gprs[ARM_PC]); int i; for (i = 0; i < 1024 * 1024 * 16; ++i) { - ARMStep(&gba.cpu); + ARMRun(&gba.cpu); } GBADeinit(&gba); close(fd);