all repos — mgba @ 36670b3fa2182f0f61071b613f60da03ff9a4fba

mGBA Game Boy Advance Emulator

Implement LSR(1) and reindent LSL(1)
Jeffrey Pfau jeffrey@endrift.com
Fri, 12 Apr 2013 22:24:35 -0700
commit

36670b3fa2182f0f61071b613f60da03ff9a4fba

parent

9ca65038ed03bb971e2a757acb41375e13889764

1 files changed, 17 insertions(+), 8 deletions(-)

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

@@ -90,15 +90,24 @@ #define DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(NAME, BODY) \

COUNT_5(DEFINE_IMMEDIATE_5_INSTRUCTION_EX_THUMB, NAME ## _, BODY) DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LSL1, \ - if (!immediate) { \ - cpu->gprs[rd] = cpu->gprs[rm]; \ - } else { \ - cpu->cpsr.c = cpu->gprs[rm] & (1 << (32 - immediate)); \ - cpu->gprs[rd] = cpu->gprs[rm] << immediate; \ - } \ - THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) + if (!immediate) { \ + cpu->gprs[rd] = cpu->gprs[rm]; \ + } else { \ + cpu->cpsr.c = cpu->gprs[rm] & (1 << (32 - immediate)); \ + cpu->gprs[rd] = cpu->gprs[rm] << immediate; \ + } \ + THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) + +DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LSR1, + if (!immediate) { \ + cpu->cpsr.c = ARM_SIGN(cpu->gprs[rm]); \ + cpu->gprs[rd] = 0; \ + } else { \ + cpu->cpsr.c = cpu->gprs[rm] & (1 << (immediate - 1)); \ + cpu->gprs[rd] = ((uint32_t) cpu->gprs[rm]) >> immediate; \ + } \ + THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) -DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LSR1, ARM_STUB) DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(ASR1, ARM_STUB) DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LDR1, cpu->gprs[rd] = cpu->memory->load32(cpu->memory, cpu->gprs[rm] + immediate * 4))