* src/pic16/gen.c (genSkipc): fixed semantics (execute branch
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 26 Mar 2005 17:49:18 +0000 (17:49 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 26 Mar 2005 17:49:18 +0000 (17:49 +0000)
  if condition == CARRY)
* (genCmp): adapted to new genSkipc semantics
* src/pic16/genutils.c (pic6_genCmp_special): removed side effect
  on rIfx (genCmp was broken)

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

ChangeLog
src/pic16/gen.c
src/pic16/genutils.c

index 6bd37ede3454b0c301e9e0062196f4f1fd7cf2c2..5f18c5f8edda2bc4da716c59aab8e445d9515c4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-03-26 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/gen.c (genSkipc): fixed semantics (execute branch
+         if condition == CARRY)
+       * (genCmp): adapted to new genSkipc semantics
+       * src/pic16/genutils.c (pic6_genCmp_special): removed side effect
+         on rIfx (genCmp was broken)
+
 2005-03-26 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * src/SDCCmain.c (setDefaultOptions, optionsTable[], parseCmdLine),
index aa092a06e6b7669a9a2ef64a0f5cda6e3925c602..3164667a94c7ea4a162468ce7802475107a2ca28 100644 (file)
@@ -4837,9 +4837,9 @@ static void genSkipc(resolvedIfx *rifx)
     return;
 
   if(rifx->condition)
-    emitSKPC;
-  else
     emitSKPNC;
+  else
+    emitSKPC;
 
   pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rifx->lbl->key));
   rifx->generated = 1;
@@ -5040,7 +5040,7 @@ static void genCmp (operand *left,operand *right,
     } // if
 
     // This fails for lit = 0xFF (unsigned) AND lit = 0x7F (signed),
-    // that's we handled it above.
+    // that's why we handled it above.
     lit++;
 
     dummy = left;
@@ -5144,7 +5144,7 @@ result_in_carry:
    * now CARRY contains the result of the comparison: *
    * SUBWF sets CARRY iff                             *
    * F-W >= 0 <==> F >= W <==> !(F < W)               *
-   * (F=left, W=right)
+   * (F=left, W=right)                                *
    ****************************************************/
 
   if (performedLt) {
@@ -5170,10 +5170,8 @@ correct_result_in_carry:
   } // if (result)
 
   // perform conditional jump
-  // genSkipc branches to rifx->label if (rifx->condition != CARRY)
   if (ifx) {
     //DEBUGpc ("generate control flow");
-    rIfx.condition ^= 1;
     genSkipc (&rIfx);
     ifx->generated = 1;
   } // if
index d227e0abc74f0266e1e5054c72a42b586e337b09..ccbc503f95cf39ca279f2531ca882c87717347b5 100644 (file)
@@ -500,13 +500,15 @@ int pic16_genCmp_special(operand *left, operand *right, operand *result,
   int offs=0;
   symbol *tmplbl;
   unsigned long lit;
-  int op, cmp_op=0;
+  int op, cmp_op=0, cond_pre;
 
     FENTRY;
     
     if(!(pic16_options.opt_flags & OF_OPTIMIZE_CMP))return 0;
 
     size = max(AOP_SIZE(left), AOP_SIZE(right));
+
+    cond_pre = rIfx->condition; // must restore old value on return with 0!!!
     
     if(!isAOP_REGlike(left)) {
       operand *dummy;
@@ -554,5 +556,6 @@ int pic16_genCmp_special(operand *left, operand *right, operand *result,
 
     }          /* */
       
+  rIfx->condition = cond_pre;
   return 0;
 }