all repos — mgba @ 6b07dd33af9bcd683ecce1cb24be4bc9378fd11d

mGBA Game Boy Advance Emulator

Implement ASR(1)
Jeffrey Pfau jeffrey@endrift.com
Tue, 16 Apr 2013 23:22:01 -0700
commit

6b07dd33af9bcd683ecce1cb24be4bc9378fd11d

parent

8c03c20019afb3a1099c9ea90d66d2c9f10aa6ac

1 files changed, 13 insertions(+), 1 deletions(-)

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

@@ -127,7 +127,19 @@ cpu->gprs[rd] = ((uint32_t) cpu->gprs[rm]) >> immediate;

} THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) -DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(ASR1, ARM_STUB) +DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(ASR1, + if (!immediate) { + cpu->cpsr.c = ARM_SIGN(cpu->gprs[rm]); + if (cpu->cpsr.c) { + cpu->gprs[rd] = 0xFFFFFFFF; + } else { + cpu->gprs[rd] = 0; + } + } else { + cpu->cpsr.c = cpu->gprs[rm] & (1 << (immediate - 1)); + cpu->gprs[rd] = cpu->gprs[rm] >> immediate; + } + THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LDR1, cpu->gprs[rd] = cpu->memory->load32(cpu->memory, cpu->gprs[rm] + immediate * 4)) DEFINE_IMMEDIATE_5_INSTRUCTION_THUMB(LDRB1, cpu->gprs[rd] = cpu->memory->loadU8(cpu->memory, cpu->gprs[rm] + immediate))