* applied patch from bug-report #1076292,
authorvrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Dec 2004 00:16:11 +0000 (00:16 +0000)
committervrokas <vrokas@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 5 Dec 2004 00:16:11 +0000 (00:16 +0000)
* applied patches for genAnd and Goto-optimizations for Raphael
Neider,
* src/SDCCicode.c (printOperand): fixed !REGA source to compile and
dump a less iCode information,
* src/pic16/device.h (pic16_options_t): added field debgen,
* src/pic16/gen.h: added macros DUMP_FUNCTION_ENTRY,
DUMP_FUNCTION_EXIT, FENTRY, FENTRY2,
* src/pic16/gen.c (my_powof2): renamed to pic16_my_powof2 and made
puclic,
* (various functions): added macros FENTRY and FENTRY2 to functions,
to emit function prologue,
* (various functions): fixed indentation,
* (genNearPointerGet): fixed loading of FSR0,
* (genPackBits): applied patch from Raphael Neider to fix updating
of FSR0 and touching only the modified bits,
* src/pic16/genarith.c (various functions): added macros FENTRY to
emit function prologue in comments,
* src/pic16/pcode.h: added functions debugf2, debugf3,
* src/pic16/ralloc.c: partial fix for packForPush caused
segmentation fault,

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

ChangeLog
src/SDCCicode.c
src/pic16/device.h
src/pic16/gen.c
src/pic16/gen.h
src/pic16/genarith.c
src/pic16/genutils.c
src/pic16/main.c
src/pic16/pcode.c
src/pic16/pcode.h
src/pic16/ralloc.c

index 5dd7953917885de28b5120f18d98fa859cdfbe31..bb45d3f0e938466349f05db00527506e79449fe4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2004-12-05 Vangelis Rokas <vrokas AT otenet.gr>
+
+       * applied patch from bug-report #1076292,
+       * applied patches for genAnd and Goto-optimizations for Raphael
+       Neider,
+       * src/SDCCicode.c (printOperand): fixed !REGA source to compile and
+       dump a less iCode information,
+       * src/pic16/device.h (pic16_options_t): added field debgen,
+       * src/pic16/gen.h: added macros DUMP_FUNCTION_ENTRY,
+       DUMP_FUNCTION_EXIT, FENTRY, FENTRY2,
+       * src/pic16/gen.c (my_powof2): renamed to pic16_my_powof2 and made
+       puclic,
+       * (various functions): added macros FENTRY and FENTRY2 to functions,
+       to emit function prologue,
+       * (various functions): fixed indentation,
+       * (genNearPointerGet): fixed loading of FSR0,
+       * (genPackBits): applied patch from Raphael Neider to fix updating
+       of FSR0 and touching only the modified bits,
+       * src/pic16/genarith.c (various functions): added macros FENTRY to
+       emit function prologue in comments,
+       * src/pic16/pcode.h: added functions debugf2, debugf3,
+       * src/pic16/ralloc.c: partial fix for packForPush caused
+       segmentation fault,
+
 2004-12-04 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
        * src/mcs51/peeph.def: added 261.a,b (16 bit rotate) by Stas Sergeev
index 6e7dcb262fc52ef06ae40921282ef80f0e7cb759..c423c505196c0e5e1888cb2c2f7a59845cff81fd 100644 (file)
@@ -233,7 +233,7 @@ printOperand (operand * op, FILE * file)
 
     case SYMBOL:
 #define REGA 1
-#ifdef REGA
+#if REGA
       fprintf (file, "%s [k%d lr%d:%d so:%d]{ ia%d a2p%d re%d rm%d nos%d ru%d dp%d}",          /*{ar%d rm%d ru%d p%d a%d u%d i%d au%d k%d ks%d}"  , */
               (OP_SYMBOL (op)->rname[0] ? OP_SYMBOL (op)->rname : OP_SYMBOL (op)->name),
               op->key,
@@ -277,19 +277,53 @@ printOperand (operand * op, FILE * file)
            }
        }
 #else
-      fprintf (file, "%s", (OP_SYMBOL (op)->rname[0] ?
-                           OP_SYMBOL (op)->rname : OP_SYMBOL (op)->name));
+
+      fprintf (file, "%s ", (OP_SYMBOL (op)->rname[0] ? OP_SYMBOL (op)->rname : OP_SYMBOL (op)->name));
+
+#if 0
+
+      fprintf (file, "[lr%d:%d so:%d]",
+              OP_LIVEFROM (op), OP_LIVETO (op),
+              OP_SYMBOL (op)->stack
+       );
+#endif
+
+#if 1
+      {
+       fprintf (file, "{");
+       printTypeChain (operandType (op), file);
+       if (SPIL_LOC (op) && IS_ITEMP (op))
+         fprintf (file, "}{ sir@ %s", SPIL_LOC (op)->rname);
+       fprintf (file, "}");
+
+      }
+#endif
+
       /* if assigned to registers */
-      if (OP_SYMBOL (op)->nRegs && !OP_SYMBOL (op)->isspilt)
+      if (OP_SYMBOL (op)->nRegs)
        {
-         int i;
-         fprintf (file, "[");
-         for (i = 0; i < OP_SYMBOL (op)->nRegs; i++)
-           fprintf (file, "%s ", (OP_SYMBOL (op)->regs[i] ?
-                                  OP_SYMBOL (op)->regs[i]->name :
-                                  "err"));
-         fprintf (file, "]");
+         if (OP_SYMBOL (op)->isspilt)
+           {
+             if (!OP_SYMBOL (op)->remat)
+               if (OP_SYMBOL (op)->usl.spillLoc)
+                 fprintf (file, "[%s]", (OP_SYMBOL (op)->usl.spillLoc->rname[0] ?
+                                      OP_SYMBOL (op)->usl.spillLoc->rname :
+                                      OP_SYMBOL (op)->usl.spillLoc->name));
+               else
+                 fprintf (file, "[err]");
+             else
+               fprintf (file, "[remat]");
+           }
+         else
+           {
+             int i;
+             fprintf (file, "[");
+             for (i = 0; i < OP_SYMBOL (op)->nRegs; i++)
+               fprintf (file, "%s ", port->getRegName (OP_SYMBOL (op)->regs[i]));
+             fprintf (file, "]");
+           }
        }
+
 #endif
       break;
 
@@ -2095,8 +2129,8 @@ geniCodeMultiply (operand * left, operand * right, RESULT_TYPE resultType)
   if (p2 && !IS_FLOAT (letype)
       && !((resultType == RESULT_TYPE_INT) && (getSize (resType) != getSize (ltype))
            && (port->support.muldiv == 1))
-      && strcmp (port->target, "pic14") != 0  /* don't shift for pic */
-      && strcmp (port->target, "pic16") != 0)
+      && strcmp (port->target, "pic16") != 0  /* don't shift for pic */
+      && strcmp (port->target, "pic14") != 0)
     {
       if ((resultType == RESULT_TYPE_INT) && (getSize (resType) != getSize (ltype)))
        {
index 92cbe337eb5f8430622843ff2021b40455295b35..0251116ffbefe25ee61c120d2379f8b19413b862 100644 (file)
@@ -105,6 +105,7 @@ typedef struct {
   int ip_stack;
   unsigned long opt_flags;
   int gstack;
+  unsigned int debgen;
 } pic16_options_t;
 
 #define STACK_MODEL_SMALL      (pic16_options.stack_model == 0)
index 52b13c785be8be42df0c48c269032c19ef92a45e..fed12d129bf8bcf7a811ad40103805edbe973277 100644 (file)
@@ -183,7 +183,7 @@ static  pBlock *pb;
 /*   return y;                                                     */
 /* return -1;                                                      */
 /*-----------------------------------------------------------------*/
-static int my_powof2 (unsigned long num)
+int pic16_my_powof2 (unsigned long num)
 {
   if(num) {
     if( (num & (num-1)) == 0) {
@@ -287,6 +287,8 @@ void DEBUGpic16_emitcode (char *inst,char *fmt, ...)
 //     fprintf(stderr, "%s\n", lb);
 }
 
+
+
 void pic16_emitpLabel(int key)
 {
   pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(NULL,key+100+pic16_labelOffset));
@@ -551,8 +553,9 @@ static void genSetDPTR(int n)
 /*-----------------------------------------------------------------*/
 static void resolveIfx(resolvedIfx *resIfx, iCode *ifx)
 {
-
-  DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+  FENTRY2;
+  
+//  DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
 
   if(!resIfx) 
     return;
@@ -613,8 +616,8 @@ static asmop *aopForSym (iCode *ic, operand *op, bool result)
     asmop *aop;
     memmap *space= SPEC_OCLS(sym->etype);
 
-    DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
-
+    FENTRY2;
+    
     _G.resDirect = 0;  /* clear flag that instructs the result is loaded directly from aopForSym */
     
 //    sym = OP_SYMBOL(op);
@@ -858,11 +861,10 @@ static asmop *aopForRemat (operand *op) // x symbol *sym)
   int offset = 0;
   int viaimmd=0;
 
-
+    FENTRY2;
+    
        ic = sym->rematiCode;
 
-       DEBUGpic16_emitcode(";","%s %d",__FUNCTION__,__LINE__);
-       
        if(IS_OP_POINTER(op)) {
                DEBUGpic16_emitcode(";","%s %d IS_OP_POINTER",__FUNCTION__,__LINE__);
        }
@@ -1831,7 +1833,7 @@ pCodeOp *pic16_popGet (asmop *aop, int offset) //, bool bit16, bool dname)
   char *rs;
   pCodeOp *pcop;
 
-    //DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY2;
     /* offset is greater than
     size then zero */
 
@@ -2527,7 +2529,7 @@ static void pic16_genNot (iCode *ic)
   symbol *tlbl;
   int size;
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
   /* assign asmOps to operand & result */
   pic16_aopOp (IC_LEFT(ic),ic,FALSE);
   pic16_aopOp (IC_RESULT(ic),ic,TRUE);
@@ -2574,11 +2576,10 @@ static void pic16_genNot (iCode *ic)
 /*-----------------------------------------------------------------*/
 static void pic16_genCpl (iCode *ic)
 {
-    int offset = 0;
-    int size ;
-
+  int offset = 0;
+  int size ;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
     /* assign asmOps to operand & result */
     pic16_aopOp (IC_LEFT(ic),ic,FALSE);
     pic16_aopOp (IC_RESULT(ic),ic,TRUE);
@@ -2625,9 +2626,9 @@ release:
 /*-----------------------------------------------------------------*/
 static void genUminusFloat(operand *op,operand *result)
 {
-    int size ,offset =0 ;
-
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  int size ,offset =0 ;
+  
+    FENTRY;
     /* for this we just need to flip the 
     first it then copy the rest in place */
     size = AOP_SIZE(op);
@@ -2649,54 +2650,53 @@ static void genUminus (iCode *ic)
   int size, i;
   sym_link *optype, *rtype;
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       
-       /* assign asmops */
-       pic16_aopOp(IC_LEFT(ic),ic,FALSE);
-       pic16_aopOp(IC_RESULT(ic),ic,TRUE);
-
-       /* if both in bit space then special case */
-       if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY
-               && AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { 
+    FENTRY;    
+    
+    /* assign asmops */
+    pic16_aopOp(IC_LEFT(ic),ic,FALSE);
+    pic16_aopOp(IC_RESULT(ic),ic,TRUE);
 
-               pic16_emitpcode(POC_BCF,   pic16_popGet(AOP(IC_RESULT(ic)),0));
-               pic16_emitpcode(POC_BTFSS, pic16_popGet(AOP(IC_LEFT(ic)),0));
-               pic16_emitpcode(POC_BSF,   pic16_popGet(AOP(IC_RESULT(ic)),0));
-               
-               goto release; 
-       } 
+    /* if both in bit space then special case */
+    if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY
+      && AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { 
+        
+        pic16_emitpcode(POC_BCF,   pic16_popGet(AOP(IC_RESULT(ic)),0));
+        pic16_emitpcode(POC_BTFSS, pic16_popGet(AOP(IC_LEFT(ic)),0));
+        pic16_emitpcode(POC_BSF,   pic16_popGet(AOP(IC_RESULT(ic)),0));
+        goto release; 
+    } 
 
-       optype = operandType(IC_LEFT(ic));
-       rtype = operandType(IC_RESULT(ic));
+    optype = operandType(IC_LEFT(ic));
+    rtype = operandType(IC_RESULT(ic));
 
-       /* if float then do float stuff */
-       if (IS_FLOAT(optype)) {
-               genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
-               goto release;
-       }
+    /* if float then do float stuff */
+    if (IS_FLOAT(optype)) {
+      genUminusFloat(IC_LEFT(ic),IC_RESULT(ic));
+      goto release;
+    }
 
-       /* otherwise subtract from zero by taking the 2's complement */
-       size = AOP_SIZE(IC_LEFT(ic));
+    /* otherwise subtract from zero by taking the 2's complement */
+    size = AOP_SIZE(IC_LEFT(ic));
 
-       for(i=0; i<size; i++) {
-               if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
-                       pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)),i));
-               else {
-                       pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),i));
-                       pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),i));
-               }
-       }
+    for(i=0; i<size; i++) {
+      if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) )
+        pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)),i));
+      else {
+        pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),i));
+        pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),i));
+      }
+    }
 
