all repos — mgba @ 19f9b72c33430863882a7ef8cddbbfbe0a37c491

mGBA Game Boy Advance Emulator

Fix CPSR C being written
Jeffrey Pfau jeffrey@endrift.com
Sun, 28 Apr 2013 00:06:13 -0700
commit

19f9b72c33430863882a7ef8cddbbfbe0a37c491

parent

682684cb6d8a3b45b37c62e720a7f38ded261a88

2 files changed, 8 insertions(+), 8 deletions(-)

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

@@ -234,7 +234,7 @@ _ARMReadCPSR(cpu); \

} else { \ cpu->cpsr.n = ARM_SIGN(D); \ cpu->cpsr.z = !(D); \ - cpu->cpsr.c = cpu->shifterCarryOut; \ + cpu->cpsr.c = !!cpu->shifterCarryOut; \ } #define ARM_NEUTRAL_HI_S(DLO, DHI) \
M src/arm/isa-thumb.csrc/arm/isa-thumb.c

@@ -112,7 +112,7 @@ 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->cpsr.c = (cpu->gprs[rm] >> (32 - immediate)) & 1; cpu->gprs[rd] = cpu->gprs[rm] << immediate; } THUMB_NEUTRAL_S( , , cpu->gprs[rd]);)

@@ -122,7 +122,7 @@ 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->cpsr.c = (cpu->gprs[rm] >> (immediate - 1)) & 1; cpu->gprs[rd] = ((uint32_t) cpu->gprs[rm]) >> immediate; } THUMB_NEUTRAL_S( , , cpu->gprs[rd]);)

@@ -136,7 +136,7 @@ } else {

cpu->gprs[rd] = 0; } } else { - cpu->cpsr.c = cpu->gprs[rm] & (1 << (immediate - 1)); + cpu->cpsr.c = (cpu->gprs[rm] >> (immediate - 1)) & 1; cpu->gprs[rd] = cpu->gprs[rm] >> immediate; } THUMB_NEUTRAL_S( , , cpu->gprs[rd]);)

@@ -200,7 +200,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(LSL2,

int rs = cpu->gprs[rn] & 0xFF; if (rs) { if (rs < 32) { - cpu->cpsr.c = cpu->gprs[rd] & (1 << (32 - rs)); + cpu->cpsr.c = (cpu->gprs[rd] >> (32 - rs)) & 1; cpu->gprs[rd] <<= rs; } else { if (rs > 32) {

@@ -217,7 +217,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(LSR2,

int rs = cpu->gprs[rn] & 0xFF; if (rs) { if (rs < 32) { - cpu->cpsr.c = cpu->gprs[rd] & (1 << (rs - 1)); + cpu->cpsr.c = (cpu->gprs[rd] >> (rs - 1)) & 1; cpu->gprs[rd] = (uint32_t) cpu->gprs[rd] >> rs; } else { if (rs > 32) {

@@ -234,7 +234,7 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ASR2,

int rs = cpu->gprs[rn] & 0xFF; if (rs) { if (rs < 32) { - cpu->cpsr.c = cpu->gprs[rd] & (1 << (rs - 1)); + cpu->cpsr.c = (cpu->gprs[rd] >> (rs - 1)) & 1; cpu->gprs[rd] >>= rs; } else { cpu->cpsr.c = ARM_SIGN(cpu->gprs[rd]);

@@ -263,7 +263,7 @@ int rs = cpu->gprs[rn] & 0xFF;

if (rs) { int r4 = rs & 0x1F; if (r4 > 0) { - cpu->cpsr.c = cpu->gprs[rd] & (1 << (r4 - 1)); + cpu->cpsr.c = (cpu->gprs[rd] >> (r4 - 1)) & 1; cpu->gprs[rd] = ARM_ROR(cpu->gprs[rd], r4); } else { cpu->cpsr.c = ARM_SIGN(cpu->gprs[rd]);