top level:
[deliverable/binutils-gdb.git] / sim / mips / dsp.igen
index 9c39b7160fd0a5d779bdda059d2be47b42a8db9a..0b337cc001cf7d3a1082bb544b6d40a32b9d91c9 100644 (file)
     h0 = (signed64)h1 + (signed64)h2;
   else // SUB
     h0 = (signed64)h1 - (signed64)h2;
-  if (((h0 & 0x100000000) >> 1) != (h0 & 0x80000000))
+  if (((h0 & 0x100000000LL) >> 1) != (h0 & 0x80000000))
     {
       DSPCR |= DSPCR_OUFLAG4;
-      if (h0 & 0x100000000)
+      if (h0 & 0x100000000LL)
        h0 = 0x80000000;
       else
        h0 = 0x7fffffff;
        }
       else // right
        {
-         if (sat == 1 && shift != 0)
-           h0 += (1 << (shift - 1));
-         h0 = h0 >> shift;
+         if (sat == 1 && shift != 0 && (h0 & (1 << (shift-1))))
+           h0 = (h0 >> shift) + 1;
+         else
+           h0 = h0 >> shift;
        }
 
       result |= ((unsigned32)((unsigned16)h0) << i);
 {
   unsigned32 result = GPR[rt];
   signed32 h0 = (signed32)result;
-  if (shift != 0)
-    h0 += (1 << (shift - 1));
-  h0 = h0 >> shift;
+  if (shift != 0 && (h0 & (1 << (shift-1))))
+    h0 = (h0 >> shift) + 1;
+  else
+    h0 = h0 >> shift;
   GPR[rd] = EXTEND32 (h0);
 }
 
This page took 0.026323 seconds and 4 git commands to generate.