-       pic16_emitpcode(POC_INCF,  pic16_popGet(AOP(IC_RESULT(ic)),0));
-       for(i=1; i<size; i++) {
-               emitSKPNZ;
-               pic16_emitpcode(POC_INCF,  pic16_popGet(AOP(IC_RESULT(ic)),i));
-       }
+    pic16_emitpcode(POC_INCF,  pic16_popGet(AOP(IC_RESULT(ic)),0));
+    for(i=1; i<size; i++) {
+      emitSKPNZ;
+      pic16_emitpcode(POC_INCF,  pic16_popGet(AOP(IC_RESULT(ic)),i));
+    }
 
 release:
-       /* release the aops */
-       pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
-       pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);    
+    /* release the aops */
+    pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
+    pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);    
 }
 
 #if 0
@@ -2845,7 +2845,8 @@ static void assignResultValue(operand * oper, int rescall)
   int size = AOP_SIZE(oper);
   int offset=0;
   
-    DEBUGpic16_emitcode ("; ***","%s  %d rescall:%d size:%d",__FUNCTION__,__LINE__,rescall,size); // patch 14
+    FENTRY2;
+//    DEBUGpic16_emitcode ("; ***","%s  %d rescall:%d size:%d",__FUNCTION__,__LINE__,rescall,size); // patch 14
     DEBUGpic16_pic16_AopType(__LINE__,oper,NULL,NULL);
 
     if(rescall) {
@@ -2934,6 +2935,7 @@ static void genIpush (iCode *ic)
 {
 //  int size, offset=0;
 
+  FENTRY;
   DEBUGpic16_emitcode ("; ***","%s  %d - WARNING no code generated",__FUNCTION__,__LINE__);
 
   if(ic->parmPush) {
@@ -2982,6 +2984,7 @@ static void genIpush (iCode *ic)
 /*-----------------------------------------------------------------*/
 static void genIpop (iCode *ic)
 {
+  FENTRY;
   DEBUGpic16_emitcode ("; ***","%s  %d - WARNING no code generated",__FUNCTION__,__LINE__);
 #if 0
     int size,offset ;
@@ -3123,7 +3126,7 @@ static void genCall (iCode *ic)
   int inwparam=0;
   char *fname;
   
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     ftype = OP_SYM_TYPE(IC_LEFT(ic));
     /* if caller saves & we have not saved then */
@@ -3292,7 +3295,7 @@ static void genPcall (iCode *ic)
   symbol *retlbl = newiTempLabel(NULL);
   pCodeOp *pcop_lbl = pic16_popGetLabel(retlbl->key);
   
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     ftype = OP_SYM_TYPE(IC_LEFT(ic));
     fntype = operandType( IC_LEFT(ic) )->next;
@@ -3448,6 +3451,7 @@ static void genFunction (iCode *ic)
   symbol *sym;
   sym_link *ftype;
   
+    FENTRY;
     DEBUGpic16_emitcode ("; ***","%s  %d curr label offset=%dprevious max_key=%d ",__FUNCTION__,__LINE__,pic16_labelOffset,max_key);
 
     pic16_labelOffset += (max_key+4);
@@ -3650,7 +3654,7 @@ static void genEndFunction (iCode *ic)
 {
   symbol *sym = OP_SYMBOL(IC_LEFT(ic));
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     if(IFFUNC_ISNAKED(sym->type)) {
       DEBUGpic16_emitcode("; ***", "_naked function, no epilogue");
@@ -3787,7 +3791,7 @@ static void genRet (iCode *ic)
   int size;
   operand *left;
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
        /* if we have no return value then
         * just generate the "ret" */
        
@@ -3907,15 +3911,14 @@ jumpret:
 /*-----------------------------------------------------------------*/
 static void genLabel (iCode *ic)
 {
+  FENTRY;
 
+  /* special case never generate */
+  if (IC_LABEL(ic) == entryLabel)
+    return ;
 
-    /* special case never generate */
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if (IC_LABEL(ic) == entryLabel)
-        return ;
-
-    pic16_emitpLabel(IC_LABEL(ic)->key);
-    pic16_emitcode("","_%05d_DS_:",(IC_LABEL(ic)->key+100 + pic16_labelOffset));
+  pic16_emitpLabel(IC_LABEL(ic)->key);
+//  pic16_emitcode("","_%05d_DS_:",(IC_LABEL(ic)->key+100 + pic16_labelOffset));
 }
 
 /*-----------------------------------------------------------------*/
@@ -3924,8 +3927,9 @@ static void genLabel (iCode *ic)
 //tsd
 static void genGoto (iCode *ic)
 {
+  FENTRY;
   pic16_emitpcode(POC_GOTO,pic16_popGetLabel(IC_LABEL(ic)->key));
-  pic16_emitcode ("goto","_%05d_DS_",(IC_LABEL(ic)->key+100)+pic16_labelOffset);
+//  pic16_emitcode ("goto","_%05d_DS_",(IC_LABEL(ic)->key+100)+pic16_labelOffset);
 }
 
 
@@ -3936,7 +3940,7 @@ static void genMultbits (operand *left,
                          operand *right, 
                          operand *result)
 {
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
 
   if(!pic16_sameRegs(AOP(result),AOP(right)))
     pic16_emitpcode(POC_BSF,  pic16_popGet(AOP(result),0));
@@ -3956,7 +3960,7 @@ static void genMultOneByte (operand *left,
                             operand *result)
 {
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
   DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
   DEBUGpic16_pic16_AopTypeSign(__LINE__,left,right,result);
 
@@ -3993,35 +3997,34 @@ static void genMultOneWord (operand *left,
                             operand *right,
                             operand *result)
 {
+  FENTRY;
+  DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
+  DEBUGpic16_pic16_AopTypeSign(__LINE__,left,right,result);
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
-       DEBUGpic16_pic16_AopTypeSign(__LINE__,left,right,result);
-
-       /* (if two literals, the value is computed before)
-        * if one literal, literal on the right */
-       if (AOP_TYPE(left) == AOP_LIT){
-         operand *t = right;
-               right = left;
-               left = t;
-       }
+  /* (if two literals, the value is computed before)
+   * if one literal, literal on the right */
+  if (AOP_TYPE(left) == AOP_LIT){
+    operand *t = right;
+    right = left;
+    left = t;
+  }
 
-       /* size is checked already == 2 */
-//     size = AOP_SIZE(result);
+  /* size is checked already == 2 */
+//  size = AOP_SIZE(result);
 
-       if (AOP_TYPE(right) == AOP_LIT) {
-               pic16_emitpcomment("multiply lit val:%s by variable %s and store in %s", 
-                                       pic16_aopGet(AOP(right),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(left),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(result),0,FALSE,FALSE));
-       } else {
-               pic16_emitpcomment("multiply variable :%s by variable %s and store in %s", 
-                                       pic16_aopGet(AOP(right),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(left),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(result),0,FALSE,FALSE));
-       }
+  if (AOP_TYPE(right) == AOP_LIT) {
+    pic16_emitpcomment("multiply lit val:%s by variable %s and store in %s", 
+      pic16_aopGet(AOP(right),0,FALSE,FALSE), 
+      pic16_aopGet(AOP(left),0,FALSE,FALSE), 
+      pic16_aopGet(AOP(result),0,FALSE,FALSE));
+  } else {
+    pic16_emitpcomment("multiply variable :%s by variable %s and store in %s", 
+      pic16_aopGet(AOP(right),0,FALSE,FALSE), 
+      pic16_aopGet(AOP(left),0,FALSE,FALSE), 
+      pic16_aopGet(AOP(result),0,FALSE,FALSE));
+  }
        
-       pic16_genMult16X16_16(left, right,result);
+  pic16_genMult16X16_16(left, right,result);
 }
 
 /*-----------------------------------------------------------------*/
@@ -4031,35 +4034,34 @@ static void genMultOneLong (operand *left,
                             operand *right,
                             operand *result)
 {
+  FENTRY;
+  DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
+  DEBUGpic16_pic16_AopTypeSign(__LINE__,left,right,result);
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
-       DEBUGpic16_pic16_AopTypeSign(__LINE__,left,right,result);
-
-       /* (if two literals, the value is computed before)
-        * if one literal, literal on the right */
-       if (AOP_TYPE(left) == AOP_LIT){
-         operand *t = right;
-               right = left;
-               left = t;
-       }
+  /* (if two literals, the value is computed before)
+   * if one literal, literal on the right */
+  if (AOP_TYPE(left) == AOP_LIT){
+    operand *t = right;
+    right = left;
+    left = t;
+  }
 
-       /* size is checked already == 4 */
-//     size = AOP_SIZE(result);
+  /* size is checked already == 4 */
+//  size = AOP_SIZE(result);
 
-       if (AOP_TYPE(right) == AOP_LIT) {
-               pic16_emitpcomment("multiply lit val:%s by variable %s and store in %s", 
-                                       pic16_aopGet(AOP(right),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(left),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(result),0,FALSE,FALSE));
-       } else {
-               pic16_emitpcomment("multiply variable :%s by variable %s and store in %s", 
-                                       pic16_aopGet(AOP(right),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(left),0,FALSE,FALSE), 
-                                       pic16_aopGet(AOP(result),0,FALSE,FALSE));
-       }
+  if (AOP_TYPE(right) == AOP_LIT) {
+    pic16_emitpcomment("multiply lit val:%s by variable %s and store in %s", 
+        pic16_aopGet(AOP(right),0,FALSE,FALSE), 
+        pic16_aopGet(AOP(left),0,FALSE,FALSE), 
+        pic16_aopGet(AOP(result),0,FALSE,FALSE));
+  } else {
+    pic16_emitpcomment("multiply variable :%s by variable %s and store in %s", 
+        pic16_aopGet(AOP(right),0,FALSE,FALSE), 
+        pic16_aopGet(AOP(left),0,FALSE,FALSE), 
+        pic16_aopGet(AOP(result),0,FALSE,FALSE));
+  }
        
-       pic16_genMult32X32_32(left, right,result);
+  pic16_genMult32X32_32(left, right,result);
 }
 
 
@@ -4073,7 +4075,7 @@ static void genMult (iCode *ic)
   operand *right = IC_RIGHT(ic);
   operand *result= IC_RESULT(ic);   
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
        /* assign the amsops */
        pic16_aopOp (left,ic,FALSE);
        pic16_aopOp (right,ic,FALSE);
@@ -4130,10 +4132,9 @@ static void genDivbits (operand *left,
                         operand *right, 
                         operand *result)
 {
+  char *l;
 
-    char *l;
-
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
     /* the result must be bit */    
     pic16_emitcode("mov","b,%s",pic16_aopGet(AOP(right),0,FALSE,FALSE));
     l = pic16_aopGet(AOP(left),0,FALSE,FALSE);
@@ -4152,10 +4153,10 @@ static void genDivOneByte (operand *left,
                            operand *right,
                            operand *result)
 {
-    sym_link *opetype = operandType(result);
-    char *l ;
-    symbol *lbl ;
-    int size,offset;
+  sym_link *opetype = operandType(result);
+  char *l ;
+  symbol *lbl ;
+  int size,offset;
 
        /* result = divident / divisor
         * - divident may be a register or a literal,
@@ -4165,7 +4166,8 @@ static void genDivOneByte (operand *left,
         * In addition we must handle signed and unsigned, which
         * result in 6 final different cases -- VR */
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
     size = AOP_SIZE(result) - 1;
     offset = 1;
     /* signed or unsigned */
@@ -4308,7 +4310,8 @@ static void genDiv (iCode *ic)
         * Division functions written here just in case someone
         * wants to inline and not use the support libraries -- VR */
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
     /* assign the amsops */
     pic16_aopOp (left,ic,FALSE);
     pic16_aopOp (right,ic,FALSE);
@@ -4344,9 +4347,11 @@ static void genModbits (operand *left,
                         operand *right, 
                         operand *result)
 {
+  char *l;
 
-    char *l;
-
+    FENTRY;  
+    
+    werror(W_POSSBUG2, __FILE__, __LINE__);
     /* the result must be bit */    
     pic16_emitcode("mov","b,%s",pic16_aopGet(AOP(right),0,FALSE,FALSE));
     l = pic16_aopGet(AOP(left),0,FALSE,FALSE);
@@ -4366,11 +4371,13 @@ static void genModOneByte (operand *left,
                            operand *right,
                            operand *result)
 {
-    sym_link *opetype = operandType(result);
-    char *l ;
-    symbol *lbl ;
+  sym_link *opetype = operandType(result);
+  char *l ;
+  symbol *lbl ;
+
+    FENTRY;
+    werror(W_POSSBUG2, __FILE__, __LINE__);
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     /* signed or unsigned */
     if (SPEC_USIGN(opetype)) {
         /* unsigned is easy */
@@ -4438,11 +4445,12 @@ static void genModOneByte (operand *left,
 /*-----------------------------------------------------------------*/
 static void genMod (iCode *ic)
 {
-    operand *left = IC_LEFT(ic);
-    operand *right = IC_RIGHT(ic);
-    operand *result= IC_RESULT(ic);  
+  operand *left = IC_LEFT(ic);
+  operand *right = IC_RIGHT(ic);
+  operand *result= IC_RESULT(ic);  
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
     /* assign the amsops */
     pic16_aopOp (left,ic,FALSE);
     pic16_aopOp (right,ic,FALSE);
@@ -4480,8 +4488,8 @@ release :
 */
 static void genIfxJump (iCode *ic, char *jval)
 {
-
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
+  
     /* if true label then we jump if condition
     supplied is true */
     if ( IC_TRUE(ic) ) {
@@ -4709,6 +4717,8 @@ static void genCmp (operand *left,operand *right,
   }
 */
 
+  FENTRY;
+  
   resolveIfx(&rFalseIfx,ifx);
   truelbl  = newiTempLabel(NULL);
   size = max(AOP_SIZE(left),AOP_SIZE(right));
@@ -5530,7 +5540,8 @@ static void genCmp (operand *left, operand *right,
   resolvedIfx rFalseIfx;
   symbol *falselbl, *tlbl;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
     DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
 
     resolveIfx(&rFalseIfx, ifx);
@@ -5783,9 +5794,9 @@ static void genCmp (operand *left,operand *right,
   int willCheckCarry=0;
   //  resolvedIfx rTrueIfx;
   symbol *truelbl;
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
 
+    FENTRY;
+  
   /* General concept:
    * subtract right from left if at the end the carry flag is set then we
    * know that left is greater than right */
@@ -6237,11 +6248,12 @@ check_carry:
 /*-----------------------------------------------------------------*/
 static void genCmpGt (iCode *ic, iCode *ifx)
 {
-    operand *left, *right, *result;
-    sym_link *letype , *retype;
-    int sign ;
+  operand *left, *right, *result;
+  sym_link *letype , *retype;
+  int sign ;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
     left = IC_LEFT(ic);
     right= IC_RIGHT(ic);
     result = IC_RESULT(ic);
@@ -6266,11 +6278,12 @@ static void genCmpGt (iCode *ic, iCode *ifx)
 /*-----------------------------------------------------------------*/
 static void genCmpLt (iCode *ic, iCode *ifx)
 {
-    operand *left, *right, *result;
-    sym_link *letype , *retype;
-    int sign ;
+  operand *left, *right, *result;
+  sym_link *letype , *retype;
+  int sign ;
+
+    FENTRY;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     left = IC_LEFT(ic);
     right= IC_RIGHT(ic);
     result = IC_RESULT(ic);
@@ -6639,15 +6652,17 @@ static void genCmpEq (iCode *ic, iCode *ifx)
   int generate_result = 0;
   int i=0;
 
+  FENTRY;
+  
   pic16_aopOp((left=IC_LEFT(ic)),ic,FALSE);
   pic16_aopOp((right=IC_RIGHT(ic)),ic,FALSE);
   pic16_aopOp((result=IC_RESULT(ic)),ic,TRUE);
  
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
   DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
 
   if( (AOP_TYPE(right) == AOP_CRY) || (AOP_TYPE(left) == AOP_CRY) )
     {
+      werror(W_POSSBUG2, __FILE__, __LINE__);
       DEBUGpic16_emitcode ("; ***","%s  %d -- ERROR",__FUNCTION__,__LINE__);
       fprintf(stderr, "%s  %d error - left/right CRY operands not supported\n",__FUNCTION__,__LINE__);
       goto release;
@@ -7062,8 +7077,9 @@ release:
 /*-----------------------------------------------------------------*/
 static iCode *ifxForOp ( operand *op, iCode *ic )
 {
+  FENTRY2;
+
     /* if true symbol then needs to be assigned */
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     if (IS_TRUE_SYMOP(op))
         return NULL ;
 
@@ -7137,10 +7153,11 @@ static iCode *ifxForOp ( operand *op, iCode *ic )
 /*-----------------------------------------------------------------*/
 static void genAndOp (iCode *ic)
 {
-    operand *left,*right, *result;
+  operand *left,*right, *result;
 /*     symbol *tlbl; */
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+
     /* note here that && operations that are in an
     if statement are taken away by backPatchLabels
     only those used in arthmetic operations remain */
@@ -7185,13 +7202,14 @@ static void genAndOp (iCode *ic)
 
 static void genOrOp (iCode *ic)
 {
-    operand *left,*right, *result;
-    symbol *tlbl;
+  operand *left,*right, *result;
+  symbol *tlbl;
+
+    FENTRY;  
 
-    /* note here that || operations that are in an
+  /* note here that || operations that are in an
     if statement are taken away by backPatchLabels
     only those used in arthmetic operations remain */
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     pic16_aopOp((left=IC_LEFT(ic)),ic,FALSE);
     pic16_aopOp((right=IC_RIGHT(ic)),ic,FALSE);
     pic16_aopOp((result=IC_RESULT(ic)),ic,FALSE);
@@ -7252,10 +7270,10 @@ static int isLiteralBit(unsigned long lit)
 /*-----------------------------------------------------------------*/
 static void continueIfTrue (iCode *ic)
 {
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(IC_TRUE(ic))
-        pic16_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
-    ic->generated = 1;
+  FENTRY;
+  if(IC_TRUE(ic))
+    pic16_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
+  ic->generated = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -7263,10 +7281,10 @@ static void continueIfTrue (iCode *ic)
 /*-----------------------------------------------------------------*/
 static void jumpIfTrue (iCode *ic)
 {
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(!IC_TRUE(ic))
-        pic16_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
-    ic->generated = 1;
+  FENTRY;
+  if(!IC_TRUE(ic))
+    pic16_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+  ic->generated = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -7274,20 +7292,19 @@ static void jumpIfTrue (iCode *ic)
 /*-----------------------------------------------------------------*/
 static void jmpTrueOrFalse (iCode *ic, symbol *tlbl)
 {
-    // ugly but optimized by peephole
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(IC_TRUE(ic)){
-        symbol *nlbl = newiTempLabel(NULL);
-        pic16_emitcode("sjmp","%05d_DS_",nlbl->key+100);                 
-        pic16_emitcode("","%05d_DS_:",tlbl->key+100);
-        pic16_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
-        pic16_emitcode("","%05d_DS_:",nlbl->key+100);
-    }
-    else{
-        pic16_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
-        pic16_emitcode("","%05d_DS_:",tlbl->key+100);
-    }
-    ic->generated = 1;
+  // ugly but optimized by peephole
+  FENTRY;
+  if(IC_TRUE(ic)){
+    symbol *nlbl = newiTempLabel(NULL);
+      pic16_emitcode("sjmp","%05d_DS_",nlbl->key+100);                 
+      pic16_emitcode("","%05d_DS_:",tlbl->key+100);
+      pic16_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
+      pic16_emitcode("","%05d_DS_:",nlbl->key+100);
+  } else {
+    pic16_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+    pic16_emitcode("","%05d_DS_:",tlbl->key+100);
+  }
+  ic->generated = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -7301,8 +7318,8 @@ static void genAnd (iCode *ic, iCode *ifx)
   int bytelit = 0;
   resolvedIfx rIfx;
 
-
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
+    
   pic16_aopOp((left = IC_LEFT(ic)),ic,FALSE);
   pic16_aopOp((right= IC_RIGHT(ic)),ic,FALSE);
   pic16_aopOp((result=IC_RESULT(ic)),ic,TRUE);
@@ -7518,7 +7535,7 @@ static void genAnd (iCode *ic, iCode *ifx)
 
        default:
          {
-           int p = my_powof2( (~lit) & 0xff );
+           int p = pic16_my_powof2( (~lit) & 0xff );
            if(p>=0) {
              /* only one bit is set in the literal, so use a bcf instruction */
 //           pic16_emitcode("bcf","%s,%d",pic16_aopGet(AOP(left),offset,FALSE,TRUE),p);
@@ -7822,7 +7839,7 @@ static void genOr (iCode *ic, iCode *ifx)
            /*  or'ing with 0 has no effect */
            continue;
          else {
-           int p = my_powof2(lit & 0xff);
+           int p = pic16_my_powof2(lit & 0xff);
            if(p>=0) {
              /* only one bit is set in the literal, so use a bsf instruction */
              pic16_emitpcode(POC_BSF,
@@ -9299,7 +9316,7 @@ static void genlshFour (operand *result, operand *left, int shCount)
 /*-----------------------------------------------------------------*/
 /* genLeftShiftLiteral - left shifting by known count              */
 /*-----------------------------------------------------------------*/
-static void genLeftShiftLiteral (operand *left,
+void pic16_genLeftShiftLiteral (operand *left,
                                  operand *right,
                                  operand *result,
                                  iCode *ic)
@@ -9307,7 +9324,8 @@ static void genLeftShiftLiteral (operand *left,
     int shCount = (int) floatFromVal (AOP(right)->aopu.aop_lit);
     int size;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d shCount:%d",__FUNCTION__,__LINE__,shCount);
+    FENTRY;
+    DEBUGpic16_emitcode ("; ***","shCount:%d", shCount);
     pic16_freeAsmop(right,NULL,ic,TRUE);
 
     pic16_aopOp(left,ic,FALSE);
@@ -9400,7 +9418,7 @@ static void genLeftShift (iCode *ic)
   /* if the shift count is known then do it 
      as efficiently as possible */
   if (AOP_TYPE(right) == AOP_LIT) {
-    genLeftShiftLiteral (left,right,result,ic);
+    pic16_genLeftShiftLiteral (left,right,result,ic);
     return ;
   }
 
@@ -9586,7 +9604,7 @@ static void genLeftShift (iCode *ic)
   /* if the shift count is known then do it 
      as efficiently as possible */
   if (AOP_TYPE(right) == AOP_LIT) {
-    genLeftShiftLiteral (left,right,result,ic);
+    pic16_genLeftShiftLiteral (left,right,result,ic);
     return ;
   }
 
@@ -10493,96 +10511,92 @@ static void genNearPointerGet (operand *left,
                               operand *result, 
                               iCode *ic)
 {
-    asmop *aop = NULL;
-    //regs *preg = NULL ;
-    sym_link *rtype, *retype;
-    sym_link *ltype = operandType(left);    
+  asmop *aop = NULL;
+  //regs *preg = NULL ;
+  sym_link *rtype, *retype;
+  sym_link *ltype = operandType(left);    
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       rtype = operandType(result);
-       retype= getSpec(rtype);
+    FENTRY;
     
-       pic16_aopOp(left,ic,FALSE);
+    rtype = operandType(result);
+    retype= getSpec(rtype);
+    
+    pic16_aopOp(left,ic,FALSE);
 
-//     pic16_DumpOp("(left)",left);
-//     pic16_DumpOp("(result)",result);
+//    pic16_DumpOp("(left)",left);
+//    pic16_DumpOp("(result)",result);
 
-       /* if left is rematerialisable and
-        * result is not bit variable type and
-        * the left is pointer to data space i.e
-        * lower 128 bytes of space */
-       if (AOP_TYPE(left) == AOP_PCODE
-               && !IS_BITFIELD(retype)
-               && DCL_TYPE(ltype) == POINTER) {
+    /* if left is rematerialisable and
+     * result is not bit variable type and
+     * the left is pointer to data space i.e
+     * lower 128 bytes of space */
+    
+    if (AOP_TYPE(left) == AOP_PCODE
+      && !IS_BITFIELD(retype)
+      && DCL_TYPE(ltype) == POINTER) {
 
-               genDataPointerGet (left,result,ic);
-               pic16_freeAsmop(left, NULL, ic, TRUE);
-         return ;
-       }
+        genDataPointerGet (left,result,ic);
+        pic16_freeAsmop(left, NULL, ic, TRUE);
+        return ;
+    }
     
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-       /* if the value is already in a pointer register
-        * then don't need anything more */
-       if (!AOP_INPREG(AOP(left))) {
-               /* otherwise get a free pointer register */
-               DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    /* if the value is already in a pointer register
+     * then don't need anything more */
+    if (!AOP_INPREG(AOP(left))) {
+      /* otherwise get a free pointer register */
+      DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
                
-               /* VR -- the whole concept is to load FSR0 with the address of the symbol */
-               if( (AOP_TYPE(left) == AOP_PCODE) 
-                       && ((AOP(left)->aopu.pcop->type == PO_IMMEDIATE)
-                               || (AOP(left)->aopu.pcop->type == PO_DIR))) // patch 10
-               {
-                       if(!IS_BITFIELD(retype))
-                               pic16_loadFSR0( left );  // patch 10
-               } else {
-                 if(!IS_BITFIELD(retype)) {
-                   // set up FSR0 with address from left
-                    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_fsr0l))); // patch 10
-                    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),1), pic16_popCopyReg(&pic16_pc_fsr0h))); // patch 10
-                  }
-               }
-       }
-//      else
-//     rname = pic16_aopGet(AOP(left),0,FALSE,FALSE);
+      /* VR -- the whole concept is to load FSR0 with the address of the symbol */
+      /* bitfields will be handled by genUnpackBits */
+      if(!IS_BITFIELD(retype)) {
+
+        if(is_LitAOp( AOP(left) )) {
+          pic16_loadFSR0( left );
+        } else {
+            // set up FSR0 with address from left
+            pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),0), pic16_popCopyReg(&pic16_pc_fsr0l))); // patch 10
+            pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(left),1), pic16_popCopyReg(&pic16_pc_fsr0h))); // patch 10
+        }
+      }
+    }
+//    else
+//    rname = pic16_aopGet(AOP(left),0,FALSE,FALSE);
     
     pic16_aopOp (result,ic,FALSE);
     
     DEBUGpic16_pic16_AopType(__LINE__, left, NULL, result);
 
-      /* if bitfield then unpack the bits */
+    /* if bitfield then unpack the bits */
     if (IS_BITFIELD(retype)) 
-       genUnpackBits (result, left, NULL, POINTER);
+      genUnpackBits (result, left, NULL, POINTER);
     else {
-       /* we have can just get the values */
+      /* we have can just get the values */
       int size = AOP_SIZE(result);
       int offset = 0;  
        
       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-
-       /* fsr0 is loaded already -- VR */
-//     pic16_loadFSR0( left );
+      /* fsr0 is loaded already -- VR */
+//      pic16_loadFSR0( left );
 
 //      pic16_emitpcode(POC_MOVFW,pic16_popGet(AOP(left),0));
 //      pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_fsr0));
       while(size--) {
-
-       if(size) {
-               pic16_emitpcode(POC_MOVFF,
-                       pic16_popGet2p(pic16_popCopyReg(&pic16_pc_postinc0),
-                               pic16_popGet(AOP(result), offset++)));
-       } else {
-               pic16_emitpcode(POC_MOVFF,
-                       pic16_popGet2p(pic16_popCopyReg(&pic16_pc_indf0),
-                               pic16_popGet(AOP(result), offset++)));
-       }
+        if(size) {
+          pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_postinc0),
+                pic16_popGet(AOP(result), offset++)));
+        } else {
+          pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popCopyReg(&pic16_pc_indf0),
+                pic16_popGet(AOP(result), offset++)));
+        }
       }
 #if 0
-//     pic16_emitpcode(POC_MOVFW,pic16_popCopyReg(&pic16_pc_postinc0));
-//     pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(result),offset++));
-       if(size)
-         pic16_emitpcode(POC_INCF,pic16_popCopyReg(&pic16_pc_fsr0));
+//      pic16_emitpcode(POC_MOVFW,pic16_popCopyReg(&pic16_pc_postinc0));
+//      pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(result),offset++));
+      if(size)
+        pic16_emitpcode(POC_INCF,pic16_popCopyReg(&pic16_pc_fsr0));
 #endif
 /*
        while (size--) {
@@ -10603,30 +10617,29 @@ static void genNearPointerGet (operand *left,
 
     /* now some housekeeping stuff */
     if (aop) {
-       /* we had to allocate for this iCode */
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       pic16_freeAsmop(NULL,aop,ic,TRUE);
+      /* we had to allocate for this iCode */
+      DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+      pic16_freeAsmop(NULL,aop,ic,TRUE);
     } else { 
-       /* we did not allocate which means left
-          already in a pointer register, then
-          if size > 0 && this could be used again
-          we have to point it back to where it 
-          belongs */
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       if (AOP_SIZE(result) > 1 &&
-           !OP_SYMBOL(left)->remat &&
-           ( OP_SYMBOL(left)->liveTo > ic->seq ||
-             ic->depth )) {
-//         int size = AOP_SIZE(result) - 1;
-//         while (size--)
-//             pic16_emitcode("dec","%s",rname);
+      /* we did not allocate which means left
+       * already in a pointer register, then
+       * if size > 0 && this could be used again
+       * we have to point it back to where it 
+       * belongs */
+      DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+      if (AOP_SIZE(result) > 1
+        && !OP_SYMBOL(left)->remat
+        && ( OP_SYMBOL(left)->liveTo > ic->seq
+            || ic->depth )) {
+//        int size = AOP_SIZE(result) - 1;
+//        while (size--)
+//          pic16_emitcode("dec","%s",rname);
        }
     }
 
     /* done */
     pic16_freeAsmop(left,NULL,ic,TRUE);
     pic16_freeAsmop(result,NULL,ic,TRUE);
-     
 }
 
 /*-----------------------------------------------------------------*/
@@ -11040,8 +11053,8 @@ static void genPointerGet (iCode *ic)
     sym_link *type, *etype;
     int p_type;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
+    FENTRY;
+    
     left = IC_LEFT(ic);
     result = IC_RESULT(ic) ;
 
@@ -11165,7 +11178,7 @@ static void genPackBits (sym_link    *etype , operand *result,
                                                pic16_popCopyGPR2Bit(pic16_popGet(AOP(result), 0), bstr));
                                }
                        } else {
-
+                                pic16_loadFSR0( result );
                                if(lit) {
                                        pic16_emitpcode(POC_BSF,
                                                pic16_popCopyGPR2Bit(pic16_popCopyReg(&pic16_pc_indf0), bstr));
@@ -11216,6 +11229,8 @@ static void genPackBits (sym_link    *etype , operand *result,
        if((shCnt=SPEC_BSTR(etype))
                || SPEC_BLEN(etype) <= 8 )  {
 
+               pic16_emitpcode(POC_ANDLW, pic16_popGetLit((1U << blen)-1));
+
                /* shift left acc */
                AccLsh(shCnt);
 
@@ -11225,6 +11240,7 @@ static void genPackBits (sym_link    *etype , operand *result,
                switch (p_type) {
                        case FPOINTER:
                        case POINTER:
+                               pic16_loadFSR0( result );
                                pic16_emitpcode(POC_MOVFW, pic16_popCopyReg(&pic16_pc_indf0));
 //                             pic16_emitcode ("mov","b,a");
 //                             pic16_emitcode("mov","a,@%s",rname);
@@ -11881,11 +11897,11 @@ release:
 /*-----------------------------------------------------------------*/
 static void genPointerSet (iCode *ic)
 {    
-    operand *right, *result ;
-    sym_link *type, *etype;
-    int p_type;
+  operand *right, *result ;
+  sym_link *type, *etype;
+  int p_type;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     right = IC_RIGHT(ic);
     result = IC_RESULT(ic) ;
@@ -11953,36 +11969,34 @@ static void genIfx (iCode *ic, iCode *popIc)
   operand *cond = IC_COND(ic);
   int isbit =0;
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
-  pic16_aopOp(cond,ic,FALSE);
+    pic16_aopOp(cond,ic,FALSE);
 
-  /* get the value into acc */
-  if (AOP_TYPE(cond) != AOP_CRY)
-    pic16_toBoolean(cond);
-  else
-    isbit = 1;
-  /* the result is now in the accumulator */
-  pic16_freeAsmop(cond,NULL,ic,TRUE);
-
-  /* if there was something to be popped then do it */
-  if (popIc)
-    genIpop(popIc);
-
-  /* if the condition is  a bit variable */
-  if (isbit && IS_ITEMP(cond) && 
-      SPIL_LOC(cond)) {
-    genIfxJump(ic,SPIL_LOC(cond)->rname);
-    DEBUGpic16_emitcode ("; isbit  SPIL_LOC","%s",SPIL_LOC(cond)->rname);
-  }
-  else {
-    if (isbit && !IS_ITEMP(cond))
-      genIfxJump(ic,OP_SYMBOL(cond)->rname);
+    /* get the value into acc */
+    if (AOP_TYPE(cond) != AOP_CRY)
+      pic16_toBoolean(cond);
     else
-      genIfxJump(ic,"a");
-  }
-  ic->generated = 1;
-
+      isbit = 1;
+    /* the result is now in the accumulator */
+    pic16_freeAsmop(cond,NULL,ic,TRUE);
+
+    /* if there was something to be popped then do it */
+    if (popIc)
+      genIpop(popIc);
+
+    /* if the condition is  a bit variable */
+    if (isbit && IS_ITEMP(cond) && 
+        SPIL_LOC(cond)) {
+      genIfxJump(ic,SPIL_LOC(cond)->rname);
+      DEBUGpic16_emitcode ("; isbit  SPIL_LOC","%s",SPIL_LOC(cond)->rname);
+    } else {
+      if (isbit && !IS_ITEMP(cond))
+        genIfxJump(ic,OP_SYMBOL(cond)->rname);
+        else
+        genIfxJump(ic,"a");
+    }
+    ic->generated = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -11995,7 +12009,7 @@ static void genAddrOf (iCode *ic)
   symbol *sym; // = OP_SYMBOL(IC_LEFT(ic));
   pCodeOp *pcop0, *pcop1, *pcop2;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     pic16_aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
@@ -12105,7 +12119,7 @@ static void genAssign (iCode *ic)
   result = IC_RESULT(ic);
   right  = IC_RIGHT(ic) ;
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
   
   /* if they are the same */
   if (operandsEqu (IC_RESULT(ic),IC_RIGHT(ic)))
@@ -12198,15 +12212,10 @@ static void genAssign (iCode *ic)
        && !IS_FUNC(OP_SYM_TYPE(right))
        ) {
        DEBUGpic16_emitcode(";   ", "%s:%d symbol in code space, take special care\n", __FUNCTION__, __LINE__);
-//     fprintf(stderr, "%s:%d symbol %s = [ %s ] is in code space\n", __FILE__, __LINE__, OP_SYMBOL(result)->name, OP_SYMBOL(right)->name);
+       fprintf(stderr, "%s:%d symbol %s = [ %s ] is in code space\n", __FILE__, __LINE__, OP_SYMBOL(result)->name, OP_SYMBOL(right)->name);
 
        // set up table pointer
-       if( (AOP_TYPE(right) == AOP_PCODE)
-               && ((AOP(right)->aopu.pcop->type == PO_IMMEDIATE)
-//             || (AOP(right)->aopu.pcop->type == PO_DIR)
-                )
-               )
-       {
+       if(is_LitOp(right)) {
 //             fprintf(stderr, "%s:%d inside block 1\n", __FILE__, __LINE__);
                pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(right),0));
                pic16_emitpcode(POC_MOVWF,pic16_popCopyReg(&pic16_pc_tblptrl));
@@ -12306,13 +12315,13 @@ static void genAssign (iCode *ic)
 /*-----------------------------------------------------------------*/
 static void genJumpTab (iCode *ic)
 {
-    symbol *jtab;
-    char *l;
-    pCodeOp *jt_offs;
-    pCodeOp *jt_offs_hi;
-    pCodeOp *jt_label;
+  symbol *jtab;
+  char *l;
+  pCodeOp *jt_offs;
+  pCodeOp *jt_offs_hi;
+  pCodeOp *jt_label;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
     pic16_aopOp(IC_JTCOND(ic),ic,FALSE);
     /* get the condition into accumulator */
@@ -12531,8 +12540,8 @@ static void genCast (iCode *ic)
   operand *right = IC_RIGHT(ic);
   int size, offset ;
 
-       DEBUGpic16_emitcode("; ***","%s  %d",__FUNCTION__,__LINE__);
 
+    FENTRY;
 
        /* if they are equivalent then do nothing */
 //     if (operandsEqu(IC_RESULT(ic),IC_RIGHT(ic)))
@@ -12908,7 +12917,8 @@ static int genDjnz (iCode *ic, iCode *ifx)
 /*-----------------------------------------------------------------*/
 static void genReceive (iCode *ic)
 {    
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+
+  FENTRY;
 
 #if 0
   fprintf(stderr, "%s:%d %s for symbol %s\tonStack: %d\n", __FILE__, __LINE__, __FUNCTION__,
@@ -12977,8 +12987,8 @@ genDummyRead (iCode * ic)
 
 void genpic16Code (iCode *lic)
 {
-    iCode *ic;
-    int cln = 0;
+  iCode *ic;
+  int cln = 0;
 
     lineHead = lineCurr = NULL;
 
@@ -12989,7 +12999,7 @@ void genpic16Code (iCode *lic)
     /* if debug information required */
     if (options.debug && currFunc) {
       if (currFunc) {
-       cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
+        cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
       }
     }
 #endif
@@ -12997,234 +13007,231 @@ void genpic16Code (iCode *lic)
     for (ic = lic ; ic ; ic = ic->next ) {
 
       DEBUGpic16_emitcode(";ic ", "\t%c 0x%x",ic->op, ic->op);
-       if ( cln != ic->lineno ) {
-           if ( options.debug ) {
-             debugFile->writeCLine (ic);
-           }
-           
-           if(!options.noCcodeInAsm) {
-               pic16_addpCode2pBlock(pb,
-                       pic16_newpCodeCSource(ic->lineno, ic->filename, 
-                               printCLine(ic->filename, ic->lineno)));
-           }
+      if ( cln != ic->lineno ) {
+        if ( options.debug ) {
+          debugFile->writeCLine (ic);
+        }
+        
+        if(!options.noCcodeInAsm) {
+          pic16_addpCode2pBlock(pb, pic16_newpCodeCSource(ic->lineno, ic->filename, 
+              printCLine(ic->filename, ic->lineno)));
+        }
 
-           cln = ic->lineno ;
-       }
+        cln = ic->lineno ;
+      }
        
-       if(options.iCodeInAsm) {
-               char *l;
-               /* insert here code to print iCode as comment */
-               l = Safe_strdup(printILine(ic));
-               pic16_emitpcomment("ic:%d: %s", ic->seq, l);
-       }
+      if(options.iCodeInAsm) {
+        char *l;
+
+          /* insert here code to print iCode as comment */
+          l = Safe_strdup(printILine(ic));
+          pic16_emitpcomment("ic:%d: %s", ic->seq, l);
+      }
        
-       /* if the result is marked as
-          spilt and rematerializable or code for
-          this has already been generated then
-          do nothing */
-       if (resultRemat(ic) || ic->generated ) 
-           continue ;
+      /* if the result is marked as
+       * spilt and rematerializable or code for
+       * this has already been generated then
+       * do nothing */
+      if (resultRemat(ic) || ic->generated ) 
+        continue ;
        
-       /* depending on the operation */
-       switch (ic->op) {
-       case '!' :
-           pic16_genNot(ic);
-           break;
-           
-       case '~' :
-           pic16_genCpl(ic);
-           break;
-           
-       case UNARYMINUS:
-           genUminus (ic);
-           break;
-           
-       case IPUSH:
-           genIpush (ic);
-           break;
+      /* depending on the operation */
+      switch (ic->op) {
+        case '!' :
+          pic16_genNot(ic);
+          break;
            
-       case IPOP:
-           /* IPOP happens only when trying to restore a 
-              spilt live range, if there is an ifx statement
-              following this pop then the if statement might
-              be using some of the registers being popped which
-              would destroy the contents of the register so
-              we need to check for this condition and handle it */
-           if (ic->next            && 
-               ic->next->op == IFX &&
-               regsInCommon(IC_LEFT(ic),IC_COND(ic->next))) 
-               genIfx (ic->next,ic);
-           else
-               genIpop (ic);
-           break; 
+        case '~' :
+          pic16_genCpl(ic);
+          break;
            
-       case CALL:
-           genCall (ic);
-           break;
+        case UNARYMINUS:
+          genUminus (ic);
+          break;
            
-       case PCALL:
-           genPcall (ic);
-           break;
+        case IPUSH:
+          genIpush (ic);
+          break;
            
-       case FUNCTION:
-           genFunction (ic);
-           break;
+        case IPOP:
+          /* IPOP happens only when trying to restore a 
+          * spilt live range, if there is an ifx statement
+          * following this pop then the if statement might
+          * be using some of the registers being popped which
+          * would destroy the contents of the register so
+          * we need to check for this condition and handle it */
+          if (ic->next
+            && ic->next->op == IFX
+            && regsInCommon(IC_LEFT(ic),IC_COND(ic->next))) 
+              genIfx (ic->next,ic);
+          else
+            genIpop (ic);
+          break; 
            
-       case ENDFUNCTION:
-           genEndFunction (ic);
-           break;
+        case CALL:
+          genCall (ic);
+          break;
            
-       case RETURN:
-           genRet (ic);
-           break;
+        case PCALL:
+          genPcall (ic);
+          break;
            
-       case LABEL:
-           genLabel (ic);
-           break;
+        case FUNCTION:
+          genFunction (ic);
+          break;
            
-       case GOTO:
-           genGoto (ic);
-           break;
+        case ENDFUNCTION:
+          genEndFunction (ic);
+          break;
            
-       case '+' :
-           pic16_genPlus (ic) ;
-           break;
+        case RETURN:
+          genRet (ic);
+          break;
            
-       case '-' :
-           if ( ! genDjnz (ic,ifxForOp(IC_RESULT(ic),ic)))
-               pic16_genMinus (ic);
-           break;
+        case LABEL:
+          genLabel (ic);
+          break;
            
-       case '*' :
-           genMult (ic);
-           break;
+        case GOTO:
+          genGoto (ic);
+          break;
            
-       case '/' :
-           genDiv (ic) ;
-           break;
+        case '+' :
+          pic16_genPlus (ic) ;
+          break;
            
-       case '%' :
-           genMod (ic);
-           break;
+        case '-' :
+          if ( ! genDjnz (ic,ifxForOp(IC_RESULT(ic),ic)))
+            pic16_genMinus (ic);
+          break;
+
+        case '*' :
+          genMult (ic);
+          break;
            
-       case '>' :
-           genCmpGt (ic,ifxForOp(IC_RESULT(ic),ic));                 
-           break;
+        case '/' :
+          genDiv (ic) ;
+          break;
            
-       case '<' :
-           genCmpLt (ic,ifxForOp(IC_RESULT(ic),ic));
-           break;
+        case '%' :
+          genMod (ic);
+          break;
            
-       case LE_OP:
-       case GE_OP:
-       case NE_OP:
+        case '>' :
+          genCmpGt (ic,ifxForOp(IC_RESULT(ic),ic));                  
+          break;
            
-           /* note these two are xlated by algebraic equivalence
-              during parsing SDCC.y */
-           werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
-                  "got '>=' or '<=' shouldn't have come here");
-           break;      
+        case '<' :
+          genCmpLt (ic,ifxForOp(IC_RESULT(ic),ic));
+          break;
            
-       case EQ_OP:
-           genCmpEq (ic,ifxForOp(IC_RESULT(ic),ic));
-           break;          
+        case LE_OP:
+        case GE_OP:
+        case NE_OP:
+          /* note these two are xlated by algebraic equivalence
+           * during parsing SDCC.y */
+          werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
+            "got '>=' or '<=' shouldn't have come here");
+          break;
+
+        case EQ_OP:
+          genCmpEq (ic,ifxForOp(IC_RESULT(ic),ic));
+          break;           
            
-       case AND_OP:
-           genAndOp (ic);
-           break;
+        case AND_OP:
+          genAndOp (ic);
+          break;
            
-       case OR_OP:
-           genOrOp (ic);
-           break;
+        case OR_OP:
+          genOrOp (ic);
+          break;
            
-       case '^' :
-           genXor (ic,ifxForOp(IC_RESULT(ic),ic));
-           break;
+        case '^' :
+          genXor (ic,ifxForOp(IC_RESULT(ic),ic));
+          break;
            
-       case '|' :
-               genOr (ic,ifxForOp(IC_RESULT(ic),ic));
-           break;
+        case '|' :
+          genOr (ic,ifxForOp(IC_RESULT(ic),ic));
+          break;
            
-       case BITWISEAND:
-            genAnd (ic,ifxForOp(IC_RESULT(ic),ic));
-           break;
+        case BITWISEAND:
+          genAnd (ic,ifxForOp(IC_RESULT(ic),ic));
+          break;
            
-       case INLINEASM:
-           genInline (ic);
-           break;
+        case INLINEASM:
+          genInline (ic);
+          break;
            
-       case RRC:
-           genRRC (ic);
-           break;
+        case RRC:
+          genRRC (ic);
+          break;
            
-       case RLC:
-           genRLC (ic);
-           break;
+        case RLC:
+          genRLC (ic);
+          break;
            
-       case GETHBIT:
-           genGetHbit (ic);
-           break;
+        case GETHBIT:
+          genGetHbit (ic);
+          break;
            
-       case LEFT_OP:
-           genLeftShift (ic);
-           break;
+        case LEFT_OP:
+          genLeftShift (ic);
+          break;
            
-       case RIGHT_OP:
-           genRightShift (ic);
-           break;
+        case RIGHT_OP:
+          genRightShift (ic);
+          break;
            
-       case GET_VALUE_AT_ADDRESS:
-           genPointerGet(ic);
-           break;
+        case GET_VALUE_AT_ADDRESS:
+          genPointerGet(ic);
+          break;
            
-       case '=' :
-           if (POINTER_SET(ic))
-               genPointerSet(ic);
-           else
-               genAssign(ic);
-           break;
+        case '=' :
+          if (POINTER_SET(ic))
+            genPointerSet(ic);
+          else
+            genAssign(ic);
+          break;
            
-       case IFX:
-           genIfx (ic,NULL);
-           break;
+        case IFX:
+          genIfx (ic,NULL);
+          break;
            
-       case ADDRESS_OF:
-           genAddrOf (ic);
-           break;
+        case ADDRESS_OF:
+          genAddrOf (ic);
+          break;
            
-       case JUMPTABLE:
-           genJumpTab (ic);
-           break;
+        case JUMPTABLE:
+          genJumpTab (ic);
+          break;
            
-       case CAST:
-           genCast (ic);
-           break;
+        case CAST:
+          genCast (ic);
+          break;
            
-       case RECEIVE:
-           genReceive(ic);
-           break;
+        case RECEIVE:
+          genReceive(ic);
+          break;
            
-       case SEND:
-           addSet(&_G.sendSet,ic);
-            /* create a reversed list of SEND iCodes */
-//            addSetHead(&_G.sendSet, ic);
-           break;
+        case SEND:
+          addSet(&_G.sendSet,ic);
+          break;
 
-       case DUMMY_READ_VOLATILE:
-         genDummyRead (ic);
-         break;
+        case DUMMY_READ_VOLATILE:
+          genDummyRead (ic);
+          break;
 
-       default :
-           ic = ic;
-        }
+        default :
+          ic = ic;
+      }
     }
 
 
     /* now we are ready to call the
        peep hole optimizer */
-    if (!options.nopeep) {
+    if (!options.nopeep)
       peepHole (&lineHead);
-    }
+
     /* now do the actual printing */
     printLine (lineHead, codeOutFile);
 
index 85a735030b19684fdc681dbf25a458408f27a74a..dd649f372789872c2e2ccd3629188104438ad7e8 100644 (file)
@@ -175,6 +175,7 @@ bool pic16_genMinusDec (iCode *ic);
 void pic16_addSign(operand *result, int offset, int sign);
 void pic16_genMinusBits (iCode *ic);
 void pic16_genMinus (iCode *ic);
+void pic16_genLeftShiftLiteral (operand *left, operand *right, operand *result, iCode *ic);
 
 pCodeOp *pic16_popGet2p(pCodeOp *src, pCodeOp *dst);
 void pic16_emitpcomment (char *fmt, ...);
@@ -199,11 +200,25 @@ void pic16_outBitC(operand *result);
 void pic16_toBoolean(operand *oper);
 void pic16_freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop);
 const char *pic16_pCodeOpType(  pCodeOp *pcop);
+int pic16_my_powof2 (unsigned long num);
 
 
 void dumpiCode(iCode *lic);
 
 int inWparamList(char *s);
 
+#define DUMP_FUNCTION_ENTRY    1
+#define DUMP_FUNCTION_EXIT     0
 
+#if DUMP_FUNCTION_ENTRY
+#define FENTRY pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__)
+#define FENTRY2 if(pic16_options.debgen&2)pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__)
+#endif
+
+#if DUMP_FUNCTION_EXIT
+#define FEXIT  pic16_emitpcomment("; **}", "%d %s", __LINE__, __FUNCTION__)
+#define FEXIT2 if(pic16_options.debgen&2)pic16_emitpcomment("**{\t%d %s", __LINE__, __FUNCTION__)
+#endif
+
+#define ERROR  werror(W_POSSBUG2, __FILE__, __LINE__)
 #endif
index a543487350e450115839f46d8d98fd97800fd95e..b5b707a89d170b6543ce81bc329faa04d2e73577 100644 (file)
@@ -167,10 +167,11 @@ const char *pic16_pCodeOpSubType(pCodeOp *pcop)
 /*-----------------------------------------------------------------*/
 bool pic16_genPlusIncr (iCode *ic)
 {
-    unsigned int icount ;
-    unsigned int size = pic16_getDataSize(IC_RESULT(ic));
+  unsigned int icount ;
+  unsigned int size = pic16_getDataSize(IC_RESULT(ic));
+
+    FENTRY;
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     DEBUGpic16_emitcode ("; ","result %s, left %s, right %s",
                         pic16_AopType(AOP_TYPE(IC_RESULT(ic))),
                         pic16_AopType(AOP_TYPE(IC_LEFT(ic))),
@@ -280,8 +281,7 @@ void pic16_outBitAcc(operand *result)
 /*-----------------------------------------------------------------*/
 void pic16_genPlusBits (iCode *ic)
 {
-
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+  FENTRY;
 
   DEBUGpic16_emitcode ("; ","result %s, left %s, right %s",
                       pic16_AopType(AOP_TYPE(IC_RESULT(ic))),
@@ -425,7 +425,8 @@ static void adjustArithmeticResult(iCode *ic)
 /*-----------------------------------------------------------------*/
 static void genAddLit2byte (operand *result, int offr, int lit)
 {
-
+  FENTRY;
+  
   switch(lit & 0xff) {
   case 0:
     break;
@@ -465,7 +466,7 @@ static void genAddLit (iCode *ic, int lit)
   operand *result;
   operand *left;
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
 
   left = IC_LEFT(ic);
@@ -779,13 +780,12 @@ static void genAddLit (iCode *ic, int lit)
 /*-----------------------------------------------------------------*/
 void pic16_genPlus (iCode *ic)
 {
-       int i, size, offset = 0;
-       operand *result, *left, *right;
-
-       /* special cases :- */
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
+  int i, size, offset = 0;
+  operand *result, *left, *right;
 
+    FENTRY;
+    
+    /* special cases :- */
        result = IC_RESULT(ic);
        left = IC_LEFT(ic);
        right = IC_RIGHT(ic);
@@ -1153,7 +1153,7 @@ bool pic16_genMinusDec (iCode *ic)
     unsigned int icount ;
     unsigned int size = pic16_getDataSize(IC_RESULT(ic));
 
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
     /* will try to generate an increment */
     /* if the right side is not a literal 
     we cannot */
@@ -1286,7 +1286,8 @@ void pic16_addSign(operand *result, int offset, int sign)
 void pic16_genMinusBits (iCode *ic)
 {
     symbol *lbl = newiTempLabel(NULL);
-    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+
+    FENTRY;
     if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY){
         pic16_emitcode("mov","c,%s",AOP(IC_LEFT(ic))->aopu.aop_dir);
         pic16_emitcode("jnb","%s,%05d_DS_",AOP(IC_RIGHT(ic))->aopu.aop_dir,(lbl->key+100));
@@ -1313,7 +1314,7 @@ void pic16_genMinus (iCode *ic)
   int size, offset = 0, same=0;
   unsigned long lit = 0L;
 
-  DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
   pic16_aopOp (IC_LEFT(ic),ic,FALSE);
   pic16_aopOp (IC_RIGHT(ic),ic,FALSE);
   pic16_aopOp (IC_RESULT(ic),ic,TRUE);
@@ -1607,7 +1608,7 @@ void pic16_genUMult8XLit_8 (operand *left,
   int size = AOP_SIZE(result);
   int i;
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
        DEBUGpic16_pic16_AopType(__LINE__,left,right,result);
 
        if (AOP_TYPE(right) != AOP_LIT){
@@ -1703,8 +1704,8 @@ void pic16_genUMult16XLit_16 (operand *left,
   int same;
 
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
+    FENTRY;
+    
        if (AOP_TYPE(right) != AOP_LIT){
                fprintf(stderr,"%s %d - right operand is not a literal\n",__FILE__,__LINE__);
                exit(1);
@@ -1815,8 +1816,8 @@ void pic16_genUMult8X8_8 (operand *left,
                           operand *result)
 
 {
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
+  FENTRY;
+  
 
        if (AOP_TYPE(right) == AOP_LIT) {
                pic16_genUMult8XLit_8(left,right,result);
@@ -1880,7 +1881,7 @@ void pic16_genUMult16X16_16 (operand *left,
 {
   pCodeOp *pct1, *pct2, *pct3, *pct4;
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    FENTRY;
 
 
        if (AOP_TYPE(right) == AOP_LIT) {
@@ -2007,12 +2008,12 @@ void pic16_genMult8X8_8 (operand *left,
                         operand *right,
                         operand *result)
 {
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-       if(AOP_TYPE(right) == AOP_LIT)
-               pic16_genUMult8XLit_8(left,right,result);
-       else
-               pic16_genUMult8X8_8(left,right,result);
+  FENTRY;
+  
+  if(AOP_TYPE(right) == AOP_LIT)
+    pic16_genUMult8XLit_8(left,right,result);
+  else
+    pic16_genUMult8X8_8(left,right,result);
 }
 
 
@@ -2023,13 +2024,12 @@ void pic16_genMult16X16_16 (operand *left,
                         operand *right,
                         operand *result)
 {
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-       if (AOP_TYPE(right) == AOP_LIT)
-               pic16_genUMult16XLit_16(left,right,result);
-       else
-               pic16_genUMult16X16_16(left,right,result);
-
+  FENTRY;
+  
+  if (AOP_TYPE(right) == AOP_LIT)
+    pic16_genUMult16XLit_16(left,right,result);
+  else
+    pic16_genUMult16X16_16(left,right,result);
 }
 
 
@@ -2047,8 +2047,8 @@ void pic16_genUMult32XLit_32 (operand *left,
   int same;
 
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
+    FENTRY;
+    
        if (AOP_TYPE(right) != AOP_LIT){
                fprintf(stderr,"%s %d - right operand is not a literal\n",__FILE__,__LINE__);
                exit(1);
@@ -2159,9 +2159,8 @@ void pic16_genUMult32X32_32 (operand *left,
 {
   pCodeOp *pct1, *pct2, *pct3, *pct4;
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-
+    FENTRY;
+    
        if (AOP_TYPE(right) == AOP_LIT) {
                pic16_genUMult8XLit_8(left,right,result);
          return;
@@ -2246,13 +2245,12 @@ void pic16_genMult32X32_32 (operand *left,
                         operand *right,
                         operand *result)
 {
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-       if (AOP_TYPE(right) == AOP_LIT)
-               pic16_genUMult32XLit_32(left,right,result);
-       else
-               pic16_genUMult32X32_32(left,right,result);
-
+  FENTRY;
+  
+  if (AOP_TYPE(right) == AOP_LIT)
+    pic16_genUMult32XLit_32(left,right,result);
+  else
+    pic16_genUMult32X32_32(left,right,result);
 }
 
 
index 16dfc1a1aac8fae8e5bf500909da0730f5707a44..55e5bbe9d3572bf9262d77b7b1b75ad8d4a0529b 100644 (file)
@@ -75,46 +75,46 @@ void pic16_genNot (iCode *ic)
  * result[AOP_CRY,AOP_REG]  = ! left[AOP_CRY, AOP_REG]
  */
 
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-       /* assign asmOps to operand & result */
-       pic16_aopOp (IC_LEFT(ic),ic,FALSE);
-       pic16_aopOp (IC_RESULT(ic),ic,TRUE);
-       DEBUGpic16_pic16_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
-
-       /* if in bit space then a special case */
-       if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
-               if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
-                       pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(IC_LEFT(ic)),0));
-                       pic16_emitpcode(POC_XORWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-               } else {
-                       pic16_emitpcode(POC_CLRF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-                       pic16_emitpcode(POC_BTFSS,pic16_popGet(AOP(IC_LEFT(ic)),0));
-                       pic16_emitpcode(POC_INCF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-               }
-               goto release;
-       }
-
-       size = AOP_SIZE(IC_LEFT(ic));
+    FENTRY;
+   
+    /* assign asmOps to operand & result */
+    pic16_aopOp (IC_LEFT(ic),ic,FALSE);
+    pic16_aopOp (IC_RESULT(ic),ic,TRUE);
+    DEBUGpic16_pic16_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
+
+    /* if in bit space then a special case */
+    if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
+      if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
+        pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(IC_LEFT(ic)),0));
+        pic16_emitpcode(POC_XORWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
+      } else {
+        pic16_emitpcode(POC_CLRF,pic16_popGet(AOP(IC_RESULT(ic)),0));
+        pic16_emitpcode(POC_BTFSS,pic16_popGet(AOP(IC_LEFT(ic)),0));
+        pic16_emitpcode(POC_INCF,pic16_popGet(AOP(IC_RESULT(ic)),0));
+      }
+      goto release;
+    }
+
+    size = AOP_SIZE(IC_LEFT(ic));
 #if 0
-       if(size == 1) {
-               pic16_emitpcode(POC_COMFW,pic16_popGet(AOP(IC_LEFT(ic)),0));
-               pic16_emitpcode(POC_ANDLW,pic16_popGetLit(1));
-               pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-               goto release;
-       }
+    if(size == 1) {
+      pic16_emitpcode(POC_COMFW,pic16_popGet(AOP(IC_LEFT(ic)),0));
+      pic16_emitpcode(POC_ANDLW,pic16_popGetLit(1));
+      pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
+      goto release;
+    }
 #endif
 
-       pic16_toBoolean( IC_LEFT(ic) );
-       emitSETC;
-       pic16_emitpcode(POC_TSTFSZ, pic16_popCopyReg( &pic16_pc_wreg ));
-       emitCLRC;
-       pic16_outBitC( IC_RESULT(ic) );
+    pic16_toBoolean( IC_LEFT(ic) );
+    emitSETC;
+    pic16_emitpcode(POC_TSTFSZ, pic16_popCopyReg( &pic16_pc_wreg ));
+    emitCLRC;
+    pic16_outBitC( IC_RESULT(ic) );
 
 release:    
-       /* release the aops */
-       pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
-       pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
+    /* release the aops */
+    pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
+    pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
 }
 
 #endif /* defined(GEN_Not) */
@@ -133,37 +133,36 @@ void pic16_genCpl (iCode *ic)
 /*
  * result[CRY,REG] = ~left[CRY,REG]
  */
-
-       DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-       /* assign asmOps to operand & result */
-       pic16_aopOp (IC_LEFT(ic),ic,FALSE);
-       pic16_aopOp (IC_RESULT(ic),ic,TRUE);
-       DEBUGpic16_pic16_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
-
-       /* if both are in bit space then 
-          a special case */
-       if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY &&
-               AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { 
-
-               /* FIXME */
-               pic16_emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); 
-               pic16_emitcode("cpl","c"); 
-               pic16_emitcode("mov","%s,c",IC_RESULT(ic)->aop->aopu.aop_dir); 
-               goto release; 
-       } 
-
-       size = AOP_SIZE(IC_RESULT(ic));
-       while (size--) {
-
-               if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
-                       pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)), offset));
-               } else {
-                       pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),offset));
-                       pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),offset));
-               }
-               offset++;
-       }
+    FENTRY;
+
+    DEBUGpic16_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    /* assign asmOps to operand & result */
+    pic16_aopOp (IC_LEFT(ic),ic,FALSE);
+    pic16_aopOp (IC_RESULT(ic),ic,TRUE);
+    DEBUGpic16_pic16_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
+
+    /* if both are in bit space then 
+     * a special case */
+    if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY
+      && AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { 
+
+        /* FIXME */
+        pic16_emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); 
+        pic16_emitcode("cpl","c"); 
+        pic16_emitcode("mov","%s,c",IC_RESULT(ic)->aop->aopu.aop_dir); 
+        goto release; 
+    } 
+
+    size = AOP_SIZE(IC_RESULT(ic));
+    while (size--) {
+      if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
+        pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)), offset));
+      } else {
+        pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),offset));
+        pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),offset));
+      }
+      offset++;
+    }
 
 release:
     /* release the aops */
index ab14e44d2a6341e942ceb0ad7e0f3a420f3b6a26..430f3425bf3cd675680aeafaad244d5553aae8aa 100644 (file)
@@ -650,6 +650,7 @@ _pic16_setDefaultOptions (void)
   pic16_options.no_crt = 0;                    /* use crt by default */
   pic16_options.ip_stack = 1;          /* set to 1 to enable ipop/ipush for stack */
   pic16_options.gstack = 0;
+  pic16_options.debgen = 0;
 }
 
 static const char *
index a33caa4f3507023e156af3889477778647db7b04..8eba51028e9f56157687c961ed3a4bddeab0463c 100644 (file)
@@ -7069,7 +7069,7 @@ void pic16_OptimizeJumps ()
   pCode *pc_prev = NULL;
   pCode *pc_next = NULL;
   pBlock *pb;
-       int isHandled = 0;
+  int isHandled = 0;
   int opt=0, toofar=0, jumptabs=0, opt_cond = 0, cond_toofar=0, opt_reorder = 0;
   
   if (!the_pFile) return;
@@ -7086,6 +7086,7 @@ void pic16_OptimizeJumps ()
        int dist = findpCodeLabel(pc, label, MAX_DIST_BRA);
        if (dist < 0) dist = -dist;
        //fprintf (stderr, "distance: %d (", dist); pc->print(stderr, pc);fprintf (stderr, ")\n");
+       isHandled = 0;
 
        if (condBraType != -1 && hasNoLabel(pc)) {
          if (dist < MAX_DIST_BCC) {
index ae1e1ea560c38c6066e881c6a678b5b232cbaf71..41f864122c66666c018e0502a4e16d1f32e327dd 100644 (file)
@@ -1029,6 +1029,9 @@ extern int pic16_pcode_verbose;
 #ifndef debugf
 //#define debugf(frm, rest...)       _debugf(__FILE__, __LINE__, frm, rest)
 #define debugf(frm, rest)      _debugf(__FILE__, __LINE__, frm, rest)
+#define debugf2(frm, arg1, arg2)       _debugf(__FILE__, __LINE__, frm, arg1, arg2)
+#define debugf3(frm, arg1, arg2, arg3) _debugf(__FILE__, __LINE__, frm, arg1, arg2, arg3)
+
 #endif
 
 extern void _debugf(char *f, int l, char *frm, ...);
index e25e89caa9276de7384171971562540cc5cbd08a..79351a97998d31ac729391320c43b8d1689a6df9 100644 (file)
@@ -3645,11 +3645,22 @@ static void
 packForPush (iCode * ic, eBBlock * ebp)
 {
   iCode *dic;
-
+  
   debugLog ("%s\n", __FUNCTION__);
   if (ic->op != IPUSH || !IS_ITEMP (IC_LEFT (ic)))
     return;
 
+#if 0
+  {
+    int n1, n2;
+
+      n1 = bitVectnBitsOn( OP_DEFS(IC_LEFT(ic)));
+      n2 = bitVectnBitsOn( OP_USES(IC_LEFT(ic)));
+      debugf3("defs: %d\tuses: %d\t%s\n", n1, n2, printILine(ic));
+      debugf2("IC_LEFT(ic): from %d to %d\n", OP_LIVEFROM(IC_LEFT(ic)), OP_LIVETO(IC_LEFT(ic)));
+  }
+#endif
+
   /* must have only definition & one usage */
   if (bitVectnBitsOn (OP_DEFS (IC_LEFT (ic))) != 1 ||
       bitVectnBitsOn (OP_USES (IC_LEFT (ic))) != 1)
@@ -3660,12 +3671,26 @@ packForPush (iCode * ic, eBBlock * ebp)
                               bitVectFirstBit (OP_DEFS (IC_LEFT (ic))))))
     return;
 
+  /* if definition is not assignment,
+   * or is not pointer (because pointer might have changed) */
   if (dic->op != '=' || POINTER_SET (dic))
     return;
 
+  /* we must ensure that we can use the delete the assignment,
+   * because the source might have been modified in between.
+   * Until I know how to fix this, I'll use the adhoc fix
+   * to check the liveranges */
+  if((OP_LIVEFROM(IC_RIGHT(dic))==0) || (OP_LIVETO(IC_RIGHT(dic))==0))
+    return;
+//  debugf2("IC_RIGHT(dic): from %d to %d\n", OP_LIVEFROM(IC_RIGHT(dic)), OP_LIVETO(IC_RIGHT(dic)));
+  
+
+
   /* we now we know that it has one & only one def & use
      and the that the definition is an assignment */
   IC_LEFT (ic) = IC_RIGHT (dic);
+  
+  debugf("remiCodeFromeBBlock: %s\n", printILine(dic));
 
   remiCodeFromeBBlock (ebp, dic);
   bitVectUnSetBit(OP_SYMBOL(IC_RESULT(dic))->defs,dic->key);
@@ -3690,33 +3715,32 @@ static void isData(sym_link *sl)
 {
   FILE *of = stderr;
 
-       if(!pic16_ralloc_debug)return;
-       
-       if(!sl)return;
-
-       if(debugF)
-               of = debugF;
-
-       for ( ; sl; sl=sl->next) {
-               if(!IS_DECL(sl) ) {
-                       switch (SPEC_SCLS(sl)) {
-                               case S_DATA: fprintf (of, "data "); break;
-                               case S_XDATA: fprintf (of, "xdata "); break;
-                               case S_SFR: fprintf (of, "sfr "); break;
-                               case S_SBIT: fprintf (of, "sbit "); break;
-                               case S_CODE: fprintf (of, "code "); break;
-                               case S_IDATA: fprintf (of, "idata "); break;
-                               case S_PDATA: fprintf (of, "pdata "); break;
-                               case S_LITERAL: fprintf (of, "literal "); break;
-                               case S_STACK: fprintf (of, "stack "); break;
-                               case S_XSTACK: fprintf (of, "xstack "); break;
-                               case S_BIT: fprintf (of, "bit "); break;
-                               case S_EEPROM: fprintf (of, "eeprom "); break;
-                               default: break;
-                       }
-
-               }
-       }
+    if(!pic16_ralloc_debug)return;
+    
+    if(!sl)return;
+    
+    if(debugF)
+      of = debugF;
+
+    for ( ; sl; sl=sl->next) {
+      if(!IS_DECL(sl) ) {
+        switch (SPEC_SCLS(sl)) {
+          case S_DATA: fprintf (of, "data "); break;
+          case S_XDATA: fprintf (of, "xdata "); break;
+          case S_SFR: fprintf (of, "sfr "); break;
+          case S_SBIT: fprintf (of, "sbit "); break;
+          case S_CODE: fprintf (of, "code "); break;
+          case S_IDATA: fprintf (of, "idata "); break;
+          case S_PDATA: fprintf (of, "pdata "); break;
+          case S_LITERAL: fprintf (of, "literal "); break;
+          case S_STACK: fprintf (of, "stack "); break;
+          case S_XSTACK: fprintf (of, "xstack "); break;
+          case S_BIT: fprintf (of, "bit "); break;
+          case S_EEPROM: fprintf (of, "eeprom "); break;
+          default: break;
+        }
+      }
+    }
 }
 
 
@@ -3745,8 +3769,6 @@ pic16_packRegisters (eBBlock * ebp)
       {
 //             debugLog("%d\n", __LINE__);
        /* find assignment of the form TrueSym := iTempNN:1 */
-       /* see BUGLOG0001 for workaround with the CAST - VR */
-//     if ( (ic->op == '=' || ic->op == CAST) && !POINTER_SET (ic) ) // patch 11
        if ( (ic->op == '=') && !POINTER_SET (ic) ) // patch 11
          change += packRegsForAssign (ic, ebp);
        /* debug stuff */
@@ -3818,46 +3840,43 @@ pic16_packRegisters (eBBlock * ebp)
 
 
     if (POINTER_SET (ic))
-       debugLog ("  %d - Pointer set\n", __LINE__);
-
-
-               /* Look for two subsequent iCodes with */
-               /*   iTemp := _c;         */
-               /*   _c = iTemp & op;     */
-               /* and replace them by    */
-               /*   iTemp := _c;         */
-               /*   _c = _c & op;        */
-               if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^') &&
-                       ic->prev &&
-                       ic->prev->op == '=' &&
-                       IS_ITEMP (IC_LEFT (ic)) &&
-                       IC_LEFT (ic) == IC_RESULT (ic->prev) &&
-                       isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev)))
+      debugLog ("  %d - Pointer set\n", __LINE__);
+      
+      /* Look for two subsequent iCodes with */
+      /*   iTemp := _c;         */
+      /*   _c = iTemp & op;     */
+      /* and replace them by    */
+      /*   iTemp := _c;         */
+      /*   _c = _c & op;        */
+      if ((ic->op == BITWISEAND || ic->op == '|' || ic->op == '^')
+        && ic->prev
+        && ic->prev->op == '='
+        && IS_ITEMP (IC_LEFT (ic))
+        && IC_LEFT (ic) == IC_RESULT (ic->prev)
+        && isOperandEqual (IC_RESULT(ic), IC_RIGHT(ic->prev)))
         {
-                       iCode* ic_prev = ic->prev;
-                       symbol* prev_result_sym = OP_SYMBOL (IC_RESULT (ic_prev));
+          iCode* ic_prev = ic->prev;
+          symbol* prev_result_sym = OP_SYMBOL (IC_RESULT (ic_prev));
                        
-                       ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic));
-                       if (IC_RESULT (ic_prev) != IC_RIGHT (ic))
+          ReplaceOpWithCheaperOp (&IC_LEFT (ic), IC_RESULT (ic));
+          if (IC_RESULT (ic_prev) != IC_RIGHT (ic)) {
+            bitVectUnSetBit (OP_USES (IC_RESULT (ic_prev)), ic->key);
+            if (/*IS_ITEMP (IC_RESULT (ic_prev)) && */
+              prev_result_sym->liveTo == ic->seq)
             {
-                               bitVectUnSetBit (OP_USES (IC_RESULT (ic_prev)), ic->key);
-                               if (/*IS_ITEMP (IC_RESULT (ic_prev)) && */
-                                       prev_result_sym->liveTo == ic->seq)
-                {
-                                       prev_result_sym->liveTo = ic_prev->seq;
-                }
-            }
-                       bitVectSetBit (OP_USES (IC_RESULT (ic)), ic->key);
-                       
-                       bitVectSetBit (ic->rlive, IC_RESULT (ic)->key);
-                       
-                       if (bitVectIsZero (OP_USES (IC_RESULT (ic_prev))))
-            {
-                               bitVectUnSetBit (ic->rlive, IC_RESULT (ic)->key);
-                               bitVectUnSetBit (OP_DEFS (IC_RESULT (ic_prev)), ic_prev->key);
-                               remiCodeFromeBBlock (ebp, ic_prev);
-                               hTabDeleteItem (&iCodehTab, ic_prev->key, ic_prev, DELETE_ITEM, NULL);
+              prev_result_sym->liveTo = ic_prev->seq;
             }
+          }
+          bitVectSetBit (OP_USES (IC_RESULT (ic)), ic->key);
+          
+          bitVectSetBit (ic->rlive, IC_RESULT (ic)->key);
+
+          if (bitVectIsZero (OP_USES (IC_RESULT (ic_prev)))) {
+            bitVectUnSetBit (ic->rlive, IC_RESULT (ic)->key);
+            bitVectUnSetBit (OP_DEFS (IC_RESULT (ic_prev)), ic_prev->key);
+            remiCodeFromeBBlock (ebp, ic_prev);
+            hTabDeleteItem (&iCodehTab, ic_prev->key, ic_prev, DELETE_ITEM, NULL);
+          }
         }
                
     /* if this is an itemp & result of a address of a true sym 
@@ -4078,6 +4097,12 @@ pic16_packRegisters (eBBlock * ebp)
       }
     }
 #endif
+
+#if 1
+    /* there are some problems with packing variables
+     * it seems that the live range estimator doesn't
+     * estimate correctly the liveranges of some symbols */
+     
     /* pack for PUSH 
        iTempNN := (some variable in farspace) V1
        push iTempNN ;
@@ -4088,7 +4113,7 @@ pic16_packRegisters (eBBlock * ebp)
       {
        packForPush (ic, ebp);
       }
-
+#endif
 
 #ifndef NO_packRegsForAccUse
     /* pack registers for accumulator use, when the