Ensure shifter carry-out gets bits set right
Jeffrey Pfau jeffrey@endrift.com
Tue, 30 Apr 2013 21:02:56 -0700
1 files changed,
8 insertions(+),
8 deletions(-)
jump to
M
src/arm/isa-arm.c
→
src/arm/isa-arm.c
@@ -18,7 +18,7 @@ cpu->shifterOperand = cpu->gprs[rm];
cpu->shifterCarryOut = cpu->cpsr.c; } else { cpu->shifterOperand = cpu->gprs[rm] << immediate; - cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (32 - immediate)); + cpu->shifterCarryOut = (cpu->gprs[rm] >> (32 - immediate)) & 1; } }@@ -32,10 +32,10 @@ int rm = opcode & 0x0000000F;
int immediate = (opcode & 0x00000F80) >> 7; if (immediate) { cpu->shifterOperand = ((uint32_t) cpu->gprs[rm]) >> immediate; - cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1)); + cpu->shifterCarryOut = (cpu->gprs[rm] >> (immediate - 1)) & 1; } else { cpu->shifterOperand = 0; - cpu->shifterCarryOut = cpu->gprs[rm] & 0x80000000; + cpu->shifterCarryOut = ARM_SIGN(cpu->gprs[rm]); } }@@ -49,10 +49,10 @@ int rm = opcode & 0x0000000F;
int immediate = (opcode & 0x00000F80) >> 7; if (immediate) { cpu->shifterOperand = cpu->gprs[rm] >> immediate; - cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1)); + cpu->shifterCarryOut = (cpu->gprs[rm] >> (immediate - 1)) & 1; } else { - cpu->shifterCarryOut = cpu->gprs[rm] & 0x80000000; - cpu->shifterOperand = cpu->shifterCarryOut >> 31; // Ensure sign extension + cpu->shifterCarryOut = ARM_SIGN(cpu->gprs[rm]); + cpu->shifterOperand = cpu->shifterCarryOut; } }@@ -66,7 +66,7 @@ int rm = opcode & 0x0000000F;
int immediate = (opcode & 0x00000F80) >> 7; if (immediate) { cpu->shifterOperand = ARM_ROR(cpu->gprs[rm], immediate); - cpu->shifterCarryOut = cpu->gprs[rm] & (1 << (immediate - 1)); + cpu->shifterCarryOut = (cpu->gprs[rm] >> (immediate - 1)) & 1; } else { // RRX cpu->shifterOperand = (cpu->cpsr.c << 31) | (((uint32_t) cpu->gprs[rm]) >> 1);@@ -255,7 +255,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) \