* src/z80/peeph-z80.def: removed some peephole rules that don't
[fw/sdcc] / src / z80 / gen.c
index 00ee1a68ae2bac398f493743eda15a60f8be5630..281dc7baf33604390278b63dfe7b4cc5a983d4eb 100644 (file)
@@ -1684,15 +1684,9 @@ aopGet (asmop * aop, int offset, bool bit16)
       { /*.p.t.20030716 handling for i/o port read access for Z80 */
         if( aop->paged )
         { /* banked mode */
-          if( aop->bcInUse )  emit2( "push bc" );
-
-          emit2( "ld bc,#%s", aop->aopu.aop_dir );
-          emit2( "in a,(c)" );
-
-          if( aop->bcInUse )
-            emit2( "pop bc" );
-          else
-            spillPair (PAIR_BC);
+         /* reg A goes to address bits 15-8 during "in a,(x)" instruction */
+         emit2( "ld a,!msbimmeds", aop->aopu.aop_dir);
+         emit2( "in a,(!lsbimmeds)", aop->aopu.aop_dir);
         }
         else if( z80_opts.port_mode == 180 )
         { /* z180 in0/out0 mode */
@@ -4048,11 +4042,14 @@ genMult (iCode * ic)
   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);
+  
+  byteResult =  (AOP_SIZE (IC_RESULT (ic)) == 1);
 
   if (AOP_SIZE (IC_LEFT (ic)) > 2 ||
       AOP_SIZE (IC_RIGHT (ic)) > 2 ||
@@ -4083,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));
-      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
     {
@@ -4108,7 +4108,8 @@ genMult (iCode * ic)
           if (active == FALSE)
             {
               emit2 ("ld l,e");
-              emit2 ("ld h,d");
+              if (!byteResult)
+               emit2 ("ld h,d");
             }
           else
             {
@@ -4127,7 +4128,10 @@ genMult (iCode * ic)
       _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);
@@ -7251,23 +7255,44 @@ genReceive (iCode * ic)
 static void
 genDummyRead (iCode * ic)
 {
-  operand *right;
+  operand *op;
   int size, offset;
 
-  right = IC_RIGHT (ic);
-  aopOp (right, ic, FALSE, FALSE);
+  op = IC_RIGHT (ic);
+  if (op && IS_SYMOP (op))
+    {
+      aopOp (op, ic, FALSE, FALSE);
   
-  /* general case */
-  size = AOP_SIZE (right);
-  offset = 0;
+      /* general case */
+      size = AOP_SIZE (op);
+      offset = 0;
 
-  while (size--)
-    {
-      _moveA (aopGet (AOP (right), offset, FALSE));
-      offset++;
+      while (size--)
+       {
+         _moveA (aopGet (AOP (op), offset, FALSE));
+         offset++;
+       }
+
+      freeAsmop (op, NULL, ic);
     }
+  
+  op = IC_LEFT (ic);
+  if (op && IS_SYMOP (op))
+    {
+      aopOp (op, ic, FALSE, FALSE);
+  
+      /* general case */
+      size = AOP_SIZE (op);
+      offset = 0;
 
-  freeAsmop (right, NULL, ic);
+      while (size--)
+       {
+         _moveA (aopGet (AOP (op), offset, FALSE));
+         offset++;
+       }
+
+      freeAsmop (op, NULL, ic);
+    }
 }
 
 enum