all repos — mgba @ d90d7d189975a765a12c3cd1fef9508c2202874a

mGBA Game Boy Advance Emulator

Implement BL
Jeffrey Pfau jeffrey@endrift.com
Thu, 11 Apr 2013 03:14:09 -0700
commit

d90d7d189975a765a12c3cd1fef9508c2202874a

parent

133d574667b66c760897811f3e64a9f400184af1

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

jump to
M src/isa-thumb.csrc/isa-thumb.c

@@ -291,8 +291,17 @@

DEFINE_INSTRUCTION_THUMB(ILL, ARM_STUB) DEFINE_INSTRUCTION_THUMB(BKPT, ARM_STUB) DEFINE_INSTRUCTION_THUMB(B, ARM_STUB) -DEFINE_INSTRUCTION_THUMB(BL1, ARM_STUB) -DEFINE_INSTRUCTION_THUMB(BL2, ARM_STUB) +DEFINE_INSTRUCTION_THUMB(BL1, \ + int16_t immediate = (opcode & 0x07FF) << 7; \ + cpu->gprs[ARM_LR] = cpu->gprs[ARM_PC] + (((int32_t) immediate) << 4);) + +DEFINE_INSTRUCTION_THUMB(BL2, \ + uint16_t immediate = (opcode & 0x07FF) << 1; \ + uint32_t pc = cpu->gprs[ARM_PC]; \ + cpu->gprs[ARM_PC] = cpu->gprs[ARM_LR] + immediate; \ + cpu->gprs[ARM_LR] = pc - 1; \ + THUMB_WRITE_PC;) + DEFINE_INSTRUCTION_THUMB(BX, ARM_STUB) DEFINE_INSTRUCTION_THUMB(SWI, ARM_STUB)