From 2eeb6a864adbfbc930521ee8a0f9d9ba6bd4e7c4 Mon Sep 17 00:00:00 2001 From: tecodev Date: Sat, 26 Mar 2005 17:49:18 +0000 Subject: [PATCH] * 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) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3708 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 8 ++++++++ src/pic16/gen.c | 10 ++++------ src/pic16/genutils.c | 5 ++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bd37ede..5f18c5f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-03-26 Raphael Neider + + * 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 * src/SDCCmain.c (setDefaultOptions, optionsTable[], parseCmdLine), diff --git a/src/pic16/gen.c b/src/pic16/gen.c index aa092a06..3164667a 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -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 diff --git a/src/pic16/genutils.c b/src/pic16/genutils.c index d227e0ab..ccbc503f 100644 --- a/src/pic16/genutils.c +++ b/src/pic16/genutils.c @@ -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; } -- 2.30.2