Implement ROR
Jeffrey Pfau jeffrey@endrift.com
Thu, 25 Apr 2013 00:53:24 -0700
2 files changed,
13 insertions(+),
2 deletions(-)
M
src/arm/isa-inlines.h
→
src/arm/isa-inlines.h
@@ -45,7 +45,7 @@ #define ARM_COND_LE (cpu->cpsr.z || !cpu->cpsr.n != !cpu->cpsr.v)
#define ARM_COND_AL 1 #define ARM_SIGN(I) ((I) >> 31) -#define ARM_ROR(I, ROTATE) (((I) >> ROTATE) | (I << (32 - ROTATE))) +#define ARM_ROR(I, ROTATE) ((((uint32_t) (I)) >> ROTATE) | (I << (32 - ROTATE))) #define ARM_CARRY_FROM(M, N, D) ((ARM_SIGN((M) | (N))) && !(ARM_SIGN(D))) #define ARM_BORROW_FROM(M, N, D) (((uint32_t) (M)) >= ((uint32_t) (N)))
M
src/arm/isa-thumb.c
→
src/arm/isa-thumb.c
@@ -249,7 +249,18 @@ THUMB_NEUTRAL_S( , , cpu->gprs[rd]))
DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ADC, ARM_STUB) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(SBC, ARM_STUB) -DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ROR, ARM_STUB) +DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(ROR, + 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->gprs[rd] = ARM_ROR(cpu->gprs[rd], r4); + } else { + cpu->cpsr.c = ARM_SIGN(cpu->gprs[rd]); + } + } + THUMB_NEUTRAL_S( , , cpu->gprs[rd]);) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(TST, ARM_STUB) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(NEG, THUMB_SUBTRACTION(cpu->gprs[rd], 0, cpu->gprs[rn])) DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(CMP2, int32_t aluOut = cpu->gprs[rd] - cpu->gprs[rn]; THUMB_SUBTRACTION_S(cpu->gprs[rd], cpu->gprs[rn], aluOut))