* src/z80/gen.c (genMult): handle single byte result product
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 29 Jan 2004 06:36:41 +0000 (06:36 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 29 Jan 2004 06:36:41 +0000 (06:36 +0000)
* src/SDCCopt.c (killDeadCode): never convert ADDRESS_OF iCode to
DUMMY_READ_VOLATILE (fixed bug #886367)

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

ChangeLog
src/SDCCopt.c
src/z80/gen.c

index cd8360335977dddb71fbf1a546c20794e974da1e..b3453cdc1e55f82e23d5513ae33659f199d539f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-01-27 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/z80/gen.c (genMult): handle single byte result product
+       * src/SDCCopt.c (killDeadCode): never convert ADDRESS_OF iCode to
+       DUMMY_READ_VOLATILE (fixed bug #886367)
+
 2004-01-27 Bernhard Held <bernhard AT bernhardheld.de>
 
        * support/regression/tests/libmullong.c: fixed logic, on little endian
 2004-01-27 Bernhard Held <bernhard AT bernhardheld.de>
 
        * support/regression/tests/libmullong.c: fixed logic, on little endian
index 05eab6f518d451b39e92f169410e71a509474135..8ae80be05507bd2c481aa4d08c117b8dbaff05db 100644 (file)
@@ -878,7 +878,10 @@ killDeadCode (eBBlock ** ebbs, int count)
                  bool volRight = IS_SYMOP (IC_RIGHT (ic)) 
                                  && isOperandVolatile (IC_RIGHT (ic), FALSE);
 
                  bool volRight = IS_SYMOP (IC_RIGHT (ic)) 
                                  && isOperandVolatile (IC_RIGHT (ic), FALSE);
 
-                 
+                 /* a dead address-of operation should die, even if volatile */
+                 if (ic->op == ADDRESS_OF)
+                   volLeft = FALSE;
+
                  if (ic->next && ic->seqPoint == ic->next->seqPoint
                      && (ic->next->op == '+' || ic->next->op == '-'))
                    {
                  if (ic->next && ic->seqPoint == ic->next->seqPoint
                      && (ic->next->op == '+' || ic->next->op == '-'))
                    {
index cd669c7c359f3741344515ea5947182b254badd1..281dc7baf33604390278b63dfe7b4cc5a983d4eb 100644 (file)
@@ -4042,11 +4042,14 @@ genMult (iCode * ic)
   int count, i;
   /* If true then the final operation should be a subtract */
   bool active = FALSE;
   int count, i;
   /* If true then the final operation should be a subtract */
   bool active = FALSE;
+  bool byteResult;
 
   /* Shouldn't occur - all done through function calls */
   aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
   aopOp (IC_RIGHT (ic), ic, FALSE, FALSE);
   aopOp (IC_RESULT (ic), ic, TRUE, FALSE);
 
   /* Shouldn't occur - all done through function calls */
   aopOp (IC_LEFT (ic), ic, FALSE, FALSE);
   aopOp (IC_RIGHT (ic), ic, FALSE, FALSE);
   aopOp (IC_RESULT (ic), ic, TRUE, FALSE);
+  
+  byteResult =  (AOP_SIZE (IC_RESULT (ic)) == 1);
 
   if (AOP_SIZE (IC_LEFT (ic)) > 2 ||
       AOP_SIZE (IC_RIGHT (ic)) > 2 ||
 
   if (AOP_SIZE (IC_LEFT (ic)) > 2 ||
       AOP_SIZE (IC_RIGHT (ic)) > 2 ||
@@ -4077,10 +4080,13 @@ genMult (iCode * ic)
   if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic)))))
     {
       emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
   if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic)))))
     {
       emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
-      emit2 ("ld a,e");
-      emit2 ("rlc a");
-      emit2 ("sbc a,a");
-      emit2 ("ld d,a");
+      if (!byteResult)
+        {
+          emit2 ("ld a,e");
+          emit2 ("rlc a");
+          emit2 ("sbc a,a");
+          emit2 ("ld d,a");
+       }
     }
   else
     {
     }
   else
     {
@@ -4102,7 +4108,8 @@ genMult (iCode * ic)
           if (active == FALSE)
             {
               emit2 ("ld l,e");
           if (active == FALSE)
             {
               emit2 ("ld l,e");
-              emit2 ("ld h,d");
+              if (!byteResult)
+               emit2 ("ld h,d");
             }
           else
             {
             }
           else
             {
@@ -4121,7 +4128,10 @@ genMult (iCode * ic)
       _G.stack.pushedDE = FALSE;
     }
 
       _G.stack.pushedDE = FALSE;
     }
 
-  commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
+  if (byteResult)
+    aopPut (AOP (IC_RESULT (ic)), _pairs[PAIR_HL].l, 0);
+  else
+    commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);
 
   freeAsmop (IC_LEFT (ic), NULL, ic);
   freeAsmop (IC_RIGHT (ic), NULL, ic);
 
   freeAsmop (IC_LEFT (ic), NULL, ic);
   freeAsmop (IC_RIGHT (ic), NULL, ic);