Skip to contentSkip to conversation

target-mips: set carry bit correctly in DSPControl register

PATCH Applied Petar Jovanovic 2 participants 2 messages May 13, 2013 – May 19, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-mips: set carry bit correctly in DSPControl register

From: Petar Jovanovic <[email protected]>

First we need to clear the bit and then we set the given value. Instruction ADDSC sets the bit and instruction ADDWC uses this bit.

---
 target-mips/dsp_helper.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target-mips/dsp_helper.c +4 -3
index 9212789..e98bac8 100644
@@ -53,9 +53,10 @@ static inline void set_DSPControl_overflow_flag(uint32_t flag, int position,
     env->active_tc.DSPControl |= (target_ulong)flag << position;
 }
 
-static inline void set_DSPControl_carryflag(uint32_t flag, CPUMIPSState *env)
+static inline void set_DSPControl_carryflag(bool flag, CPUMIPSState *env)
 {
-    env->active_tc.DSPControl |= (target_ulong)flag << 13;
+    env->active_tc.DSPControl &= ~(1 << 13);
+    env->active_tc.DSPControl |= flag << 13;
 }
 
 static inline uint32_t get_DSPControl_carryflag(CPUMIPSState *env)
@@ -1266,7 +1267,7 @@ SUBUH_QB(subuh_r, 1);
 target_ulong helper_addsc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
 {
     uint64_t temp, tempRs, tempRt;
-    int32_t flag;
+    bool flag;
 
     tempRs = (uint64_t)rs & MIPSDSP_LLO;
     tempRt = (uint64_t)rt & MIPSDSP_LLO;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 28 lines · Petar Jovanovic

From: Petar Jovanovic <[email protected]>

First we need to clear the bit and then we set the given value. Instruction ADDSC sets the bit and instruction ADDWC uses this bit.

---
 target-mips/dsp_helper.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target-mips/dsp_helper.c +3 -2
index 9212789..e98bac8 100644
@@ -53,9 +53,10 @@ static inline void set_DSPControl_overflow_flag(uint32_t flag, int position,
     env->active_tc.DSPControl |= (target_ulong)flag << position;
 }
 
-static inline void set_DSPControl_carryflag(uint32_t flag, CPUMIPSState *env)
+static inline void set_DSPControl_carryflag(bool flag, CPUMIPSState *env)
 {
-    env->active_tc.DSPControl |= (target_ulong)flag << 13;
+    env->active_tc.DSPControl &= ~(1 << 13);
+    env->active_tc.DSPControl |= flag << 13;
 }
 
 static inline uint32_t get_DSPControl_carryflag(CPUMIPSState *env)

target-mips/dsp_helper.c SUBUH_QB(subuh_r, 1); · line 1273

Quoted 8 lines
target-mips/dsp_helper.c +1 -1
@@ -1266,7 +1267,7 @@ SUBUH_QB(subuh_r, 1);
 target_ulong helper_addsc(target_ulong rs, target_ulong rt, CPUMIPSState *env)
 {
     uint64_t temp, tempRs, tempRt;
-    int32_t flag;
+    bool flag;
 
     tempRs = (uint64_t)rs & MIPSDSP_LLO;
     tempRt = (uint64_t)rt & MIPSDSP_LLO;

Thanks, applied.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net