all repos — mgba @ 6e3a9a95082d0dc6b563549bb2fd25cadf9645a2

mGBA Game Boy Advance Emulator

Fix writing to PC
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Apr 2013 01:57:04 -0700
commit

6e3a9a95082d0dc6b563549bb2fd25cadf9645a2

parent

68f2eed84d0290500f05a4b3973bb45adf330de7

2 files changed, 6 insertions(+), 1 deletions(-)

jump to
M src/arm.csrc/arm.c

@@ -122,6 +122,9 @@ #define ARM_COND_GT (!cpu->cpsr.z && !cpu->cpsr.n == !cpu->cpsr.v)

#define ARM_COND_LE (cpu->cpsr.z || !cpu->cpsr.n != !cpu->cpsr.v) #define ARM_COND_AL 1 +#define ARM_WRITE_PC \ + cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -cpu->instructionWidth) + cpu->instructionWidth + #define ARM_ADDITION_S(M, N, D) \ if (rd == ARM_PC && _ARMModeHasSPSR(cpu->cpsr.priv)) { \ cpu->cpsr = cpu->spsr; \

@@ -380,7 +383,8 @@

DEFINE_INSTRUCTION_ARM(B, \ int32_t offset = opcode << 8; \ offset >>= 6; \ - cpu->gprs[ARM_PC] += offset) + cpu->gprs[ARM_PC] += offset; \ + ARM_WRITE_PC;) DEFINE_INSTRUCTION_ARM(BL,) DEFINE_INSTRUCTION_ARM(BX,)
M src/main.csrc/main.c

@@ -11,6 +11,7 @@ int fd = open("test.rom", O_RDONLY);

GBALoadROM(&gba, fd); gba.cpu.gprs[ARM_PC] = 0x08000004; ARMStep(&gba.cpu); + ARMStep(&gba.cpu); GBADeinit(&gba); return 0;