* src/z80/gen.c (genLeftShift, genRightShift): fixed second part of
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 4 Dec 2004 06:12:32 +0000 (06:12 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 4 Dec 2004 06:12:32 +0000 (06:12 +0000)
  bug #1074377
* src/hc08/gen.c (genrshFour, shiftRLong, shiftLLong),
* src/mcs51/gen.c (shiftLLong): Fixed some shifting bugs Frieder found

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3599 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/hc08/gen.c
src/mcs51/gen.c
src/z80/gen.c

index 427fc6036b18dafd2af1dd0f13779759273d80fc..df234ac5c2bdd8519aa45ad5b77769a229c47f84 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-03 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/z80/gen.c (genLeftShift, genRightShift): fixed second part of
+         bug #1074377
+       * src/hc08/gen.c (genrshFour, shiftRLong, shiftLLong),
+       * src/mcs51/gen.c (shiftLLong): Fixed some shifting bugs Frieder found
+
 2004-12-02 Slade Rich <slade_rich AT users.sourceforge.net>
 
        * src/pic/pcode.c : fixed a problem where banksel was not being inserted.
index b144bf6001ec8810dd38d06bd1d4ff741656b2af..b101c25bf2a74debdb10ef0480aa9618c1c2b0e9 100644 (file)
@@ -6234,6 +6234,7 @@ shiftLLong (operand * left, operand * result, int offr)
       loadRegFromAop (hc08_reg_a, AOP (left), MSB24);
       rmwWithReg ("rol", hc08_reg_a);
       storeRegToAop (hc08_reg_a, AOP (result), offr+2);
+      storeConstToAop (zero, AOP (result), 0);
     }
 
   pullOrFreeReg (hc08_reg_x, needpulx);
@@ -6561,6 +6562,7 @@ shiftRLong (operand * left, int offl,
       else
         rmwWithReg ("lsr", hc08_reg_a);
       storeRegToAop (hc08_reg_a, AOP (result), MSB24);
+      storeRegSignToUpperAop (hc08_reg_a, AOP (result), MSB32, sign);
     }
 
   loadRegFromAop (hc08_reg_xa, AOP (left), offl);
@@ -6624,7 +6626,8 @@ genrshFour (operand * result, operand * left,
          loadRegFromConst (hc08_reg_a, zero);
          XAccRsh (shCount-8, sign);
          accopWithAop ("ora", AOP (result), 1);
-         storeRegToFullAop (hc08_reg_xa, AOP (result), 1);
+         storeRegToAop (hc08_reg_xa, AOP (result), 1);
+          storeRegSignToUpperAop (hc08_reg_x, AOP(result), 3, sign);
        }
     }
   else
index 97218f070241d2f0df1932673f844f14ac87d3b1..c5ffcd85822f7d037ea51414e10b5cd3056a5e3b 100644 (file)
@@ -7409,7 +7409,7 @@ shiftLLong (operand * left, operand * result, int offr)
 
   if (size >= MSB24 + offr)
     {
-      if (!(sameRegs (AOP (left), AOP (left)) && size >= MSB24 + offr && offr != LSB))
+      if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB24 + offr && offr != LSB))
         {
           l = aopGet (AOP (left), MSB24, FALSE, FALSE);
           MOVA (l);
index 95327d250feaeca29aa002c1e56d9584dcc0d3cc..97776615384011a6c91226dfa5db500cc144e05a 100644 (file)
@@ -6043,6 +6043,9 @@ genLeftShift (iCode * ic)
   aopOp (left, ic, FALSE, FALSE);
   aopOp (result, ic, FALSE, FALSE);
 
+  if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG)
+     _push (PAIR_AF);
+  
   /* now move the left to the result if they are not the
      same */
 
@@ -6064,6 +6067,9 @@ genLeftShift (iCode * ic)
   offset = 0;
   tlbl1 = newiTempLabel (NULL);
 
+  if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG)
+     _pop (PAIR_AF);
+  
   emit2 ("!shortjp !tlabel", tlbl1->key + 100);
   emitLabel (tlbl->key + 100);
   l = aopGet (AOP (result), offset, FALSE);
@@ -6317,6 +6323,9 @@ genRightShift (iCode * ic)
   aopOp (left, ic, FALSE, FALSE);
   aopOp (result, ic, FALSE, FALSE);
 
+  if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG)
+     _push (PAIR_AF);
+  
   /* now move the left to the result if they are not the
      same */
   if (!sameRegs (AOP (left), AOP (result)))
@@ -6336,6 +6345,9 @@ genRightShift (iCode * ic)
   tlbl1 = newiTempLabel (NULL);
   size = AOP_SIZE (result);
   offset = size - 1;
+  
+  if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG)
+     _pop (PAIR_AF);
 
   emit2 ("!shortjp !tlabel", tlbl1->key + 100);
   emitLabel (tlbl->key + 100);