* src/pic/*.[ch]: removed dead/replaced code, no functional changes
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 15 Aug 2008 15:11:06 +0000 (15:11 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 15 Aug 2008 15:11:06 +0000 (15:11 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5214 4a8a32a2-be11-0410-ad9d-d568d2c75423

12 files changed:
ChangeLog
src/pic/device.c
src/pic/gen.c
src/pic/genarith.c
src/pic/glue.c
src/pic/main.c
src/pic/pcode.c
src/pic/pcode.h
src/pic/pcodeflow.c
src/pic/pcodepeep.c
src/pic/pcoderegs.c
src/pic/ralloc.c

index 972844da55f3a01f5cedc3ca53b1b22f4d06e01f..3f370c6127386ffa3738be7edaabf0249f53c720 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,7 @@
 
        * src/pic/*.[ch]: make proper use of header files and avoid
          ad-hoc extern declarations, mark module-local helpers 'static',
-         no functional changes
+         removed dead/replaced code, no functional changes
        * src/pic16/pcode.c: disentangled from pic14 backend
 
 2008-08-14 Philipp Klaus Krause <pkk AT spth.de>
index 5a5ef83000432267b1a8cfaa46fdd9b7f32b9e64..17ab6d5d054fcb7710552d7b3ab02963ab5fcf0f 100644 (file)
@@ -538,169 +538,6 @@ char *processor_base_name(void)
        return pic->name;
 }
 
-#if 0
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-static int validAddress(int address, int reg_size)
-{
-       if (maxRAMaddress < 0) {
-               fprintf(stderr, "missing maxram setting in %s\n", DEVICE_FILE_NAME);
-               return 0;
-       }
-       //  fprintf(stderr, "validAddress: Checking 0x%04x\n",address);
-       assert (reg_size > 0);
-       if(address + (reg_size - 1) > maxRAMaddress)
-               return 0;
-       
-       return 1;
-}
-#endif
-
-#if 0
-/* The following code should be (and is) implemented in the linker. */
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-void mapRegister(regs *reg)
-{
-       
-       unsigned i;
-       int alias;
-       
-       if(!reg || !reg->size) {
-               fprintf(stderr,"WARNING: %s:%s:%d Bad register\n",__FILE__,__FUNCTION__,__LINE__);
-               return;
-       }
-       
-       if (maxRAMaddress < 0) {
-               fprintf(stderr, "missing maxram setting in %s\n", DEVICE_FILE_NAME);
-               return;
-       }
-       
-       for(i=0; i<reg->size; i++) {
-               
-               assert(reg->address >= 0 && reg->address < maxRAMaddress);
-               
-               alias = finalMapping[reg->address].alias;
-               reg->alias = alias;
-               
-               do {
-                       
-                       //fprintf(stdout,"mapping %s to address 0x%02x, reg size = %d\n",reg->name, (reg->address+alias+i),reg->size);
-                       
-                       finalMapping[reg->address + alias + i].reg = reg;
-                       finalMapping[reg->address + alias + i].instance = i;
-                       
-                       /* Decrement alias */
-                       if(alias)
-                               alias -= ((alias & (alias - 1)) ^ alias);
-                       else
-                               alias--;
-                       
-               } while (alias>=0);
-       }
-       
-       //fprintf(stderr,"%s - %s addr = 0x%03x, size %d\n",__FUNCTION__,reg->name, reg->address,reg->size);
-       
-       reg->isMapped = 1;
-       
-}
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-int assignRegister(regs *reg, int start_address)
-{
-       int i;
-       
-       //fprintf(stderr,"%s -  %s start_address = 0x%03x\n",__FUNCTION__,reg->name, start_address);
-       if(reg->isFixed) {
-               
-               if (validAddress(reg->address,reg->size)) {
-                       //fprintf(stderr,"%s -  %s address = 0x%03x\n",__FUNCTION__,reg->name, reg->address);
-                       mapRegister(reg);
-                       return reg->address;
-               }
-               
-               if (getenv("SDCCPICDEBUG")) {
-                       fprintf(stderr, "WARNING: Ignoring Out of Range register assignment at fixed address %d, %s\n",
-                           reg->address, reg->name);
-               }
-               
-       } else {
-               
-       /* This register does not have a fixed address requirement
-       * so we'll search through all availble ram address and
-               * assign the first one */
-               
-               for (i=start_address; i<=maxRAMaddress; i++) {
-                       
-                       if (validAddress(i,reg->size)) {
-                               reg->address = i;
-                               mapRegister(reg);
-                               return i;
-                       }
-               }
-               
-               fprintf(stderr, "WARNING: No more RAM available for %s\n",reg->name);
-               
-       }
-       
-       return -1;
-}
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-void assignFixedRegisters(set *regset)
-{
-       regs *reg;
-       
-       for (reg = setFirstItem(regset) ; reg ; 
-       reg = setNextItem(regset)) {
-               
-               if(reg->isFixed) 
-                       assignRegister(reg,0);
-       }
-       
-}
-
-/*-----------------------------------------------------------------*
-*-----------------------------------------------------------------*/
-void assignRelocatableRegisters(set *regset, int used)
-{
-       
-       regs *reg;
-       int address = 0;
-       
-       for (reg = setFirstItem(regset) ; reg ; 
-       reg = setNextItem(regset)) {
-               
-               //fprintf(stdout,"assigning %s (%d) isFixed=%d, wasUsed=%d\n",reg->name,reg->size,reg->isFixed,reg->wasUsed);
-               
-               if((!reg->isExtern) && (!reg->isFixed) && ( used || reg->wasUsed)) {
-                       /* If register have been reused then shall not print it a second time. */
-                       set *s;
-                       int done = 0;
-                       for (s = regset; s; s = s->next) {
-                               regs *r;
-                               r = s->item;
-                               if (r == reg)
-                                       break;
-                               if((!r->isFixed) && ( used || r->wasUsed)) {
-                                       if (r->rIdx == reg->rIdx) {
-                                               reg->address = r->address;
-                                               done = 1;
-                                               break;
-                                       }
-                               }
-                       }
-                       if (!done)
-                               address = assignRegister(reg,address);
-               }
-       }
-       
-}
-#endif
-
 int IS_CONFIG_ADDRESS(int address)
 {
 
@@ -751,16 +588,6 @@ static int pic14_getConfigWord(int address)
        }
 }
 
-#if 0
-/*-----------------------------------------------------------------*
-*  
-*-----------------------------------------------------------------*/
-static unsigned pic14_getMaxRam(void)
-{
-       return pic->defMaxRAMaddrs;
-}
-#endif
-
 /*-----------------------------------------------------------------*
 *  int getHasSecondConfigReg(void) - check if the device has a 
 *  second config register, rather than just one.
index 507d386d9b8b50f7010d3ebc788e71f48bb52399..04b5cf9acef4fbb4123d86d2f45c6f1706a07b73 100644 (file)
@@ -218,11 +218,6 @@ void emitpComment (const char *fmt, ...)
     Safe_vsnprintf (buffer, 4096, fmt, va);
     //fprintf (stderr, "%s\n" ,buffer);
     addpCode2pBlock (pb, newpCodeCharP (buffer));
-#if 0
-  } else {
-    Safe_vsnprintf (buffer, 4096, fmt, va);
-    fprintf (stderr, "No current pBlock -- discarding comment [%s]\n", buffer);
-#endif
   }
   va_end (va);
 }
@@ -252,12 +247,9 @@ void emitpcode_real(PIC_OPCODE poc, pCodeOp *pcop)
 
 static void emitpcodeNULLop(PIC_OPCODE poc)
 {
-
     addpCode2pBlock(pb,newpCode(poc,NULL));
-
 }
 
-
 /*-----------------------------------------------------------------*/
 /* pic14_emitcode - writes the code into a file : for now it is simple    */
 /*-----------------------------------------------------------------*/
@@ -334,10 +326,6 @@ static void resolveIfx(resolvedIfx *resIfx, iCode *ifx)
 
     if(!ifx) {
         resIfx->lbl = NULL; /* this is wrong: newiTempLabel(NULL);  / * oops, there is no ifx. so create a label */
-                                            /*
-                                            DEBUGpic14_emitcode("; ***","%s %d null ifx creating new label key =%d",
-                                            __FUNCTION__,__LINE__,resIfx->lbl->key);
-        */
     } else {
         if(IC_TRUE(ifx)) {
             resIfx->lbl = IC_TRUE(ifx);
@@ -345,28 +333,11 @@ static void resolveIfx(resolvedIfx *resIfx, iCode *ifx)
             resIfx->lbl = IC_FALSE(ifx);
             resIfx->condition = 0;
         }
-        /*
-        if(IC_TRUE(ifx))
-        DEBUGpic14_emitcode("; ***","ifx true is non-null");
-        if(IC_FALSE(ifx))
-        DEBUGpic14_emitcode("; ***","ifx false is non-null");
-        */
     }
 
     //  DEBUGpic14_emitcode("; ***","%s lbl->key=%d, (lab offset=%d)",__FUNCTION__,resIfx->lbl->key,labelOffset);
 
 }
-/*-----------------------------------------------------------------*/
-/* pointerCode - returns the code for a pointer type               */
-/*-----------------------------------------------------------------*/
-#if 0
-static int pointerCode (sym_link *etype)
-{
-
-    return PTR_TYPE(SPEC_OCLS(etype));
-
-}
-#endif
 
 /*-----------------------------------------------------------------*/
 /* aopForSym - for a true symbol                                   */
@@ -400,12 +371,6 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
         PCOI(aop->aopu.pcop)->_function = 1;
         PCOI(aop->aopu.pcop)->index = 0;
         aop->size = FPTRSIZE;
-        /*
-        sym->aop = aop = newAsmop(AOP_IMMD);
-        aop->aopu.aop_immd = Safe_calloc(1,strlen(sym->rname)+1);
-        strcpy(aop->aopu.aop_immd,sym->rname);
-        aop->size = FPTRSIZE;
-        */
         DEBUGpic14_emitcode(";","%d size = %d, name =%s",__LINE__,aop->size,sym->rname);
         return aop;
     }
@@ -499,6 +464,7 @@ static int aopIdx (asmop *aop, int offset)
     return aop->aopu.aop_reg[offset]->rIdx;
 
 }
+
 /*-----------------------------------------------------------------*/
 /* regsInCommon - two operands have some registers in common       */
 /*-----------------------------------------------------------------*/
@@ -916,7 +882,6 @@ char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
   exit(0);
 }
 
-
 /*-----------------------------------------------------------------*/
 /* popGetTempReg - create a new temporary pCodeOp                  */
 /*-----------------------------------------------------------------*/
@@ -944,6 +909,7 @@ static void popReleaseTempReg(pCodeOp *pcop)
         PCOR(pcop)->r->isFree = 1;
 
 }
+
 /*-----------------------------------------------------------------*/
 /* popGetLabel - create a new pCodeOp of type PO_LABEL             */
 /*-----------------------------------------------------------------*/
@@ -1124,24 +1090,6 @@ pCodeOp *popGet (asmop *aop, int offset) //, bool bit16, bool dname)
 
     case AOP_DIR:
         return popRegFromString(aop->aopu.aop_dir, aop->size, offset);
-#if 0
-        pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
-        pcop->type = PO_DIR;
-
-        pcop->name = Safe_calloc(1,strlen(aop->aopu.aop_dir)+1);
-        strcpy(pcop->name,aop->aopu.aop_dir);
-        PCOR(pcop)->r = dirregWithName(aop->aopu.aop_dir);
-        if(PCOR(pcop)->r == NULL) {
-            //fprintf(stderr,"%d - couldn't find %s in allocated registers, size =%d\n",__LINE__,aop->aopu.aop_dir,aop->size);
-            PCOR(pcop)->r = allocRegByName (aop->aopu.aop_dir,aop->size);
-            DEBUGpic14_emitcode(";","%d  %s   offset=%d - had to alloc by reg name",__LINE__,pcop->name,offset);
-        } else {
-            DEBUGpic14_emitcode(";","%d  %s   offset=%d",__LINE__,pcop->name,offset);
-        }
-        PCOR(pcop)->instance = offset;
-
-        return pcop;
-#endif
 
     case AOP_REG:
         {
@@ -1175,15 +1123,6 @@ pCodeOp *popGet (asmop *aop, int offset) //, bool bit16, bool dname)
     case AOP_STR:
         DEBUGpic14_emitcode(";","%d  %s",__LINE__,aop->aopu.aop_str[offset]);
         return newpCodeOpRegFromStr(aop->aopu.aop_str[offset]);
-        /*
-        pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
-        PCOR(pcop)->r = allocRegByName(aop->aopu.aop_str[offset]);
-        PCOR(pcop)->rIdx = PCOR(pcop)->r->rIdx;
-        pcop->type = PCOR(pcop)->r->pc_type;
-        pcop->name = PCOR(pcop)->r->name;
-
-          return pcop;
-        */
 
     case AOP_PCODE:
         pcop = NULL;
@@ -1296,21 +1235,6 @@ void aopPut (asmop *aop, char *s, int offset)
 
     case AOP_REG:
         if (strcmp(aop->aopu.aop_reg[offset]->name,s) != 0) {
-            /*
-            if (*s == '@'         ||
-            strcmp(s,"r0") == 0 ||
-            strcmp(s,"r1") == 0 ||
-            strcmp(s,"r2") == 0 ||
-            strcmp(s,"r3") == 0 ||
-            strcmp(s,"r4") == 0 ||
-            strcmp(s,"r5") == 0 ||
-            strcmp(s,"r6") == 0 ||
-            strcmp(s,"r7") == 0 )
-            pic14_emitcode("mov","%s,%s  ; %d",
-            aop->aopu.aop_reg[offset]->dname,s,__LINE__);
-            else
-            */
-
             if(strcmp(s,"W")==0 )
                 pic14_emitcode("movf","%s,w  ; %d",s,__LINE__);
 
@@ -2348,29 +2272,6 @@ static int resultRemat (iCode *ic)
     return 0;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* inExcludeList - return 1 if the string is in exclude Reg list   */
-/*-----------------------------------------------------------------*/
-static bool inExcludeList(char *s)
-{
-    DEBUGpic14_emitcode ("; ***","%s  %d - WARNING no code generated",__FUNCTION__,__LINE__);
-    int i =0;
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if (options.excludeRegs[i] &&
-        STRCASECMP(options.excludeRegs[i],"none") == 0)
-        return FALSE ;
-
-    for ( i = 0 ; options.excludeRegs[i]; i++) {
-        if (options.excludeRegs[i] &&
-            STRCASECMP(s,options.excludeRegs[i]) == 0)
-            return TRUE;
-    }
-    return FALSE ;
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genFunction - generated code for function entry                 */
 /*-----------------------------------------------------------------*/
@@ -3164,59 +3065,6 @@ static void genIfxJump (iCode *ic, char *jval)
     ic->generated = 1;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genSkip                                                         */
-/*-----------------------------------------------------------------*/
-static void genSkip(iCode *ifx,int status_bit)
-{
-    FENTRY;
-    if(!ifx)
-        return;
-
-    if ( IC_TRUE(ifx) ) {
-        switch(status_bit) {
-        case 'z':
-            emitSKPNZ;
-            break;
-
-        case 'c':
-            emitSKPNC;
-            break;
-
-        case 'd':
-            emitSKPDC;
-            break;
-
-        }
-
-        emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-        pic14_emitcode("goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
-
-    } else {
-
-        switch(status_bit) {
-
-        case 'z':
-            emitSKPZ;
-            break;
-
-        case 'c':
-            emitSKPC;
-            break;
-
-        case 'd':
-            emitSKPDC;
-            break;
-        }
-        emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
-        pic14_emitcode("goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
-
-    }
-
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genSkipc                                                        */
 /*-----------------------------------------------------------------*/
@@ -3236,104 +3084,6 @@ static void genSkipc(resolvedIfx *rifx)
     rifx->generated = 1;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genSkipz2                                                       */
-/*-----------------------------------------------------------------*/
-static void genSkipz2(resolvedIfx *rifx, int invert_condition)
-{
-    FENTRY;
-    if(!rifx)
-        return;
-
-    if( (rifx->condition ^ invert_condition) & 1)
-        emitSKPZ;
-    else
-        emitSKPNZ;
-
-    emitpcode(POC_GOTO,popGetLabel(rifx->lbl->key));
-    rifx->generated = 1;
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genSkipz                                                        */
-/*-----------------------------------------------------------------*/
-static void genSkipz(iCode *ifx, int condition)
-{
-    FENTRY;
-    assert (ifx != NULL);
-
-    if(condition)
-        emitSKPNZ;
-    else
-        emitSKPZ;
-
-    if ( IC_TRUE(ifx) )
-        emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-    else
-        emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
-
-    if ( IC_TRUE(ifx) )
-        pic14_emitcode("goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
-    else
-        pic14_emitcode("goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
-
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genSkipCond                                                     */
-/*-----------------------------------------------------------------*/
-static void genSkipCond(resolvedIfx *rifx,operand *op, int offset, int bit)
-{
-    FENTRY;
-    if(!rifx)
-        return;
-
-    if(rifx->condition)
-        emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(op),offset,FALSE,FALSE),bit,0));
-    else
-        emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(op),offset,FALSE,FALSE),bit,0));
-
-
-    emitpcode(POC_GOTO,popGetLabel(rifx->lbl->key));
-    rifx->generated = 1;
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genChkZeroes :- greater or less than comparison                 */
-/*     For each byte in a literal that is zero, inclusive or the   */
-/*     the corresponding byte in the operand with W                */
-/*     returns true if any of the bytes are zero                   */
-/*-----------------------------------------------------------------*/
-static int genChkZeroes(operand *op, int lit,  int size)
-{
-
-    int i;
-    int flag =1;
-
-    while(size--) {
-        i = (lit >> (size*8)) & 0xff;
-
-        if(i==0) {
-            if(flag)
-                emitpcode(POC_MOVFW, popGet(AOP(op),size));
-            else
-                emitpcode(POC_IORFW, popGet(AOP(op),size));
-            flag = 0;
-        }
-    }
-
-    return (flag==0);
-}
-#endif
-
-
 #define isAOP_REGlike(x)  (AOP_TYPE(x) == AOP_REG || AOP_TYPE(x) == AOP_DIR || AOP_TYPE(x) == AOP_PCODE)
 #define isAOP_LIT(x)      (AOP_TYPE(x) == AOP_LIT)
 #define DEBUGpc           emitpComment
@@ -3565,3155 +3315,1621 @@ correct_result_in_carry:
   } // if
 }
 
-
-#if 0
-/* OLD VERSION -- BUGGY, DO NOT USE */
-
 /*-----------------------------------------------------------------*/
-/* genCmp :- greater or less than comparison                       */
+/* genCmpGt :- greater than comparison                             */
 /*-----------------------------------------------------------------*/
-static void genCmp (operand *left,operand *right,
-                    operand *result, iCode *ifx, int sign)
+static void genCmpGt (iCode *ic, iCode *ifx)
 {
-    int size; //, offset = 0 ;
-    unsigned long lit = 0L,i = 0;
-    resolvedIfx rFalseIfx;
-    //  resolvedIfx rTrueIfx;
-    symbol *truelbl;
+    operand *left, *right, *result;
+    sym_link *letype , *retype;
+    int sign ;
 
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /*
-    if(ifx) {
-    DEBUGpic14_emitcode ("; ***","true ifx is %s",((IC_TRUE(ifx) == NULL) ? "false" : "true"));
-    DEBUGpic14_emitcode ("; ***","false ifx is %s",((IC_FALSE(ifx) == NULL) ? "false" : "true"));
-    }
-    */
-
-    resolveIfx(&rFalseIfx,ifx);
-    truelbl  = newiTempLabel(NULL);
-    size = max(AOP_SIZE(left),AOP_SIZE(right));
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-#define _swapp
+    left = IC_LEFT(ic);
+    right= IC_RIGHT(ic);
+    result = IC_RESULT(ic);
 
-    /* if literal is on the right then swap with left */
-    if ((AOP_TYPE(right) == AOP_LIT)) {
-        operand *tmp = right ;
-        unsigned long mask = (0x100 << (8*(size-1))) - 1;
-        lit = ulFromVal(AOP(right)->aopu.aop_lit);
-#ifdef _swapp
+    letype = getSpec(operandType(left));
+    retype =getSpec(operandType(right));
+    sign =  !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
+    /* assign the amsops */
+    aopOp (left,ic,FALSE);
+    aopOp (right,ic,FALSE);
+    aopOp (result,ic,TRUE);
 
-        lit = (lit - 1) & mask;
-        right = left;
-        left = tmp;
-        rFalseIfx.condition ^= 1;
-#endif
+    genCmp(right, left, result, ifx, sign);
 
-    } else if ((AOP_TYPE(left) == AOP_LIT)) {
-        lit = ulFromVal(AOP(left)->aopu.aop_lit);
-    }
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
+/*-----------------------------------------------------------------*/
+/* genCmpLt - less than comparisons                                */
+/*-----------------------------------------------------------------*/
+static void genCmpLt (iCode *ic, iCode *ifx)
+{
+    operand *left, *right, *result;
+    sym_link *letype , *retype;
+    int sign ;
 
-    //if(IC_TRUE(ifx) == NULL)
-    /* if left & right are bit variables */
-    if (AOP_TYPE(left) == AOP_CRY &&
-        AOP_TYPE(right) == AOP_CRY ) {
-        pic14_emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
-        pic14_emitcode("anl","c,/%s",AOP(left)->aopu.aop_dir);
-    } else {
-    /* subtract right from left if at the
-    end the carry flag is set then we know that
-        left is greater than right */
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    left = IC_LEFT(ic);
+    right= IC_RIGHT(ic);
+    result = IC_RESULT(ic);
 
-        symbol *lbl  = newiTempLabel(NULL);
+    letype = getSpec(operandType(left));
+    retype =getSpec(operandType(right));
+    sign =  !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
 
-#ifndef _swapp
-        if(AOP_TYPE(right) == AOP_LIT) {
+    /* assign the amsops */
+    aopOp (left,ic,FALSE);
+    aopOp (right,ic,FALSE);
+    aopOp (result,ic,TRUE);
 
-            //lit = ulFromVal(AOP(right)->aopu.aop_lit);
+    genCmp(left, right, result, ifx, sign);
 
-            DEBUGpic14_emitcode(";right lit","lit = 0x%x,sign=%d",lit,sign);
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-            /* special cases */
+/*-----------------------------------------------------------------*/
+/* genCmpEq - generates code for equal to                          */
+/*-----------------------------------------------------------------*/
+static void genCmpEq (iCode *ic, iCode *ifx)
+{
+  operand *left, *right, *result;
+  int size;
+  symbol *false_label;
 
-            if(lit == 0) {
+  FENTRY;
+  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-                if(sign != 0)
-                    genSkipCond(&rFalseIfx,left,size-1,7);
-                else
-                    /* no need to compare to 0...*/
-                    /* NOTE: this is a de-generate compare that most certainly
-                    *       creates some dead code. */
-                    emitpcode(POC_GOTO,popGetLabel(rFalseIfx.lbl->key));
+  if(ifx)
+    DEBUGpic14_emitcode ("; ifx is non-null","");
+  else
+    DEBUGpic14_emitcode ("; ifx is null","");
 
-                if(ifx) ifx->generated = 1;
-                return;
+  aopOp((left=IC_LEFT(ic)),ic,FALSE);
+  aopOp((right=IC_RIGHT(ic)),ic,FALSE);
+  aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
-            }
-            size--;
+  DEBUGpic14_AopType(__LINE__,left,right,result);
 
-            if(size == 0) {
-                //i = (lit >> (size*8)) & 0xff;
-                DEBUGpic14_emitcode(";right lit","line = %d",__LINE__);
+  /* if literal, move literal to right */
+  if (op_isLitLike (IC_LEFT(ic))) {
+    operand *tmp = right ;
+    right = left;
+    left = tmp;
+  }
 
-                emitpcode(POC_MOVFW, popGet(AOP(left),size));
+  false_label = NULL;
+  if (ifx && !IC_TRUE(ifx))
+  {
+    assert (IC_FALSE(ifx));
+    false_label = IC_FALSE(ifx);
+  }
 
-                i = ((0-lit) & 0xff);
-                if(sign) {
-                    if( i == 0x81) {
-                    /* lit is 0x7f, all signed chars are less than
-                        * this except for 0x7f itself */
-                        emitpcode(POC_XORLW, popGetLit(0x7f));
-                        genSkipz2(&rFalseIfx,0);
-                    } else {
-                        emitpcode(POC_ADDLW, popGetLit(0x80));
-                        emitpcode(POC_ADDLW, popGetLit(i^0x80));
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                    }
+  size = min(AOP_SIZE(left),AOP_SIZE(right));
+  assert(!pic14_sameRegs(AOP(result),AOP(left)));
+  assert(!pic14_sameRegs(AOP(result),AOP(right)));
 
-                } else {
-                    if(lit == 1) {
-                        genSkipz2(&rFalseIfx,1);
-                    } else {
-                        emitpcode(POC_ADDLW, popGetLit(i));
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                    }
-                }
-
-                if(ifx) ifx->generated = 1;
-                return;
-            }
-
-            /* chars are out of the way. now do ints and longs */
-
-
-            DEBUGpic14_emitcode(";right lit","line = %d",__LINE__);
-
-            /* special cases */
+  /* assume left != right */
+  {
+    int i;
+    for (i=0; i < AOP_SIZE(result); i++)
+    {
+      emitpcode(POC_CLRF, popGet(AOP(result),i));
+    }
+  }
 
-            if(sign) {
+  if (AOP_TYPE(right) == AOP_LIT)
+  {
+    unsigned long lit = ulFromVal (AOP(right)->aopu.aop_lit);
+    int i;
+    size = AOP_SIZE(left);
+    assert(!op_isLitLike(left));
 
-                if(lit == 0) {
-                    genSkipCond(&rFalseIfx,left,size,7);
-                    if(ifx) ifx->generated = 1;
-                    return;
-                }
+    switch (lit)
+    {
+      case 0:
+        mov2w(AOP(left), 0);
+    for (i=1; i < size; i++)
+      emitpcode(POC_IORFW,popGet(AOP(left),i));
+    /* now Z is set iff `left == right' */
+    emitSKPZ;
+    if (!false_label) false_label = newiTempLabel(NULL);
+    emitpcode(POC_GOTO, popGetLabel(false_label->key));
+    break;
 
-                if(lit <0x100) {
-                    DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+      default:
+    for (i=0; i < size; i++)
+    {
+      mov2w(AOP(left),i);
+      emitpcode(POC_XORLW, popGetLit(lit >> (8*i)));
+      /* now Z is cleared if `left != right' */
+      emitSKPZ;
+      if (!false_label) false_label = newiTempLabel(NULL);
+      emitpcode(POC_GOTO, popGetLabel(false_label->key));
+    } // for i
+    break;
+    } // switch (lit)
+  }
+  else
+  {
+    /* right is no literal */
+    int i;
 
-                    //rFalseIfx.condition ^= 1;
-                    //genSkipCond(&rFalseIfx,left,size,7);
-                    //rFalseIfx.condition ^= 1;
+    for (i=0; i < size; i++)
+    {
+      mov2w(AOP(right),i);
+      emitpcode(POC_XORFW,popGet(AOP(left),i));
+      /* now Z is cleared if `left != right' */
+      emitSKPZ;
+      if (!false_label) false_label = newiTempLabel(NULL);
+      emitpcode(POC_GOTO, popGetLabel(false_label->key));
+    } // for i
+  }
 
-                    emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),size,FALSE,FALSE),7,0));
-                    if(rFalseIfx.condition)
-                        emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-                    else
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
+  /* if we reach here, left == right */
 
-                    emitpcode(POC_MOVLW, popGetLit(0x100-lit));
-                    emitpcode(POC_ADDFW, popGet(AOP(left),0));
-                    emitpcode(POC_MOVFW, popGet(AOP(left),1));
+  if (AOP_SIZE(result) > 0)
+  {
+    emitpcode(POC_INCF, popGet(AOP(result),0));
+  }
 
-                    while(size > 1)
-                        emitpcode(POC_IORFW, popGet(AOP(left),size--));
+  if (ifx && IC_TRUE(ifx))
+  {
+    emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
+  }
 
-                    if(rFalseIfx.condition) {
-                        emitSKPZ;
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
+  if (false_label && (!ifx || IC_TRUE(ifx)))
+    emitpLabel(false_label->key);
 
-                    } else {
-                        emitSKPNZ;
-                    }
+  if (ifx) ifx->generated = 1;
 
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                    emitpLabel(truelbl->key);
-                    if(ifx) ifx->generated = 1;
-                    return;
+  freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+  freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+  freeAsmop(result,NULL,ic,TRUE);
+}
 
-                }
+/*-----------------------------------------------------------------*/
+/* ifxForOp - returns the icode containing the ifx for operand     */
+/*-----------------------------------------------------------------*/
+static iCode *ifxForOp ( operand *op, iCode *ic )
+{
+    FENTRY;
+    /* if true symbol then needs to be assigned */
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    if (IS_TRUE_SYMOP(op))
+        return NULL ;
 
-                if(size == 1) {
+    /* if this has register type condition and
+    the next instruction is ifx with the same operand
+    and live to of the operand is upto the ifx only then */
+    if (ic->next &&
+        ic->next->op == IFX &&
+        IC_COND(ic->next)->key == op->key &&
+        OP_SYMBOL(op)->liveTo <= ic->next->seq )
+        return ic->next;
 
-                    if( (lit & 0xff) == 0) {
-                        /* lower byte is zero */
-                        DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
-                        i = ((lit >> 8) & 0xff) ^0x80;
-                        emitpcode(POC_MOVFW, popGet(AOP(left),size));
-                        emitpcode(POC_ADDLW, popGetLit( 0x80));
-                        emitpcode(POC_ADDLW, popGetLit(0x100-i));
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+    if (ic->next &&
+        ic->next->op == IFX &&
+        IC_COND(ic->next)->key == op->key) {
+        DEBUGpic14_emitcode ("; WARNING ","%d IGNORING liveTo range in %s",__LINE__,__FUNCTION__);
+        return ic->next;
+    }
 
+    DEBUGpic14_emitcode ("; NULL :(","%d",__LINE__);
+    if (ic->next &&
+        ic->next->op == IFX)
+        DEBUGpic14_emitcode ("; ic-next"," is an IFX");
 
-                        if(ifx) ifx->generated = 1;
-                        return;
+    if (ic->next &&
+        ic->next->op == IFX &&
+        IC_COND(ic->next)->key == op->key) {
+        DEBUGpic14_emitcode ("; "," key is okay");
+        DEBUGpic14_emitcode ("; "," key liveTo %d, next->seq = %d",
+            OP_SYMBOL(op)->liveTo,
+            ic->next->seq);
+    }
 
-                    }
-                } else {
-                    /* Special cases for signed longs */
-                    if( (lit & 0xffffff) == 0) {
-                        /* lower byte is zero */
-                        DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
-                        i = ((lit >> 8*3) & 0xff) ^0x80;
-                        emitpcode(POC_MOVFW, popGet(AOP(left),size));
-                        emitpcode(POC_ADDLW, popGetLit( 0x80));
-                        emitpcode(POC_ADDLW, popGetLit(0x100-i));
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
 
+    return NULL;
+}
+/*-----------------------------------------------------------------*/
+/* genAndOp - for && operation                                     */
+/*-----------------------------------------------------------------*/
+static void genAndOp (iCode *ic)
+{
+    operand *left,*right, *result;
+    /*     symbol *tlbl; */
 
-                        if(ifx) ifx->generated = 1;
-                        return;
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    /* note here that && operations that are in an
+    if statement are taken away by backPatchLabels
+    only those used in arthmetic operations remain */
+    aopOp((left=IC_LEFT(ic)),ic,FALSE);
+    aopOp((right=IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,FALSE);
 
-                    }
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                }
+    emitpcode(POC_MOVFW,popGet(AOP(left),0));
+    emitpcode(POC_ANDFW,popGet(AOP(right),0));
+    emitpcode(POC_MOVWF,popGet(AOP(result),0));
 
+    /* if both are bit variables */
+    /*     if (AOP_TYPE(left) == AOP_CRY && */
+    /*         AOP_TYPE(right) == AOP_CRY ) { */
+    /*         pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); */
+    /*         pic14_emitcode("anl","c,%s",AOP(right)->aopu.aop_dir); */
+    /*         pic14_outBitC(result); */
+    /*     } else { */
+    /*         tlbl = newiTempLabel(NULL); */
+    /*         pic14_toBoolean(left);     */
+    /*         pic14_emitcode("jz","%05d_DS_",tlbl->key+100); */
+    /*         pic14_toBoolean(right); */
+    /*         pic14_emitcode("","%05d_DS_:",tlbl->key+100); */
+    /*         pic14_outBitAcc(result); */
+    /*     } */
 
-                if(lit & (0x80 << (size*8))) {
-                    /* lit is negative */
-                    DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-                    //genSkipCond(&rFalseIfx,left,size,7);
 
-                    emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(left),size,FALSE,FALSE),7,0));
+/*-----------------------------------------------------------------*/
+/* genOrOp - for || operation                                      */
+/*-----------------------------------------------------------------*/
+/*
+tsd pic port -
+modified this code, but it doesn't appear to ever get called
+*/
 
-                    if(rFalseIfx.condition)
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-                    else
-                        emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
+static void genOrOp (iCode *ic)
+{
+    operand *left,*right, *result;
+    symbol *tlbl;
+    int i;
 
+    /* note here that || operations that are in an
+    if statement are taken away by backPatchLabels
+    only those used in arthmetic operations remain */
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    aopOp((left=IC_LEFT(ic)),ic,FALSE);
+    aopOp((right=IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,FALSE);
 
-                } else {
-                    /* lit is positive */
-                    DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
-                    emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),size,FALSE,FALSE),7,0));
-                    if(rFalseIfx.condition)
-                        emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-                    else
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                }
+    for (i=0; i < AOP_SIZE(result); i++)
+    {
+        emitpcode(POC_CLRF, popGet(AOP(result), i));
+    } // for i
 
-                /* There are no more special cases, so perform a general compare */
+    tlbl = newiTempLabel(NULL);
+    pic14_toBoolean(left);
+    emitSKPZ;
+    emitpcode(POC_GOTO, popGetLabel(tlbl->key));
+    pic14_toBoolean(right);
+    emitpLabel(tlbl->key);
+    /* here Z is clear IFF `left || right' */
+    emitSKPZ;
+    emitpcode(POC_INCF, popGet(AOP(result), 0));
 
-                emitpcode(POC_MOVLW, popGetLit((lit >> (size*8)) & 0xff));
-                emitpcode(POC_SUBFW, popGet(AOP(left),size));
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-                while(size--) {
+/*-----------------------------------------------------------------*/
+/* isLiteralBit - test if lit == 2^n                               */
+/*-----------------------------------------------------------------*/
+static int isLiteralBit(unsigned long lit)
+{
+    unsigned long pw[32] = {1L,2L,4L,8L,16L,32L,64L,128L,
+        0x100L,0x200L,0x400L,0x800L,
+        0x1000L,0x2000L,0x4000L,0x8000L,
+        0x10000L,0x20000L,0x40000L,0x80000L,
+        0x100000L,0x200000L,0x400000L,0x800000L,
+        0x1000000L,0x2000000L,0x4000000L,0x8000000L,
+        0x10000000L,0x20000000L,0x40000000L,0x80000000L};
+    int idx;
 
-                    emitpcode(POC_MOVLW, popGetLit((lit >> (size*8)) & 0xff));
-                    emitSKPNZ;
-                    emitpcode(POC_SUBFW, popGet(AOP(left),size));
-                }
-                //rFalseIfx.condition ^= 1;
-                genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    for(idx = 0; idx < 32; idx++)
+        if(lit == pw[idx])
+            return idx+1;
+        return 0;
+}
 
-                emitpLabel(truelbl->key);
+/*-----------------------------------------------------------------*/
+/* continueIfTrue -                                                */
+/*-----------------------------------------------------------------*/
+static void continueIfTrue (iCode *ic)
+{
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    if(IC_TRUE(ic))
+    {
+        // Why +100?!?
+        emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
+        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+    }
+    ic->generated = 1;
+}
 
-                if(ifx) ifx->generated = 1;
-                return;
+/*-----------------------------------------------------------------*/
+/* jmpIfTrue -                                                     */
+/*-----------------------------------------------------------------*/
+static void jumpIfTrue (iCode *ic)
+{
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    if(!IC_TRUE(ic))
+    {
+        // Why +100?!?
+        emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
+        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+    }
+    ic->generated = 1;
+}
 
+/*-----------------------------------------------------------------*/
+/* jmpTrueOrFalse -                                                */
+/*-----------------------------------------------------------------*/
+static void jmpTrueOrFalse (iCode *ic, symbol *tlbl)
+{
+    FENTRY;
+    // ugly but optimized by peephole
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    if(IC_TRUE(ic)){
+        symbol *nlbl = newiTempLabel(NULL);
+        pic14_emitcode("sjmp","%05d_DS_",nlbl->key+100);
+        pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+        pic14_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
+        pic14_emitcode("","%05d_DS_:",nlbl->key+100);
+    }
+    else{
+        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
+        pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+    }
+    ic->generated = 1;
+}
 
-            }
-
-
-            /* sign is out of the way. So now do an unsigned compare */
-            DEBUGpic14_emitcode(";right lit","line = %d unsigned compare to 0x%x",__LINE__,lit);
-
-
-            /* General case - compare to an unsigned literal on the right.*/
-
-            i = (lit >> (size*8)) & 0xff;
-            emitpcode(POC_MOVLW, popGetLit(i));
-            emitpcode(POC_SUBFW, popGet(AOP(left),size));
-            while(size--) {
-                i = (lit >> (size*8)) & 0xff;
-
-                if(i) {
-                    emitpcode(POC_MOVLW, popGetLit(i));
-                    emitSKPNZ;
-                    emitpcode(POC_SUBFW, popGet(AOP(left),size));
-                } else {
-                /* this byte of the lit is zero,
-                    *if it's not the last then OR in the variable */
-                    if(size)
-                        emitpcode(POC_IORFW, popGet(AOP(left),size));
-                }
-            }
-
-
-        emitpLabel(lbl->key);
-        //if(emitFinalCheck)
-        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-        if(sign)
-            emitpLabel(truelbl->key);
-
-        if(ifx) ifx->generated = 1;
-        return;
-
+/*-----------------------------------------------------------------*/
+/* genAnd  - code for and                                          */
+/*-----------------------------------------------------------------*/
+static void genAnd (iCode *ic, iCode *ifx)
+{
+    operand *left, *right, *result;
+    int size, offset=0;
+    unsigned long lit = 0L;
+    int bytelit = 0;
+    resolvedIfx rIfx;
 
-        }
-#endif  // _swapp
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    aopOp((left = IC_LEFT(ic)),ic,FALSE);
+    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
-        if(AOP_TYPE(left) == AOP_LIT) {
-            //symbol *lbl = newiTempLabel(NULL);
+    resolveIfx(&rIfx,ifx);
 
-            //EXPERIMENTAL lit = ulFromVal(AOP(left)->aopu.aop_lit);
+    /* if left is a literal & right is not then exchange them */
+    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
+        AOP_NEEDSACC(left)) {
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
+    /* if result = right then exchange them */
+    if(pic14_sameRegs(AOP(result),AOP(right))){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-            DEBUGpic14_emitcode(";left lit","lit = 0x%x,sign=%d",lit,sign);
+    /* if right is bit then exchange them */
+    if (AOP_TYPE(right) == AOP_CRY &&
+        AOP_TYPE(left) != AOP_CRY){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
+    if(AOP_TYPE(right) == AOP_LIT)
+        lit = ulFromVal (AOP(right)->aopu.aop_lit);
 
-            /* Special cases */
-            if((lit == 0) && (sign == 0)){
+    size = AOP_SIZE(result);
 
-                size--;
-                emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                while(size)
-                    emitpcode(POC_IORFW, popGet(AOP(right),--size));
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                genSkipz2(&rFalseIfx,0);
-                if(ifx) ifx->generated = 1;
-                return;
+    // if(bit & yy)
+    // result = bit & yy;
+    if (AOP_TYPE(left) == AOP_CRY){
+        // c = bit & literal;
+        if(AOP_TYPE(right) == AOP_LIT){
+            if(lit & 1) {
+                if(size && pic14_sameRegs(AOP(result),AOP(left)))
+                    // no change
+                    goto release;
+                pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
+            } else {
+                // bit(result) = 0;
+                if(size && (AOP_TYPE(result) == AOP_CRY)){
+                    pic14_emitcode("clr","%s",AOP(result)->aopu.aop_dir);
+                    goto release;
+                }
+                if((AOP_TYPE(result) == AOP_CRY) && ifx){
+                    jumpIfTrue(ifx);
+                    goto release;
+                }
+                pic14_emitcode("clr","c");
+            }
+        } else {
+            if (AOP_TYPE(right) == AOP_CRY){
+                // c = bit & bit;
+                pic14_emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
+                pic14_emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
+            } else {
+                // c = bit & val;
+                MOVA(aopGet(AOP(right),0,FALSE,FALSE));
+                // c = lsb
+                pic14_emitcode("rrc","a");
+                pic14_emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
             }
+        }
+        // bit = c
+        // val = c
+        if(size)
+            pic14_outBitC(result);
+        // if(bit & ...)
+        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
+            genIfxJump(ifx, "c");
+        goto release ;
+    }
 
-            if(size==1) {
-                /* Special cases */
-                lit &= 0xff;
-                if(((lit == 0xff) && !sign) || ((lit==0x7f) && sign)) {
-                    /* degenerate compare can never be true */
-                    if(rFalseIfx.condition == 0)
-                        emitpcode(POC_GOTO,popGetLabel(rFalseIfx.lbl->key));
+    // if(val & 0xZZ)       - size = 0, ifx != FALSE  -
+    // bit = val & 0xZZ     - size = 1, ifx = FALSE -
+    if((AOP_TYPE(right) == AOP_LIT) &&
+        (AOP_TYPE(result) == AOP_CRY) &&
+        (AOP_TYPE(left) != AOP_CRY)){
+        int posbit = isLiteralBit(lit);
+        /* left &  2^n */
+        if(posbit){
+            posbit--;
+            //MOVA(aopGet(AOP(left),posbit>>3,FALSE,FALSE));
+            // bit = left & 2^n
+            if(size)
+                pic14_emitcode("mov","c,acc.%d",posbit&0x07);
+            // if(left &  2^n)
+            else{
+                if(ifx){
+                    int offset = 0;
+                    while (posbit > 7) {
+                        posbit -= 8;
+                        offset++;
+                    }
+                    emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
+                        newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit,0));
+                    emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
 
-                    if(ifx) ifx->generated = 1;
-                    return;
+                    ifx->generated = 1;
                 }
-
-                if(sign) {
-                    /* signed comparisons to a literal byte */
-
-                    int lp1 = (lit+1) & 0xff;
-
-                    DEBUGpic14_emitcode(";left lit","line = %d lit = 0x%x",__LINE__,lit);
-                    switch (lp1) {
-                    case 0:
-                        rFalseIfx.condition ^= 1;
-                        genSkipCond(&rFalseIfx,right,0,7);
-                        break;
-                    case 0x7f:
-                        emitpcode(POC_MOVFW, popGet(AOP(right),0));
-                        emitpcode(POC_XORLW, popGetLit(0x7f));
-                        genSkipz2(&rFalseIfx,1);
-                        break;
-                    default:
-                        emitpcode(POC_MOVFW, popGet(AOP(right),0));
-                        emitpcode(POC_ADDLW, popGetLit(0x80));
-                        emitpcode(POC_ADDLW, popGetLit(((0-(lit+1)) & 0xff) ^ 0x80));
-                        rFalseIfx.condition ^= 1;
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                        break;
+                goto release;
+            }
+        } else {
+            symbol *tlbl = newiTempLabel(NULL);
+            int sizel = AOP_SIZE(left);
+            if(size)
+                pic14_emitcode("setb","c");
+            while(sizel--){
+                if((bytelit = ((lit >> (offset*8)) & 0x0FFL)) != 0x0L){
+                    mov2w( AOP(left), offset);
+                    // byte ==  2^n ?
+                    if((posbit = isLiteralBit(bytelit)) != 0) {
+                        emitpcode(rIfx.condition ? POC_BTFSC : POC_BTFSS, // XXX: or the other way round?
+                            newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit - 1, 0));
+                        pic14_emitcode("jb","acc.%d,%05d_DS_",(posbit-1)&0x07,tlbl->key+100);
                     }
-                    if(ifx) ifx->generated = 1;
-                } else {
-                    /* unsigned comparisons to a literal byte */
-
-                    switch(lit & 0xff ) {
-                    case 0:
-                        emitpcode(POC_MOVFW, popGet(AOP(right),0));
-                        genSkipz2(&rFalseIfx,0);
-                        if(ifx) ifx->generated = 1;
-                        break;
-                    case 0x7f:
-                        genSkipCond(&rFalseIfx,right,0,7);
-                        if(ifx) ifx->generated = 1;
-                        break;
+                    else{
+                        emitpcode(POC_ANDLW, newpCodeOpLit(bytelit & 0x0ff));
+                        if (rIfx.condition) emitSKPZ;
+                        else emitSKPNZ;
 
-                    default:
-                        emitpcode(POC_MOVLW, popGetLit((lit+1) & 0xff));
-                        emitpcode(POC_SUBFW, popGet(AOP(right),0));
-                        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-                        rFalseIfx.condition ^= 1;
-                        if (AOP_TYPE(result) == AOP_CRY) {
-                            genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                            if(ifx) ifx->generated = 1;
-                        } else {
-                            DEBUGpic14_emitcode ("; ***","%s  %d RFIfx.cond=%d",__FUNCTION__,__LINE__, rFalseIfx.condition);
-                            emitpcode(POC_CLRF, popGet(AOP(result),0));
-                            emitpcode(POC_RLF, popGet(AOP(result),0));
-                            emitpcode(POC_MOVLW, popGetLit(0x01));
-                            emitpcode(POC_XORWF, popGet(AOP(result),0));
+                        if(bytelit != 0x0FFL)
+                        {
+                            pic14_emitcode("anl","a,%s",
+                            aopGet(AOP(right),offset,FALSE,TRUE));
                         }
-                        break;
-                    }
-                }
-
-                //goto check_carry;
-                return;
-
-            } else {
-
-                /* Size is greater than 1 */
-
-                if(sign) {
-                    int lp1 = lit+1;
-
-                    size--;
-
-                    if(lp1 == 0) {
-                        /* this means lit = 0xffffffff, or -1 */
-
-
-                        DEBUGpic14_emitcode(";left lit = -1","line = %d ",__LINE__);
-                        rFalseIfx.condition ^= 1;
-                        genSkipCond(&rFalseIfx,right,size,7);
-                        if(ifx) ifx->generated = 1;
-                        return;
+                        pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
                     }
 
-                    if(lit == 0) {
-                        int s = size;
+                    emitpcode(POC_GOTO, popGetLabel(rIfx.lbl->key));
+                    ifx->generated = 1;
 
-                        if(rFalseIfx.condition) {
-                            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
-                            emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-                        }
+                }
+                offset++;
+            }
+            // bit = left & literal
+            if(size){
+                pic14_emitcode("clr","c");
+                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+            }
+            // if(left & literal)
+            else{
+                if(ifx)
+                    jmpTrueOrFalse(ifx, tlbl);
+                goto release ;
+            }
+        }
+        pic14_outBitC(result);
+        goto release ;
+    }
 
-                        emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                        while(size--)
-                            emitpcode(POC_IORFW, popGet(AOP(right),size));
+    /* if left is same as result */
+    if(pic14_sameRegs(AOP(result),AOP(left))){
+        int know_W = -1;
+        for(;size--; offset++,lit>>=8) {
+            if(AOP_TYPE(right) == AOP_LIT){
+                switch(lit & 0xff) {
+                case 0x00:
+                    /*  and'ing with 0 has clears the result */
+                    emitpcode(POC_CLRF,popGet(AOP(result),offset));
+                    break;
+                case 0xff:
+                    /* and'ing with 0xff is a nop when the result and left are the same */
+                    break;
 
+                default:
+                    {
+                        int p = my_powof2( (~lit) & 0xff );
+                        if(p>=0) {
+                            /* only one bit is set in the literal, so use a bcf instruction */
+                            emitpcode(POC_BCF,newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),p,0));
 
-                        emitSKPZ;
-                        if(rFalseIfx.condition) {
-                            emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-                            emitpLabel(truelbl->key);
-                        }else {
-                            rFalseIfx.condition ^= 1;
-                            genSkipCond(&rFalseIfx,right,s,7);
+                        } else {
+                            if(know_W != (int)(lit&0xff))
+                                emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
+                            know_W = lit &0xff;
+                            emitpcode(POC_ANDWF,popGet(AOP(left),offset));
                         }
-
-                        if(ifx) ifx->generated = 1;
-                        return;
-                    }
-
-                    if((size == 1) &&  (0 == (lp1&0xff))) {
-                        /* lower byte of signed word is zero */
-                        DEBUGpic14_emitcode(";left lit","line = %d  0x%x+1 low byte is zero",__LINE__,lit);
-                        i = ((lp1 >> 8) & 0xff) ^0x80;
-                        emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                        emitpcode(POC_ADDLW, popGetLit( 0x80));
-                        emitpcode(POC_ADDLW, popGetLit(0x100-i));
-                        rFalseIfx.condition ^= 1;
-                        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-
-
-                        if(ifx) ifx->generated = 1;
-                        return;
                     }
+                }
+            } else {
+                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+                emitpcode(POC_ANDWF,popGet(AOP(left),offset));
+            }
+        }
 
-                    if(lit & (0x80 << (size*8))) {
-                        /* Lit is less than zero */
-                        DEBUGpic14_emitcode(";left lit","line = %d  0x%x is less than 0",__LINE__,lit);
-                        //rFalseIfx.condition ^= 1;
-                        //genSkipCond(&rFalseIfx,left,size,7);
-                        //rFalseIfx.condition ^= 1;
-                        emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
-                        //emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-
-                        if(rFalseIfx.condition)
-                            emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-                        else
-                            emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-
-
-                    } else {
-                        /* Lit is greater than or equal to zero */
-                        DEBUGpic14_emitcode(";left lit","line = %d  0x%x is greater than 0",__LINE__,lit);
-                        //rFalseIfx.condition ^= 1;
-                        //genSkipCond(&rFalseIfx,right,size,7);
-                        //rFalseIfx.condition ^= 1;
-
-                        //emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
-                        //emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-
-                        emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
-                        if(rFalseIfx.condition)
-                            emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-                        else
-                            emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-
-                    }
-
-
-                    emitpcode(POC_MOVLW, popGetLit((lp1 >> (size*8)) & 0xff));
-                    emitpcode(POC_SUBFW, popGet(AOP(right),size));
-
-                    while(size--) {
-
-                        emitpcode(POC_MOVLW, popGetLit((lp1 >> (size*8)) & 0xff));
-                        emitSKPNZ;
-                        emitpcode(POC_SUBFW, popGet(AOP(right),size));
+    } else {
+        // left & result in different registers
+        if(AOP_TYPE(result) == AOP_CRY){
+            // result = bit
+            // if(size), result in bit
+            // if(!size && ifx), conditional oper: if(left & right)
+            symbol *tlbl = newiTempLabel(NULL);
+            int sizer = min(AOP_SIZE(left),AOP_SIZE(right));
+            if(size)
+                pic14_emitcode("setb","c");
+            while(sizer--){
+                MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+                pic14_emitcode("anl","a,%s",
+                    aopGet(AOP(left),offset,FALSE,FALSE));
+                pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
+                offset++;
+            }
+            if(size){
+                CLRC;
+                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+                pic14_outBitC(result);
+            } else if(ifx)
+                jmpTrueOrFalse(ifx, tlbl);
+        } else {
+            for(;(size--);offset++) {
+                // normal case
+                // result = left & right
+                if(AOP_TYPE(right) == AOP_LIT){
+                    int t = (lit >> (offset*8)) & 0x0FFL;
+                    switch(t) {
+                    case 0x00:
+                        emitpcode(POC_CLRF,popGet(AOP(result),offset));
+                        break;
+                    case 0xff:
+                        emitpcode(POC_MOVFW,popGet(AOP(left),offset));
+                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+                        break;
+                    default:
+                        emitpcode(POC_MOVLW, popGetLit(t));
+                        emitpcode(POC_ANDFW,popGet(AOP(left),offset));
+                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
                     }
-                    rFalseIfx.condition ^= 1;
-                    //rFalseIfx.condition = 1;
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+                    continue;
+                }
 
-                    emitpLabel(truelbl->key);
+                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+                emitpcode(POC_ANDFW,popGet(AOP(left),offset));
+                emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+            }
+        }
+    }
 
-                    if(ifx) ifx->generated = 1;
-                    return;
-                    // end of if (sign)
-                } else {
+release :
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-                    /* compare word or long to an unsigned literal on the right.*/
-
-
-                    size--;
-                    if(lit < 0xff) {
-                        DEBUGpic14_emitcode ("; ***","%s  %d lit =0x%x < 0xff",__FUNCTION__,__LINE__,lit);
-                        switch (lit) {
-                        case 0:
-                            break; /* handled above */
-                        /*
-                        case 0xff:
-                            emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                            while(size--)
-                                emitpcode(POC_IORFW, popGet(AOP(right),size));
-                            genSkipz2(&rFalseIfx,0);
-                            break;
-                        */
-                        default:
-                            emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                            while(--size)
-                                emitpcode(POC_IORFW, popGet(AOP(right),size));
-
-                            emitSKPZ;
-                            if(rFalseIfx.condition)
-                                emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
-                            else
-                                emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-
-
-                            emitpcode(POC_MOVLW, popGetLit(lit+1));
-                            emitpcode(POC_SUBFW, popGet(AOP(right),0));
-
-                            rFalseIfx.condition ^= 1;
-                            genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                        }
+/*-----------------------------------------------------------------*/
+/* genOr  - code for or                                            */
+/*-----------------------------------------------------------------*/
+static void genOr (iCode *ic, iCode *ifx)
+{
+    operand *left, *right, *result;
+    int size, offset=0;
+    unsigned long lit = 0L;
 
-                        emitpLabel(truelbl->key);
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-                        if(ifx) ifx->generated = 1;
-                        return;
-                    }
+    aopOp((left = IC_LEFT(ic)),ic,FALSE);
+    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                    lit++;
-                    DEBUGpic14_emitcode ("; ***","%s  %d lit =0x%x",__FUNCTION__,__LINE__,lit);
-                    i = (lit >> (size*8)) & 0xff;
+    /* if left is a literal & right is not then exchange them */
+    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
+        AOP_NEEDSACC(left)) {
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-                    emitpcode(POC_MOVLW, popGetLit(i));
-                    emitpcode(POC_SUBFW, popGet(AOP(right),size));
+    /* if result = right then exchange them */
+    if(pic14_sameRegs(AOP(result),AOP(right))){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-                    while(size--) {
-                        i = (lit >> (size*8)) & 0xff;
+    /* if right is bit then exchange them */
+    if (AOP_TYPE(right) == AOP_CRY &&
+        AOP_TYPE(left) != AOP_CRY){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-                        if(i) {
-                            emitpcode(POC_MOVLW, popGetLit(i));
-                            emitSKPNZ;
-                            emitpcode(POC_SUBFW, popGet(AOP(right),size));
-                        } else {
-                        /* this byte of the lit is zero,
-                            *if it's not the last then OR in the variable */
-                            if(size)
-                                emitpcode(POC_IORFW, popGet(AOP(right),size));
-                        }
-                    }
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
+    if(AOP_TYPE(right) == AOP_LIT)
+        lit = ulFromVal (AOP(right)->aopu.aop_lit);
 
-                    emitpLabel(lbl->key);
+    size = AOP_SIZE(result);
 
-                    rFalseIfx.condition ^= 1;
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+    // if(bit | yy)
+    // xx = bit | yy;
+    if (AOP_TYPE(left) == AOP_CRY){
+        if(AOP_TYPE(right) == AOP_LIT){
+            // c = bit & literal;
+            if(lit){
+                // lit != 0 => result = 1
+                if(AOP_TYPE(result) == AOP_CRY){
+                    if(size)
+                        emitpcode(POC_BSF, popGet(AOP(result),0));
+                    //pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
+                    //   AOP(result)->aopu.aop_dir,
+                    //   AOP(result)->aopu.aop_dir);
+                    else if(ifx)
+                        continueIfTrue(ifx);
+                    goto release;
                 }
-
-                if(sign)
-                    emitpLabel(truelbl->key);
-                if(ifx) ifx->generated = 1;
-                return;
-            }
-        }
-        /* Compare two variables */
-
-        DEBUGpic14_emitcode(";sign","%d",sign);
-
-        size--;
-        if(sign) {
-            /* Sigh. thus sucks... */
-            if(size) {
-                emitpcode(POC_MOVFW, popGet(AOP(left),size));
-                emitpcode(POC_MOVWF, popRegFromIdx(Gstack_base_addr));
-                emitpcode(POC_MOVLW, popGetLit(0x80));
-                emitpcode(POC_XORWF, popRegFromIdx(Gstack_base_addr));
-                emitpcode(POC_XORFW, popGet(AOP(right),size));
-                emitpcode(POC_SUBFW, popRegFromIdx(Gstack_base_addr));
             } else {
-                /* Signed char comparison */
-                /* Special thanks to Nikolai Golovchenko for this snippet */
-                emitpcode(POC_MOVFW, popGet(AOP(right),0));
-                emitpcode(POC_SUBFW, popGet(AOP(left),0));
-                emitpcode(POC_RRFW,  popGet(AOP(left),0)); /* could be any register */
-                emitpcode(POC_XORFW, popGet(AOP(left),0));
-                emitpcode(POC_XORFW, popGet(AOP(right),0));
-                emitpcode(POC_ADDLW, popGetLit(0x80));
-
-                DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-                genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-
-                if(ifx) ifx->generated = 1;
-                return;
+                // lit == 0 => result = left
+                if(size && pic14_sameRegs(AOP(result),AOP(left)))
+                    goto release;
+                pic14_emitcode(";XXX mov","c,%s  %s,%d",AOP(left)->aopu.aop_dir,__FILE__,__LINE__);
             }
-
         } else {
+            if (AOP_TYPE(right) == AOP_CRY){
+                if(pic14_sameRegs(AOP(result),AOP(left))){
+                    // c = bit | bit;
+                    emitpcode(POC_BCF,   popGet(AOP(result),0));
+                    emitpcode(POC_BTFSC, popGet(AOP(right),0));
+                    emitpcode(POC_BSF,   popGet(AOP(result),0));
 
-            emitpcode(POC_MOVFW, popGet(AOP(right),size));
-            emitpcode(POC_SUBFW, popGet(AOP(left),size));
-        }
-
-
-        /* The rest of the bytes of a multi-byte compare */
-        while (size) {
-
-            emitSKPZ;
-            emitpcode(POC_GOTO,  popGetLabel(lbl->key));
-            size--;
+                    pic14_emitcode("bcf","(%s >> 3), (%s & 7)",
+                        AOP(result)->aopu.aop_dir,
+                        AOP(result)->aopu.aop_dir);
+                    pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
+                        AOP(right)->aopu.aop_dir,
+                        AOP(right)->aopu.aop_dir);
+                    pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
+                        AOP(result)->aopu.aop_dir,
+                        AOP(result)->aopu.aop_dir);
+                } else {
+                        emitpcode(POC_BCF,   popGet(AOP(result),0));
+                        emitpcode(POC_BTFSS, popGet(AOP(right),0));
+                        emitpcode(POC_BTFSC, popGet(AOP(left),0));
+                        emitpcode(POC_BSF,   popGet(AOP(result),0));
+                }
+            } else {
+                // c = bit | val;
+                symbol *tlbl = newiTempLabel(NULL);
+                pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
 
-            emitpcode(POC_MOVFW, popGet(AOP(right),size));
-            emitpcode(POC_SUBFW, popGet(AOP(left),size));
 
+                emitpcode(POC_BCF,   popGet(AOP(result),0));
 
+                if(!((AOP_TYPE(result) == AOP_CRY) && ifx))
+                    pic14_emitcode(";XXX setb","c");
+                pic14_emitcode(";XXX jb","%s,%05d_DS_",
+                    AOP(left)->aopu.aop_dir,tlbl->key+100);
+                pic14_toBoolean(right);
+                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
+                if((AOP_TYPE(result) == AOP_CRY) && ifx){
+                    jmpTrueOrFalse(ifx, tlbl);
+                    goto release;
+                } else {
+                    CLRC;
+                    pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+                }
+            }
         }
+        // bit = c
+        // val = c
+        if(size)
+            pic14_outBitC(result);
+        // if(bit | ...)
+        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
+            genIfxJump(ifx, "c");
+        goto release ;
+    }
 
-        emitpLabel(lbl->key);
-
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-        if ((AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) ||
-            (AOP_TYPE(result) == AOP_REG)) {
-            emitpcode(POC_CLRF, popGet(AOP(result),0));
-            emitpcode(POC_RLF, popGet(AOP(result),0));
+    // if(val | 0xZZ)       - size = 0, ifx != FALSE  -
+    // bit = val | 0xZZ     - size = 1, ifx = FALSE -
+    if((AOP_TYPE(right) == AOP_LIT) &&
+      (AOP_TYPE(result) == AOP_CRY) &&
+      (AOP_TYPE(left) != AOP_CRY)){
+        if(lit){
+            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
+            // result = 1
+            if(size)
+                pic14_emitcode(";XXX setb","%s",AOP(result)->aopu.aop_dir);
+            else
+                continueIfTrue(ifx);
+            goto release;
         } else {
-            genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
+            // lit = 0, result = boolean(left)
+            if(size)
+                pic14_emitcode(";XXX setb","c");
+            pic14_toBoolean(right);
+            if(size){
+                symbol *tlbl = newiTempLabel(NULL);
+                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
+                CLRC;
+                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+            } else {
+                genIfxJump (ifx,"a");
+                goto release;
+            }
         }
-        //genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-        if(ifx) ifx->generated = 1;
-
-        return;
-
-    }
-
-    // check_carry:
-    if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) {
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
         pic14_outBitC(result);
-    } else {
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-        /* if the result is used in the next
-        ifx conditional branch then generate
-        code a little differently */
-        if (ifx )
-            genIfxJump (ifx,"c");
-        else
-            pic14_outBitC(result);
-        /* leave the result in acc */
+        goto release ;
     }
 
-}
-#endif
+    /* if left is same as result */
+    if(pic14_sameRegs(AOP(result),AOP(left))){
+        int know_W = -1;
+        for(;size--; offset++,lit>>=8) {
+            if(AOP_TYPE(right) == AOP_LIT){
+                if((lit & 0xff) == 0)
+                    /*  or'ing with 0 has no effect */
+                    continue;
+                else {
+                    int p = my_powof2(lit & 0xff);
+                    if(p>=0) {
+                        /* only one bit is set in the literal, so use a bsf instruction */
+                        emitpcode(POC_BSF,
+                            newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),p,0));
+                    } else {
+                        if(know_W != (int)(lit & 0xff))
+                            emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
+                        know_W = lit & 0xff;
+                        emitpcode(POC_IORWF, popGet(AOP(left),offset));
+                    }
 
-/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison                             */
-/*-----------------------------------------------------------------*/
-static void genCmpGt (iCode *ic, iCode *ifx)
-{
-    operand *left, *right, *result;
-    sym_link *letype , *retype;
-    int sign ;
+                }
+            } else {
+                emitpcode(POC_MOVFW,  popGet(AOP(right),offset));
+                emitpcode(POC_IORWF,  popGet(AOP(left),offset));
+            }
+        }
+    } else {
+        // left & result in different registers
+        if(AOP_TYPE(result) == AOP_CRY){
+            // result = bit
+            // if(size), result in bit
+            // if(!size && ifx), conditional oper: if(left | right)
+            symbol *tlbl = newiTempLabel(NULL);
+            int sizer = max(AOP_SIZE(left),AOP_SIZE(right));
+            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    left = IC_LEFT(ic);
-    right= IC_RIGHT(ic);
-    result = IC_RESULT(ic);
 
-    letype = getSpec(operandType(left));
-    retype =getSpec(operandType(right));
-    sign =  !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
-    /* assign the amsops */
-    aopOp (left,ic,FALSE);
-    aopOp (right,ic,FALSE);
-    aopOp (result,ic,TRUE);
+            if(size)
+                pic14_emitcode(";XXX setb","c");
+            while(sizer--){
+                MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+                pic14_emitcode(";XXX orl","a,%s",
+                    aopGet(AOP(left),offset,FALSE,FALSE));
+                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
+                offset++;
+            }
+            if(size){
+                CLRC;
+                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+                pic14_outBitC(result);
+            } else if(ifx)
+                jmpTrueOrFalse(ifx, tlbl);
+        } else for(;(size--);offset++){
+            // normal case
+            // result = left | right
+            if(AOP_TYPE(right) == AOP_LIT){
+                int t = (lit >> (offset*8)) & 0x0FFL;
+                switch(t) {
+                case 0x00:
+                    emitpcode(POC_MOVFW,  popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
 
-    genCmp(right, left, result, ifx, sign);
+                    break;
+                default:
+                    emitpcode(POC_MOVLW,  popGetLit(t));
+                    emitpcode(POC_IORFW,  popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
+                }
+                continue;
+            }
+
+            // faster than result <- left, anl result,right
+            // and better if result is SFR
+            emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+            emitpcode(POC_IORFW,popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
+        }
+    }
 
+release :
     freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
     freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
     freeAsmop(result,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
-/* genCmpLt - less than comparisons                                */
+/* genXor - code for xclusive or                                   */
 /*-----------------------------------------------------------------*/
-static void genCmpLt (iCode *ic, iCode *ifx)
+static void genXor (iCode *ic, iCode *ifx)
 {
     operand *left, *right, *result;
-    sym_link *letype , *retype;
-    int sign ;
+    int size, offset=0;
+    unsigned long lit = 0L;
 
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    left = IC_LEFT(ic);
-    right= IC_RIGHT(ic);
-    result = IC_RESULT(ic);
-
-    letype = getSpec(operandType(left));
-    retype =getSpec(operandType(right));
-    sign =  !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
-
-    /* assign the amsops */
-    aopOp (left,ic,FALSE);
-    aopOp (right,ic,FALSE);
-    aopOp (result,ic,TRUE);
 
-    genCmp(left, right, result, ifx, sign);
-
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genCmpEq - generates code for equal to                          */
-/*-----------------------------------------------------------------*/
-static void genCmpEq (iCode *ic, iCode *ifx)
-{
-  operand *left, *right, *result;
-  int size;
-  symbol *false_label;
-
-  FENTRY;
-  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-  if(ifx)
-    DEBUGpic14_emitcode ("; ifx is non-null","");
-  else
-    DEBUGpic14_emitcode ("; ifx is null","");
+    aopOp((left = IC_LEFT(ic)),ic,FALSE);
+    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
-  aopOp((left=IC_LEFT(ic)),ic,FALSE);
-  aopOp((right=IC_RIGHT(ic)),ic,FALSE);
-  aopOp((result=IC_RESULT(ic)),ic,TRUE);
+    /* if left is a literal & right is not ||
+    if left needs acc & right does not */
+    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
+        (AOP_NEEDSACC(left) && !AOP_NEEDSACC(right))) {
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-  DEBUGpic14_AopType(__LINE__,left,right,result);
+    /* if result = right then exchange them */
+    if(pic14_sameRegs(AOP(result),AOP(right))){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
 
-  /* if literal, move literal to right */
-  if (op_isLitLike (IC_LEFT(ic))) {
-    operand *tmp = right ;
-    right = left;
-    left = tmp;
-  }
+    /* if right is bit then exchange them */
+    if (AOP_TYPE(right) == AOP_CRY &&
+        AOP_TYPE(left) != AOP_CRY){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
+    }
+    if(AOP_TYPE(right) == AOP_LIT)
+        lit = ulFromVal (AOP(right)->aopu.aop_lit);
 
-  false_label = NULL;
-  if (ifx && !IC_TRUE(ifx))
-  {
-    assert (IC_FALSE(ifx));
-    false_label = IC_FALSE(ifx);
-  }
+    size = AOP_SIZE(result);
 
-  size = min(AOP_SIZE(left),AOP_SIZE(right));
-  assert(!pic14_sameRegs(AOP(result),AOP(left)));
-  assert(!pic14_sameRegs(AOP(result),AOP(right)));
+    // if(bit ^ yy)
+    // xx = bit ^ yy;
+    if (AOP_TYPE(left) == AOP_CRY){
+        if(AOP_TYPE(right) == AOP_LIT){
+            // c = bit & literal;
+            if(lit>>1){
+                // lit>>1  != 0 => result = 1
+                if(AOP_TYPE(result) == AOP_CRY){
+                    if(size)
+                    {emitpcode(POC_BSF,  popGet(AOP(result),offset));
+                    pic14_emitcode("setb","%s",AOP(result)->aopu.aop_dir);}
+                    else if(ifx)
+                        continueIfTrue(ifx);
+                    goto release;
+                }
+                pic14_emitcode("setb","c");
+            } else{
+                // lit == (0 or 1)
+                if(lit == 0){
+                    // lit == 0, result = left
+                    if(size && pic14_sameRegs(AOP(result),AOP(left)))
+                        goto release;
+                    pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
+                } else{
+                    // lit == 1, result = not(left)
+                    if(size && pic14_sameRegs(AOP(result),AOP(left))){
+                        emitpcode(POC_MOVLW,  popGet(AOP(result),offset));
+                        emitpcode(POC_XORWF,  popGet(AOP(result),offset));
+                        pic14_emitcode("cpl","%s",AOP(result)->aopu.aop_dir);
+                        goto release;
+                    } else {
+                        assert ( !"incomplete genXor" );
+                        pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
+                        pic14_emitcode("cpl","c");
+                    }
+                }
+            }
 
-  /* assume left != right */
-  {
-    int i;
-    for (i=0; i < AOP_SIZE(result); i++)
-    {
-      emitpcode(POC_CLRF, popGet(AOP(result),i));
+        } else {
+            // right != literal
+            symbol *tlbl = newiTempLabel(NULL);
+            if (AOP_TYPE(right) == AOP_CRY){
+                // c = bit ^ bit;
+                pic14_emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
+            }
+            else{
+                int sizer = AOP_SIZE(right);
+                // c = bit ^ val
+                // if val>>1 != 0, result = 1
+                pic14_emitcode("setb","c");
+                while(sizer){
+                    MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE));
+                    if(sizer == 1)
+                        // test the msb of the lsb
+                        pic14_emitcode("anl","a,#0xfe");
+                    pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
+                    sizer--;
+                }
+                // val = (0,1)
+                pic14_emitcode("rrc","a");
+            }
+            pic14_emitcode("jnb","%s,%05d_DS_",AOP(left)->aopu.aop_dir,(tlbl->key+100));
+            pic14_emitcode("cpl","c");
+            pic14_emitcode("","%05d_DS_:",(tlbl->key+100));
+        }
+        // bit = c
+        // val = c
+        if(size)
+            pic14_outBitC(result);
+        // if(bit | ...)
+        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
+            genIfxJump(ifx, "c");
+        goto release ;
     }
-  }
-
-  if (AOP_TYPE(right) == AOP_LIT)
-  {
-    unsigned long lit = ulFromVal (AOP(right)->aopu.aop_lit);
-    int i;
-    size = AOP_SIZE(left);
-    assert(!op_isLitLike(left));
 
-    switch (lit)
-    {
-      case 0:
-        mov2w(AOP(left), 0);
-    for (i=1; i < size; i++)
-      emitpcode(POC_IORFW,popGet(AOP(left),i));
-    /* now Z is set iff `left == right' */
-    emitSKPZ;
-    if (!false_label) false_label = newiTempLabel(NULL);
-    emitpcode(POC_GOTO, popGetLabel(false_label->key));
-    break;
-
-      default:
-    for (i=0; i < size; i++)
-    {
-      mov2w(AOP(left),i);
-      emitpcode(POC_XORLW, popGetLit(lit >> (8*i)));
-      /* now Z is cleared if `left != right' */
-      emitSKPZ;
-      if (!false_label) false_label = newiTempLabel(NULL);
-      emitpcode(POC_GOTO, popGetLabel(false_label->key));
-    } // for i
-    break;
-    } // switch (lit)
-  }
-  else
-  {
-    /* right is no literal */
-    int i;
-
-    for (i=0; i < size; i++)
-    {
-      mov2w(AOP(right),i);
-      emitpcode(POC_XORFW,popGet(AOP(left),i));
-      /* now Z is cleared if `left != right' */
-      emitSKPZ;
-      if (!false_label) false_label = newiTempLabel(NULL);
-      emitpcode(POC_GOTO, popGetLabel(false_label->key));
-    } // for i
-  }
-
-  /* if we reach here, left == right */
-
-  if (AOP_SIZE(result) > 0)
-  {
-    emitpcode(POC_INCF, popGet(AOP(result),0));
-  }
-
-  if (ifx && IC_TRUE(ifx))
-  {
-    emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-  }
-
-  if (false_label && (!ifx || IC_TRUE(ifx)))
-    emitpLabel(false_label->key);
-
-  if (ifx) ifx->generated = 1;
-
-  freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-  freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-  freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* ifxForOp - returns the icode containing the ifx for operand     */
-/*-----------------------------------------------------------------*/
-static iCode *ifxForOp ( operand *op, iCode *ic )
-{
-    FENTRY;
-    /* if true symbol then needs to be assigned */
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if (IS_TRUE_SYMOP(op))
-        return NULL ;
-
-    /* if this has register type condition and
-    the next instruction is ifx with the same operand
-    and live to of the operand is upto the ifx only then */
-    if (ic->next &&
-        ic->next->op == IFX &&
-        IC_COND(ic->next)->key == op->key &&
-        OP_SYMBOL(op)->liveTo <= ic->next->seq )
-        return ic->next;
-
-    if (ic->next &&
-        ic->next->op == IFX &&
-        IC_COND(ic->next)->key == op->key) {
-        DEBUGpic14_emitcode ("; WARNING ","%d IGNORING liveTo range in %s",__LINE__,__FUNCTION__);
-        return ic->next;
-    }
-
-    DEBUGpic14_emitcode ("; NULL :(","%d",__LINE__);
-    if (ic->next &&
-        ic->next->op == IFX)
-        DEBUGpic14_emitcode ("; ic-next"," is an IFX");
-
-    if (ic->next &&
-        ic->next->op == IFX &&
-        IC_COND(ic->next)->key == op->key) {
-        DEBUGpic14_emitcode ("; "," key is okay");
-        DEBUGpic14_emitcode ("; "," key liveTo %d, next->seq = %d",
-            OP_SYMBOL(op)->liveTo,
-            ic->next->seq);
-    }
-
-
-    return NULL;
-}
-/*-----------------------------------------------------------------*/
-/* genAndOp - for && operation                                     */
-/*-----------------------------------------------------------------*/
-static void genAndOp (iCode *ic)
-{
-    operand *left,*right, *result;
-    /*     symbol *tlbl; */
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* note here that && operations that are in an
-    if statement are taken away by backPatchLabels
-    only those used in arthmetic operations remain */
-    aopOp((left=IC_LEFT(ic)),ic,FALSE);
-    aopOp((right=IC_RIGHT(ic)),ic,FALSE);
-    aopOp((result=IC_RESULT(ic)),ic,FALSE);
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-    emitpcode(POC_MOVFW,popGet(AOP(left),0));
-    emitpcode(POC_ANDFW,popGet(AOP(right),0));
-    emitpcode(POC_MOVWF,popGet(AOP(result),0));
-
-    /* if both are bit variables */
-    /*     if (AOP_TYPE(left) == AOP_CRY && */
-    /*         AOP_TYPE(right) == AOP_CRY ) { */
-    /*         pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir); */
-    /*         pic14_emitcode("anl","c,%s",AOP(right)->aopu.aop_dir); */
-    /*         pic14_outBitC(result); */
-    /*     } else { */
-    /*         tlbl = newiTempLabel(NULL); */
-    /*         pic14_toBoolean(left);     */
-    /*         pic14_emitcode("jz","%05d_DS_",tlbl->key+100); */
-    /*         pic14_toBoolean(right); */
-    /*         pic14_emitcode("","%05d_DS_:",tlbl->key+100); */
-    /*         pic14_outBitAcc(result); */
-    /*     } */
-
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-
-/*-----------------------------------------------------------------*/
-/* genOrOp - for || operation                                      */
-/*-----------------------------------------------------------------*/
-/*
-tsd pic port -
-modified this code, but it doesn't appear to ever get called
-*/
-
-static void genOrOp (iCode *ic)
-{
-    operand *left,*right, *result;
-    symbol *tlbl;
-    int i;
-
-    /* note here that || operations that are in an
-    if statement are taken away by backPatchLabels
-    only those used in arthmetic operations remain */
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    aopOp((left=IC_LEFT(ic)),ic,FALSE);
-    aopOp((right=IC_RIGHT(ic)),ic,FALSE);
-    aopOp((result=IC_RESULT(ic)),ic,FALSE);
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-    for (i=0; i < AOP_SIZE(result); i++)
-    {
-        emitpcode(POC_CLRF, popGet(AOP(result), i));
-    } // for i
-
-    tlbl = newiTempLabel(NULL);
-    pic14_toBoolean(left);
-    emitSKPZ;
-    emitpcode(POC_GOTO, popGetLabel(tlbl->key));
-    pic14_toBoolean(right);
-    emitpLabel(tlbl->key);
-    /* here Z is clear IFF `left || right' */
-    emitSKPZ;
-    emitpcode(POC_INCF, popGet(AOP(result), 0));
-
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* isLiteralBit - test if lit == 2^n                               */
-/*-----------------------------------------------------------------*/
-static int isLiteralBit(unsigned long lit)
-{
-    unsigned long pw[32] = {1L,2L,4L,8L,16L,32L,64L,128L,
-        0x100L,0x200L,0x400L,0x800L,
-        0x1000L,0x2000L,0x4000L,0x8000L,
-        0x10000L,0x20000L,0x40000L,0x80000L,
-        0x100000L,0x200000L,0x400000L,0x800000L,
-        0x1000000L,0x2000000L,0x4000000L,0x8000000L,
-        0x10000000L,0x20000000L,0x40000000L,0x80000000L};
-    int idx;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    for(idx = 0; idx < 32; idx++)
-        if(lit == pw[idx])
-            return idx+1;
-        return 0;
-}
-
-/*-----------------------------------------------------------------*/
-/* continueIfTrue -                                                */
-/*-----------------------------------------------------------------*/
-static void continueIfTrue (iCode *ic)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(IC_TRUE(ic))
-    {
-        // Why +100?!?
-        emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
-        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
-    }
-    ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* jmpIfTrue -                                                     */
-/*-----------------------------------------------------------------*/
-static void jumpIfTrue (iCode *ic)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(!IC_TRUE(ic))
-    {
-        // Why +100?!?
-        emitpcode(POC_GOTO, popGetLabel(IC_TRUE(ic)->key+100));
-        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
-    }
-    ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* jmpTrueOrFalse -                                                */
-/*-----------------------------------------------------------------*/
-static void jmpTrueOrFalse (iCode *ic, symbol *tlbl)
-{
-    FENTRY;
-    // ugly but optimized by peephole
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(IC_TRUE(ic)){
-        symbol *nlbl = newiTempLabel(NULL);
-        pic14_emitcode("sjmp","%05d_DS_",nlbl->key+100);
-        pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-        pic14_emitcode("ljmp","%05d_DS_",IC_TRUE(ic)->key+100);
-        pic14_emitcode("","%05d_DS_:",nlbl->key+100);
-    }
-    else{
-        pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ic)->key+100);
-        pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-    }
-    ic->generated = 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* genAnd  - code for and                                          */
-/*-----------------------------------------------------------------*/
-static void genAnd (iCode *ic, iCode *ifx)
-{
-    operand *left, *right, *result;
-    int size, offset=0;
-    unsigned long lit = 0L;
-    int bytelit = 0;
-    resolvedIfx rIfx;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    aopOp((left = IC_LEFT(ic)),ic,FALSE);
-    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
-    aopOp((result=IC_RESULT(ic)),ic,TRUE);
-
-    resolveIfx(&rIfx,ifx);
-
-    /* if left is a literal & right is not then exchange them */
-    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
-        AOP_NEEDSACC(left)) {
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if result = right then exchange them */
-    if(pic14_sameRegs(AOP(result),AOP(right))){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if right is bit then exchange them */
-    if (AOP_TYPE(right) == AOP_CRY &&
-        AOP_TYPE(left) != AOP_CRY){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-    if(AOP_TYPE(right) == AOP_LIT)
-        lit = ulFromVal (AOP(right)->aopu.aop_lit);
-
-    size = AOP_SIZE(result);
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-    // if(bit & yy)
-    // result = bit & yy;
-    if (AOP_TYPE(left) == AOP_CRY){
-        // c = bit & literal;
-        if(AOP_TYPE(right) == AOP_LIT){
-            if(lit & 1) {
-                if(size && pic14_sameRegs(AOP(result),AOP(left)))
-                    // no change
-                    goto release;
-                pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
-            } else {
-                // bit(result) = 0;
-                if(size && (AOP_TYPE(result) == AOP_CRY)){
-                    pic14_emitcode("clr","%s",AOP(result)->aopu.aop_dir);
-                    goto release;
-                }
-                if((AOP_TYPE(result) == AOP_CRY) && ifx){
-                    jumpIfTrue(ifx);
-                    goto release;
-                }
-                pic14_emitcode("clr","c");
-            }
-        } else {
-            if (AOP_TYPE(right) == AOP_CRY){
-                // c = bit & bit;
-                pic14_emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
-                pic14_emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
-            } else {
-                // c = bit & val;
-                MOVA(aopGet(AOP(right),0,FALSE,FALSE));
-                // c = lsb
-                pic14_emitcode("rrc","a");
-                pic14_emitcode("anl","c,%s",AOP(left)->aopu.aop_dir);
-            }
-        }
-        // bit = c
-        // val = c
-        if(size)
-            pic14_outBitC(result);
-        // if(bit & ...)
-        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
-            genIfxJump(ifx, "c");
-        goto release ;
-    }
-
-    // if(val & 0xZZ)       - size = 0, ifx != FALSE  -
-    // bit = val & 0xZZ     - size = 1, ifx = FALSE -
-    if((AOP_TYPE(right) == AOP_LIT) &&
-        (AOP_TYPE(result) == AOP_CRY) &&
-        (AOP_TYPE(left) != AOP_CRY)){
-        int posbit = isLiteralBit(lit);
-        /* left &  2^n */
-        if(posbit){
-            posbit--;
-            //MOVA(aopGet(AOP(left),posbit>>3,FALSE,FALSE));
-            // bit = left & 2^n
-            if(size)
-                pic14_emitcode("mov","c,acc.%d",posbit&0x07);
-            // if(left &  2^n)
-            else{
-                if(ifx){
-                    int offset = 0;
-                    while (posbit > 7) {
-                        posbit -= 8;
-                        offset++;
-                    }
-                    emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
-                        newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit,0));
-                    emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
-
-                    ifx->generated = 1;
-                }
-                goto release;
-            }
-        } else {
-            symbol *tlbl = newiTempLabel(NULL);
-            int sizel = AOP_SIZE(left);
-            if(size)
-                pic14_emitcode("setb","c");
-            while(sizel--){
-                if((bytelit = ((lit >> (offset*8)) & 0x0FFL)) != 0x0L){
-                    mov2w( AOP(left), offset);
-                    // byte ==  2^n ?
-                    if((posbit = isLiteralBit(bytelit)) != 0) {
-                        emitpcode(rIfx.condition ? POC_BTFSC : POC_BTFSS, // XXX: or the other way round?
-                            newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit - 1, 0));
-                        pic14_emitcode("jb","acc.%d,%05d_DS_",(posbit-1)&0x07,tlbl->key+100);
-                    }
-                    else{
-                        emitpcode(POC_ANDLW, newpCodeOpLit(bytelit & 0x0ff));
-                        if (rIfx.condition) emitSKPZ;
-                        else emitSKPNZ;
-
-                        if(bytelit != 0x0FFL)
-                        {
-                            pic14_emitcode("anl","a,%s",
-                            aopGet(AOP(right),offset,FALSE,TRUE));
-                        }
-                        pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
-                    }
-
-                    emitpcode(POC_GOTO, popGetLabel(rIfx.lbl->key));
-                    ifx->generated = 1;
-
-                }
-                offset++;
-            }
-            // bit = left & literal
-            if(size){
-                pic14_emitcode("clr","c");
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-            }
-            // if(left & literal)
-            else{
-                if(ifx)
-                    jmpTrueOrFalse(ifx, tlbl);
-                goto release ;
-            }
-        }
-        pic14_outBitC(result);
-        goto release ;
-    }
-
-    /* if left is same as result */
-    if(pic14_sameRegs(AOP(result),AOP(left))){
-        int know_W = -1;
-        for(;size--; offset++,lit>>=8) {
-            if(AOP_TYPE(right) == AOP_LIT){
-                switch(lit & 0xff) {
-                case 0x00:
-                    /*  and'ing with 0 has clears the result */
-                    emitpcode(POC_CLRF,popGet(AOP(result),offset));
-                    break;
-                case 0xff:
-                    /* and'ing with 0xff is a nop when the result and left are the same */
-                    break;
-
-                default:
-                    {
-                        int p = my_powof2( (~lit) & 0xff );
-                        if(p>=0) {
-                            /* only one bit is set in the literal, so use a bcf instruction */
-                            emitpcode(POC_BCF,newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),p,0));
-
-                        } else {
-                            if(know_W != (int)(lit&0xff))
-                                emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
-                            know_W = lit &0xff;
-                            emitpcode(POC_ANDWF,popGet(AOP(left),offset));
-                        }
-                    }
-                }
-            } else {
-                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-                emitpcode(POC_ANDWF,popGet(AOP(left),offset));
-            }
-        }
-
-    } else {
-        // left & result in different registers
-        if(AOP_TYPE(result) == AOP_CRY){
-            // result = bit
-            // if(size), result in bit
-            // if(!size && ifx), conditional oper: if(left & right)
-            symbol *tlbl = newiTempLabel(NULL);
-            int sizer = min(AOP_SIZE(left),AOP_SIZE(right));
-            if(size)
-                pic14_emitcode("setb","c");
-            while(sizer--){
-                MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
-                pic14_emitcode("anl","a,%s",
-                    aopGet(AOP(left),offset,FALSE,FALSE));
-                pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
-                offset++;
-            }
-            if(size){
-                CLRC;
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-                pic14_outBitC(result);
-            } else if(ifx)
-                jmpTrueOrFalse(ifx, tlbl);
-        } else {
-            for(;(size--);offset++) {
-                // normal case
-                // result = left & right
-                if(AOP_TYPE(right) == AOP_LIT){
-                    int t = (lit >> (offset*8)) & 0x0FFL;
-                    switch(t) {
-                    case 0x00:
-                        emitpcode(POC_CLRF,popGet(AOP(result),offset));
-                        break;
-                    case 0xff:
-                        emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                        break;
-                    default:
-                        emitpcode(POC_MOVLW, popGetLit(t));
-                        emitpcode(POC_ANDFW,popGet(AOP(left),offset));
-                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    }
-                    continue;
-                }
-
-                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-                emitpcode(POC_ANDFW,popGet(AOP(left),offset));
-                emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-            }
-        }
-    }
-
-release :
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genOr  - code for or                                            */
-/*-----------------------------------------------------------------*/
-static void genOr (iCode *ic, iCode *ifx)
-{
-    operand *left, *right, *result;
-    int size, offset=0;
-    unsigned long lit = 0L;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    aopOp((left = IC_LEFT(ic)),ic,FALSE);
-    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
-    aopOp((result=IC_RESULT(ic)),ic,TRUE);
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-    /* if left is a literal & right is not then exchange them */
-    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
-        AOP_NEEDSACC(left)) {
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if result = right then exchange them */
-    if(pic14_sameRegs(AOP(result),AOP(right))){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if right is bit then exchange them */
-    if (AOP_TYPE(right) == AOP_CRY &&
-        AOP_TYPE(left) != AOP_CRY){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    DEBUGpic14_AopType(__LINE__,left,right,result);
-
-    if(AOP_TYPE(right) == AOP_LIT)
-        lit = ulFromVal (AOP(right)->aopu.aop_lit);
-
-    size = AOP_SIZE(result);
-
-    // if(bit | yy)
-    // xx = bit | yy;
-    if (AOP_TYPE(left) == AOP_CRY){
-        if(AOP_TYPE(right) == AOP_LIT){
-            // c = bit & literal;
-            if(lit){
-                // lit != 0 => result = 1
-                if(AOP_TYPE(result) == AOP_CRY){
-                    if(size)
-                        emitpcode(POC_BSF, popGet(AOP(result),0));
-                    //pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
-                    //   AOP(result)->aopu.aop_dir,
-                    //   AOP(result)->aopu.aop_dir);
-                    else if(ifx)
-                        continueIfTrue(ifx);
-                    goto release;
-                }
-            } else {
-                // lit == 0 => result = left
-                if(size && pic14_sameRegs(AOP(result),AOP(left)))
-                    goto release;
-                pic14_emitcode(";XXX mov","c,%s  %s,%d",AOP(left)->aopu.aop_dir,__FILE__,__LINE__);
-            }
-        } else {
-            if (AOP_TYPE(right) == AOP_CRY){
-                if(pic14_sameRegs(AOP(result),AOP(left))){
-                    // c = bit | bit;
-                    emitpcode(POC_BCF,   popGet(AOP(result),0));
-                    emitpcode(POC_BTFSC, popGet(AOP(right),0));
-                    emitpcode(POC_BSF,   popGet(AOP(result),0));
-
-                    pic14_emitcode("bcf","(%s >> 3), (%s & 7)",
-                        AOP(result)->aopu.aop_dir,
-                        AOP(result)->aopu.aop_dir);
-                    pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
-                        AOP(right)->aopu.aop_dir,
-                        AOP(right)->aopu.aop_dir);
-                    pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
-                        AOP(result)->aopu.aop_dir,
-                        AOP(result)->aopu.aop_dir);
-                } else {
-                        emitpcode(POC_BCF,   popGet(AOP(result),0));
-                        emitpcode(POC_BTFSS, popGet(AOP(right),0));
-                        emitpcode(POC_BTFSC, popGet(AOP(left),0));
-                        emitpcode(POC_BSF,   popGet(AOP(result),0));
-                }
-            } else {
-                // c = bit | val;
-                symbol *tlbl = newiTempLabel(NULL);
-                pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
-
-
-                emitpcode(POC_BCF,   popGet(AOP(result),0));
-
-                if(!((AOP_TYPE(result) == AOP_CRY) && ifx))
-                    pic14_emitcode(";XXX setb","c");
-                pic14_emitcode(";XXX jb","%s,%05d_DS_",
-                    AOP(left)->aopu.aop_dir,tlbl->key+100);
-                pic14_toBoolean(right);
-                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
-                if((AOP_TYPE(result) == AOP_CRY) && ifx){
-                    jmpTrueOrFalse(ifx, tlbl);
-                    goto release;
-                } else {
-                    CLRC;
-                    pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-                }
-            }
-        }
-        // bit = c
-        // val = c
-        if(size)
-            pic14_outBitC(result);
-        // if(bit | ...)
-        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
-            genIfxJump(ifx, "c");
-        goto release ;
-    }
-
-    // if(val | 0xZZ)       - size = 0, ifx != FALSE  -
-    // bit = val | 0xZZ     - size = 1, ifx = FALSE -
-    if((AOP_TYPE(right) == AOP_LIT) &&
-      (AOP_TYPE(result) == AOP_CRY) &&
-      (AOP_TYPE(left) != AOP_CRY)){
-        if(lit){
-            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
-            // result = 1
-            if(size)
-                pic14_emitcode(";XXX setb","%s",AOP(result)->aopu.aop_dir);
-            else
-                continueIfTrue(ifx);
-            goto release;
-        } else {
-            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
-            // lit = 0, result = boolean(left)
-            if(size)
-                pic14_emitcode(";XXX setb","c");
-            pic14_toBoolean(right);
-            if(size){
-                symbol *tlbl = newiTempLabel(NULL);
-                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
-                CLRC;
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-            } else {
-                genIfxJump (ifx,"a");
-                goto release;
-            }
-        }
-        pic14_outBitC(result);
-        goto release ;
-    }
-
-    /* if left is same as result */
-    if(pic14_sameRegs(AOP(result),AOP(left))){
-        int know_W = -1;
-        for(;size--; offset++,lit>>=8) {
-            if(AOP_TYPE(right) == AOP_LIT){
-                if((lit & 0xff) == 0)
-                    /*  or'ing with 0 has no effect */
-                    continue;
-                else {
-                    int p = my_powof2(lit & 0xff);
-                    if(p>=0) {
-                        /* only one bit is set in the literal, so use a bsf instruction */
-                        emitpcode(POC_BSF,
-                            newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),p,0));
-                    } else {
-                        if(know_W != (int)(lit & 0xff))
-                            emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
-                        know_W = lit & 0xff;
-                        emitpcode(POC_IORWF, popGet(AOP(left),offset));
-                    }
-
-                }
-            } else {
-                emitpcode(POC_MOVFW,  popGet(AOP(right),offset));
-                emitpcode(POC_IORWF,  popGet(AOP(left),offset));
-            }
-        }
-    } else {
-        // left & result in different registers
-        if(AOP_TYPE(result) == AOP_CRY){
-            // result = bit
-            // if(size), result in bit
-            // if(!size && ifx), conditional oper: if(left | right)
-            symbol *tlbl = newiTempLabel(NULL);
-            int sizer = max(AOP_SIZE(left),AOP_SIZE(right));
-            pic14_emitcode(";XXX "," %s,%d",__FILE__,__LINE__);
-
-
-            if(size)
-                pic14_emitcode(";XXX setb","c");
-            while(sizer--){
-                MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
-                pic14_emitcode(";XXX orl","a,%s",
-                    aopGet(AOP(left),offset,FALSE,FALSE));
-                pic14_emitcode(";XXX jnz","%05d_DS_",tlbl->key+100);
-                offset++;
-            }
-            if(size){
-                CLRC;
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-                pic14_outBitC(result);
-            } else if(ifx)
-                jmpTrueOrFalse(ifx, tlbl);
-        } else for(;(size--);offset++){
-            // normal case
-            // result = left | right
-            if(AOP_TYPE(right) == AOP_LIT){
-                int t = (lit >> (offset*8)) & 0x0FFL;
-                switch(t) {
-                case 0x00:
-                    emitpcode(POC_MOVFW,  popGet(AOP(left),offset));
-                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-
-                    break;
-                default:
-                    emitpcode(POC_MOVLW,  popGetLit(t));
-                    emitpcode(POC_IORFW,  popGet(AOP(left),offset));
-                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-                }
-                continue;
-            }
-
-            // faster than result <- left, anl result,right
-            // and better if result is SFR
-            emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-            emitpcode(POC_IORFW,popGet(AOP(left),offset));
-            emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-        }
-    }
-
-release :
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genXor - code for xclusive or                                   */
-/*-----------------------------------------------------------------*/
-static void genXor (iCode *ic, iCode *ifx)
-{
-    operand *left, *right, *result;
-    int size, offset=0;
-    unsigned long lit = 0L;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    aopOp((left = IC_LEFT(ic)),ic,FALSE);
-    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
-    aopOp((result=IC_RESULT(ic)),ic,TRUE);
-
-    /* if left is a literal & right is not ||
-    if left needs acc & right does not */
-    if ((AOP_TYPE(left) == AOP_LIT && AOP_TYPE(right) != AOP_LIT) ||
-        (AOP_NEEDSACC(left) && !AOP_NEEDSACC(right))) {
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if result = right then exchange them */
-    if(pic14_sameRegs(AOP(result),AOP(right))){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-
-    /* if right is bit then exchange them */
-    if (AOP_TYPE(right) == AOP_CRY &&
-        AOP_TYPE(left) != AOP_CRY){
-        operand *tmp = right ;
-        right = left;
-        left = tmp;
-    }
-    if(AOP_TYPE(right) == AOP_LIT)
-        lit = ulFromVal (AOP(right)->aopu.aop_lit);
-
-    size = AOP_SIZE(result);
-
-    // if(bit ^ yy)
-    // xx = bit ^ yy;
-    if (AOP_TYPE(left) == AOP_CRY){
-        if(AOP_TYPE(right) == AOP_LIT){
-            // c = bit & literal;
-            if(lit>>1){
-                // lit>>1  != 0 => result = 1
-                if(AOP_TYPE(result) == AOP_CRY){
-                    if(size)
-                    {emitpcode(POC_BSF,  popGet(AOP(result),offset));
-                    pic14_emitcode("setb","%s",AOP(result)->aopu.aop_dir);}
-                    else if(ifx)
-                        continueIfTrue(ifx);
-                    goto release;
-                }
-                pic14_emitcode("setb","c");
-            } else{
-                // lit == (0 or 1)
-                if(lit == 0){
-                    // lit == 0, result = left
-                    if(size && pic14_sameRegs(AOP(result),AOP(left)))
-                        goto release;
-                    pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
-                } else{
-                    // lit == 1, result = not(left)
-                    if(size && pic14_sameRegs(AOP(result),AOP(left))){
-                        emitpcode(POC_MOVLW,  popGet(AOP(result),offset));
-                        emitpcode(POC_XORWF,  popGet(AOP(result),offset));
-                        pic14_emitcode("cpl","%s",AOP(result)->aopu.aop_dir);
-                        goto release;
-                    } else {
-                        assert ( !"incomplete genXor" );
-                        pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
-                        pic14_emitcode("cpl","c");
-                    }
-                }
-            }
-
-        } else {
-            // right != literal
-            symbol *tlbl = newiTempLabel(NULL);
-            if (AOP_TYPE(right) == AOP_CRY){
-                // c = bit ^ bit;
-                pic14_emitcode("mov","c,%s",AOP(right)->aopu.aop_dir);
-            }
-            else{
-                int sizer = AOP_SIZE(right);
-                // c = bit ^ val
-                // if val>>1 != 0, result = 1
-                pic14_emitcode("setb","c");
-                while(sizer){
-                    MOVA(aopGet(AOP(right),sizer-1,FALSE,FALSE));
-                    if(sizer == 1)
-                        // test the msb of the lsb
-                        pic14_emitcode("anl","a,#0xfe");
-                    pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
-                    sizer--;
-                }
-                // val = (0,1)
-                pic14_emitcode("rrc","a");
-            }
-            pic14_emitcode("jnb","%s,%05d_DS_",AOP(left)->aopu.aop_dir,(tlbl->key+100));
-            pic14_emitcode("cpl","c");
-            pic14_emitcode("","%05d_DS_:",(tlbl->key+100));
-        }
-        // bit = c
-        // val = c
-        if(size)
-            pic14_outBitC(result);
-        // if(bit | ...)
-        else if((AOP_TYPE(result) == AOP_CRY) && ifx)
-            genIfxJump(ifx, "c");
-        goto release ;
-    }
-
-    if(pic14_sameRegs(AOP(result),AOP(left))){
-        /* if left is same as result */
-        for(;size--; offset++) {
-            if(AOP_TYPE(right) == AOP_LIT){
-                int t  = (lit >> (offset*8)) & 0x0FFL;
-                if(t == 0x00L)
-                    continue;
-                else {
-                        emitpcode(POC_MOVLW, popGetLit(t));
-                        emitpcode(POC_XORWF,popGet(AOP(left),offset));
-                }
-            } else {
-                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-                emitpcode(POC_XORWF,popGet(AOP(left),offset));
-            }
-        }
-    } else {
-        // left & result in different registers
-        if(AOP_TYPE(result) == AOP_CRY){
-            // result = bit
-            // if(size), result in bit
-            // if(!size && ifx), conditional oper: if(left ^ right)
-            symbol *tlbl = newiTempLabel(NULL);
-            int sizer = max(AOP_SIZE(left),AOP_SIZE(right));
-            if(size)
-                pic14_emitcode("setb","c");
-            while(sizer--){
-                if((AOP_TYPE(right) == AOP_LIT) &&
-                    (((lit >> (offset*8)) & 0x0FFL) == 0x00L)){
-                    MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
-                } else {
-                    MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
-                    pic14_emitcode("xrl","a,%s",
-                        aopGet(AOP(left),offset,FALSE,FALSE));
-                }
-                pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
-                offset++;
-            }
-            if(size){
-                CLRC;
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-                pic14_outBitC(result);
-            } else if(ifx)
-                jmpTrueOrFalse(ifx, tlbl);
-        } else for(;(size--);offset++){
-            // normal case
-            // result = left & right
-            if(AOP_TYPE(right) == AOP_LIT){
-                int t = (lit >> (offset*8)) & 0x0FFL;
-                switch(t) {
-                case 0x00:
-                    emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    break;
-                case 0xff:
-                    emitpcode(POC_COMFW,popGet(AOP(left),offset));
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    break;
-                default:
-                    emitpcode(POC_MOVLW, popGetLit(t));
-                    emitpcode(POC_XORFW,popGet(AOP(left),offset));
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                }
-                continue;
-            }
-
-            // faster than result <- left, anl result,right
-            // and better if result is SFR
-            emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-            emitpcode(POC_XORFW,popGet(AOP(left),offset));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-        }
-    }
-
-release :
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genInline - write the inline code out                           */
-/*-----------------------------------------------------------------*/
-static void genInline (iCode *ic)
-{
-  char *buffer, *bp, *bp1;
-  bool inComment = FALSE;
-
-  FENTRY;
-  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-  _G.inLine += (!options.asmpeep);
-
-  buffer = bp = bp1 = Safe_strdup (IC_INLINE (ic));
-
-  while (*bp)
-    {
-      switch (*bp)
-        {
-        case ';':
-          inComment = TRUE;
-          ++bp;
-          break;
-
-        case '\n':
-          inComment = FALSE;
-          *bp++ = '\0';
-          if (*bp1)
-            addpCode2pBlock(pb, newpCodeAsmDir(bp1, NULL)); // inline directly, no process
-          bp1 = bp;
-          break;
-
-        default:
-          /* Add \n for labels, not dirs such as c:\mydir */
-          if (!inComment && (*bp == ':') && (isspace((unsigned char)bp[1])))
-            {
-              ++bp;
-              *bp = '\0';
-              ++bp;
-              /* print label, use this special format with NULL directive
-               * to denote that the argument should not be indented with tab */
-              addpCode2pBlock(pb, newpCodeAsmDir(NULL, bp1)); // inline directly, no process
-              bp1 = bp;
-            }
-          else
-            ++bp;
-          break;
-        }
-    }
-  if ((bp1 != bp) && *bp1)
-    addpCode2pBlock(pb, newpCodeAsmDir(bp1, NULL)); // inline directly, no process
-
-  Safe_free (buffer);
-
-  _G.inLine -= (!options.asmpeep);
-}
-
-/*-----------------------------------------------------------------*/
-/* genRRC - rotate right with carry                                */
-/*-----------------------------------------------------------------*/
-static void genRRC (iCode *ic)
-{
-    operand *left , *result ;
-    int size, offset = 0, same;
-
-    FENTRY;
-    /* rotate right with carry */
-    left = IC_LEFT(ic);
-    result=IC_RESULT(ic);
-    aopOp (left,ic,FALSE);
-    aopOp (result,ic,FALSE);
-
-    DEBUGpic14_AopType(__LINE__,left,NULL,result);
-
-    same = pic14_sameRegs(AOP(result),AOP(left));
-
-    size = AOP_SIZE(result);
-
-    /* get the lsb and put it into the carry */
-    emitpcode(POC_RRFW, popGet(AOP(left),size-1));
-
-    offset = 0 ;
-
-    while(size--) {
-
-        if(same) {
-            emitpcode(POC_RRF, popGet(AOP(left),offset));
-        } else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offset));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
-        }
-
-        offset++;
-    }
-
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genRLC - generate code for rotate left with carry               */
-/*-----------------------------------------------------------------*/
-static void genRLC (iCode *ic)
-{
-    operand *left , *result ;
-    int size, offset = 0;
-    int same;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* rotate right with carry */
-    left = IC_LEFT(ic);
-    result=IC_RESULT(ic);
-    aopOp (left,ic,FALSE);
-    aopOp (result,ic,FALSE);
-
-    DEBUGpic14_AopType(__LINE__,left,NULL,result);
-
-    same = pic14_sameRegs(AOP(result),AOP(left));
-
-    /* move it to the result */
-    size = AOP_SIZE(result);
-
-    /* get the msb and put it into the carry */
-    emitpcode(POC_RLFW, popGet(AOP(left),size-1));
-
-    offset = 0 ;
-
-    while(size--) {
-
-        if(same) {
-            emitpcode(POC_RLF, popGet(AOP(left),offset));
-        } else {
-            emitpcode(POC_RLFW, popGet(AOP(left),offset));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
-        }
-
-        offset++;
-    }
-
-
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* genGetHbit - generates code get highest order bit               */
-/*-----------------------------------------------------------------*/
-static void genGetHbit (iCode *ic)
-{
-    operand *left, *result;
-    left = IC_LEFT(ic);
-    result=IC_RESULT(ic);
-    aopOp (left,ic,FALSE);
-    aopOp (result,ic,FALSE);
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* get the highest order byte into a */
-    MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE));
-    if(AOP_TYPE(result) == AOP_CRY){
-        pic14_emitcode("rlc","a");
-        pic14_outBitC(result);
-    }
-    else{
-        pic14_emitcode("rl","a");
-        pic14_emitcode("anl","a,#0x01");
-        pic14_outAcc(result);
-    }
-
-
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-/*-----------------------------------------------------------------*/
-/* AccLsh - shift left accumulator by known count                  */
-/* MARK: pic14 always rotates through CARRY!                       */
-/*-----------------------------------------------------------------*/
-static void AccLsh (pCodeOp *pcop,int shCount)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    shCount &= 0x0007;              // shCount : 0..7
-    switch(shCount){
-    case 0 :
-        return;
-        break;
-    case 1 :
-        emitCLRC;
-        emitpcode(POC_RLF,pcop);
-        return;
-        break;
-    case 2 :
-        emitpcode(POC_RLF,pcop);
-        emitpcode(POC_RLF,pcop);
-        break;
-    case 3 :
-        emitpcode(POC_RLF,pcop);
-        emitpcode(POC_RLF,pcop);
-        emitpcode(POC_RLF,pcop);
-        break;
-    case 4 :
-        emitpcode(POC_SWAPF,pcop);
-        break;
-    case 5 :
-        emitpcode(POC_SWAPF,pcop);
-        emitpcode(POC_RLF,pcop);
-        break;
-    case 6 :
-        emitpcode(POC_SWAPF,pcop);
-        emitpcode(POC_RLF,pcop);
-        emitpcode(POC_RLF,pcop);
-        break;
-    case 7 :
-        emitpcode(POC_RRFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        break;
-    }
-    /* clear invalid bits */
-    emitpcode(POC_MOVLW, popGetLit ((unsigned char)(~((1UL << shCount) - 1))));
-    emitpcode(POC_ANDWF, pcop);
-}
-
-/*-----------------------------------------------------------------*/
-/* AccRsh - shift right accumulator by known count                 */
-/* MARK: pic14 always rotates through CARRY!                       */
-/* maskmode - 0: leave invalid bits undefined (caller should mask) */
-/*            1: mask out invalid bits (zero-extend)               */
-/*            2: sign-extend result (pretty slow)                  */
-/*-----------------------------------------------------------------*/
-static void AccRsh (pCodeOp *pcop,int shCount, int mask_mode)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    shCount &= 0x0007;              // shCount : 0..7
-    switch(shCount){
-    case 0 :
-        return;
-        break;
-    case 1 :
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        else if (mask_mode == 1) emitCLRC;
-        emitpcode(POC_RRF,pcop);
-        return;
-        break;
-    case 2 :
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        if (mask_mode == 2) return;
-        break;
-    case 3 :
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        /* load sign if needed */
-        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
-        emitpcode(POC_RRF,pcop);
-        if (mask_mode == 2) return;
-        break;
-    case 4 :
-        emitpcode(POC_SWAPF,pcop);
-        break;
-    case 5 :
-        emitpcode(POC_SWAPF,pcop);
-        emitpcode(POC_RRF,pcop);
-        break;
-    case 6 :
-        emitpcode(POC_SWAPF,pcop);
-        emitpcode(POC_RRF,pcop);
-        emitpcode(POC_RRF,pcop);
-        break;
-    case 7 :
-        if (mask_mode == 2)
-        {
-            /* load sign */
-            emitpcode(POC_RLFW,pcop);
-            emitpcode(POC_CLRF,pcop);
-            emitSKPNC;
-            emitpcode(POC_COMF,pcop);
-            return;
-        } else {
-            emitpcode(POC_RLFW,pcop);
-            emitpcode(POC_RLF,pcop);
-        }
-        break;
-    }
-
-    if (mask_mode == 0)
-    {
-        /* leave invalid bits undefined */
-        return;
-    }
-
-    /* clear invalid bits -- zero-extend */
-    emitpcode(POC_MOVLW, popGetLit (0x00ff >> shCount));
-    emitpcode(POC_ANDWF, pcop);
-
-    if (mask_mode == 2) {
-      /* sign-extend */
-      emitpcode(POC_MOVLW, popGetLit (0x00ff << (8 - shCount)));
-      emitpcode(POC_BTFSC, newpCodeOpBit (get_op(pcop,NULL,0), 7 - shCount ,0));
-      emitpcode(POC_IORWF, pcop);
-    }
-}
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* AccSRsh - signed right shift accumulator by known count                 */
-/*-----------------------------------------------------------------*/
-static void AccSRsh (int shCount)
-{
-    symbol *tlbl ;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(shCount != 0){
-        if(shCount == 1){
-            pic14_emitcode("mov","c,acc.7");
-            pic14_emitcode("rrc","a");
-        } else if(shCount == 2){
-            pic14_emitcode("mov","c,acc.7");
-            pic14_emitcode("rrc","a");
-            pic14_emitcode("mov","c,acc.7");
-            pic14_emitcode("rrc","a");
-        } else {
-            tlbl = newiTempLabel(NULL);
-            /* rotate right accumulator */
-            AccRol(8 - shCount);
-            /* and kill the higher order bits */
-            pic14_emitcode("anl","a,#0x%02x", SRMask[shCount]);
-            pic14_emitcode("jnb","acc.%d,%05d_DS_",7-shCount,tlbl->key+100);
-            pic14_emitcode("orl","a,#0x%02x",
-                (unsigned char)~SRMask[shCount]);
-            pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-        }
-    }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftR1Left2Result - shift right one byte from left to result   */
-/*-----------------------------------------------------------------*/
-static void shiftR1Left2ResultSigned (operand *left, int offl,
-                                      operand *result, int offr,
-                                      int shCount)
-{
-    int same;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    same = ((left == result) || (AOP(left) == AOP(result))) && (offl == offr);
-
-    switch(shCount) {
-    case 1:
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        if(same)
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
-        else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-
-        break;
-    case 2:
-
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        if(same)
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
-        else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-        emitpcode(POC_RLFW, popGet(AOP(result),offr));
-        emitpcode(POC_RRF,  popGet(AOP(result),offr));
-
-        break;
-
-    case 3:
-        if(same)
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr));
-        else {
-            emitpcode(POC_SWAPFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-
-        emitpcode(POC_RLFW,  popGet(AOP(result),offr));
-        emitpcode(POC_RLFW,  popGet(AOP(result),offr));
-        emitpcode(POC_ANDLW, popGetLit(0x1f));
-
-        emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(result),offr,FALSE,FALSE),3,0));
-        emitpcode(POC_IORLW, popGetLit(0xe0));
-
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        break;
-
-    case 4:
-        emitpcode(POC_SWAPFW, popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW,  popGetLit(0x0f));
-        emitpcode(POC_BTFSC,  newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),7,0));
-        emitpcode(POC_IORLW,  popGetLit(0xf0));
-        emitpcode(POC_MOVWF,  popGet(AOP(result),offr));
-        break;
-    case 5:
-        if(same) {
-            emitpcode(POC_SWAPF,  popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_SWAPFW,  popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF,  popGet(AOP(result),offr));
-        }
-        emitpcode(POC_RRFW,   popGet(AOP(result),offr));
-        emitpcode(POC_ANDLW,  popGetLit(0x07));
-        emitpcode(POC_BTFSC,  newpCodeOpBit(aopGet(AOP(result),offr,FALSE,FALSE),3,0));
-        emitpcode(POC_IORLW,  popGetLit(0xf8));
-        emitpcode(POC_MOVWF,  popGet(AOP(result),offr));
-        break;
-
-    case 6:
-        if(same) {
-            emitpcode(POC_MOVLW, popGetLit(0x00));
-            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),7,0));
-            emitpcode(POC_MOVLW, popGetLit(0xfe));
-            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),6,0));
-            emitpcode(POC_IORLW, popGetLit(0x01));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_CLRF,  popGet(AOP(result),offr));
-            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),7,0));
-            emitpcode(POC_DECF,  popGet(AOP(result),offr));
-            emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),6,0));
-            emitpcode(POC_BCF,   newpCodeOpBit(aopGet(AOP(result),offr,FALSE,FALSE),0,0));
-        }
-        break;
-
-    case 7:
-        if(same) {
-            emitpcode(POC_MOVLW, popGetLit(0x00));
-            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),LSB,FALSE,FALSE),7,0));
-            emitpcode(POC_MOVLW, popGetLit(0xff));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_CLRF,  popGet(AOP(result),offr));
-            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),offl,FALSE,FALSE),7,0));
-            emitpcode(POC_DECF,  popGet(AOP(result),offr));
-        }
-
-    default:
-        break;
-    }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftR1Left2Result - shift right one byte from left to result   */
-/*-----------------------------------------------------------------*/
-static void shiftR1Left2Result (operand *left, int offl,
-                                operand *result, int offr,
-                                int shCount, int sign)
-{
-    int same;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    same = ((left == result) || (AOP(left) == AOP(result))) && (offl == offr);
-
-    /* Copy the msb into the carry if signed. */
-    if(sign) {
-        shiftR1Left2ResultSigned(left,offl,result,offr,shCount);
-        return;
-    }
-
-
-
-    switch(shCount) {
-    case 1:
-        emitCLRC;
-        if(same)
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
-        else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-        break;
-    case 2:
-        emitCLRC;
-        if(same) {
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-        emitCLRC;
-        emitpcode(POC_RRF, popGet(AOP(result),offr));
-
-        break;
-    case 3:
-        if(same)
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr));
-        else {
-            emitpcode(POC_SWAPFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-
-        emitpcode(POC_RLFW,  popGet(AOP(result),offr));
-        emitpcode(POC_RLFW,  popGet(AOP(result),offr));
-        emitpcode(POC_ANDLW, popGetLit(0x1f));
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        break;
-
-    case 4:
-        emitpcode(POC_SWAPFW, popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0x0f));
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        break;
-
-    case 5:
-        emitpcode(POC_SWAPFW, popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0x0f));
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        emitCLRC;
-        emitpcode(POC_RRF, popGet(AOP(result),offr));
-
-        break;
-    case 6:
-
-        emitpcode(POC_RLFW,  popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0x80));
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        emitpcode(POC_RLF,   popGet(AOP(result),offr));
-        emitpcode(POC_RLF,   popGet(AOP(result),offr));
-        break;
-
-    case 7:
-
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        emitpcode(POC_CLRF, popGet(AOP(result),offr));
-        emitpcode(POC_RLF,  popGet(AOP(result),offr));
-
-        break;
-
-    default:
-        break;
-    }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftL1Left2Result - shift left one byte from left to result    */
-/*-----------------------------------------------------------------*/
-static void shiftL1Left2Result (operand *left, int offl,
-                                operand *result, int offr, int shCount)
-{
-    int same;
-
-    //    char *l;
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    same = ((left == result) || (AOP(left) == AOP(result))) && (offl==offr);
-    DEBUGpic14_emitcode ("; ***","same =  %d",same);
-    //    l = aopGet(AOP(left),offl,FALSE,FALSE);
-    //    MOVA(l);
-    /* shift left accumulator */
-    //AccLsh(shCount); // don't comment out just yet...
-    //    aopPut(AOP(result),"a",offr);
-
-    switch(shCount) {
-    case 1:
-        /* Shift left 1 bit position */
-        emitpcode(POC_MOVFW, popGet(AOP(left),offl));
-        if(same) {
-            emitpcode(POC_ADDWF, popGet(AOP(left),offl));
-        } else {
-            emitpcode(POC_ADDFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-        }
-        break;
-    case 2:
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW,popGetLit(0x7e));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-        break;
-    case 3:
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW,popGetLit(0x3e));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-        emitpcode(POC_RLF,  popGet(AOP(result),offr));
-        break;
-    case 4:
-        emitpcode(POC_SWAPFW,popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0xf0));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        break;
-    case 5:
-        emitpcode(POC_SWAPFW,popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0xf0));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-        break;
-    case 6:
-        emitpcode(POC_SWAPFW,popGet(AOP(left),offl));
-        emitpcode(POC_ANDLW, popGetLit(0x30));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-        emitpcode(POC_RLF,  popGet(AOP(result),offr));
-        break;
-    case 7:
-        emitpcode(POC_RRFW, popGet(AOP(left),offl));
-        emitpcode(POC_CLRF, popGet(AOP(result),offr));
-        emitpcode(POC_RRF,  popGet(AOP(result),offr));
-        break;
-
-    default:
-        DEBUGpic14_emitcode ("; ***","%s  %d, shift count is %d",__FUNCTION__,__LINE__,shCount);
-    }
-
-}
-#endif
-
-/*-----------------------------------------------------------------*/
-/* movLeft2Result - move byte from left to result                  */
-/*-----------------------------------------------------------------*/
-static void movLeft2Result (operand *left, int offl,
-                            operand *result, int offr)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(!pic14_sameRegs(AOP(left),AOP(result)) || (offl != offr)){
-        aopGet(AOP(left),offl,FALSE,FALSE);
-
-        emitpcode(POC_MOVFW, popGet(AOP(left),offl));
-        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-    }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftLeft_Left2ResultLit - shift left by known count            */
-/*-----------------------------------------------------------------*/
-
-static void shiftLeft_Left2ResultLit (operand *left, operand *result, int shCount)
-{
-    int size, same, offr, i;
-
-    size = AOP_SIZE(left);
-    if (AOP_SIZE(result) < size) size = AOP_SIZE(result);
-
-    same = pic14_sameRegs (AOP(left), AOP(result));
-
-    offr = shCount / 8;
-    shCount = shCount & 0x07;
-
-    size -= offr;
-
-    switch (shCount)
-    {
-    case 0: /* takes 0 or 2N cycles (for offr==0) */
-        if (!same || offr) {
-            for (i=size-1; i >= 0; i--)
-                movLeft2Result (left, i, result, offr + i);
-        } // if
-        break;
-
-    case 1: /* takes 1N+1 or 2N+1 cycles (or offr==0) */
-        if (same && offr) {
-            shiftLeft_Left2ResultLit (left, result, 8 * offr);
-            shiftLeft_Left2ResultLit (result, result, shCount);
-            return; /* prevent clearing result again */
-        } else {
-            emitCLRC;
-            for (i=0; i < size; i++) {
-                if (same && !offr) {
-                    emitpcode (POC_RLF, popGet (AOP(left), i));
-                } else {
-                    emitpcode (POC_RLFW, popGet (AOP(left), i));
-                    emitpcode (POC_MOVWF, popGet (AOP(result), i + offr));
-                } // if
-            } // for
-        } // if (offr)
-        break;
-
-    case 4: /* takes 3+5(N-1) = 5N-2 cycles (for offr==0) */
-        /* works in-place/with offr as well */
-        emitpcode (POC_SWAPFW, popGet (AOP(left), size-1));
-        emitpcode (POC_ANDLW, popGetLit (0xF0));
-        emitpcode (POC_MOVWF, popGet(AOP(result), size-1+offr));
-
-        for (i = size - 2; i >= 0; i--)
-        {
-            emitpcode (POC_SWAPFW, popGet (AOP(left), i));
-            emitpcode (POC_MOVWF, popGet (AOP(result), i + offr));
-            emitpcode (POC_ANDLW, popGetLit (0x0F));
-            emitpcode (POC_IORWF, popGet (AOP(result), i + offr + 1));
-            emitpcode (POC_XORWF, popGet (AOP(result), i + offr));
-        } // for i
-        break;
-
-    case 7: /* takes 2(N-1)+3 = 2N+1 cycles */
-        /* works in-place/with offr as well */
-        emitpcode (POC_RRFW, popGet (AOP(left), size-1));
-        for (i = size-2; i >= 0; i--) {
-            emitpcode (POC_RRFW, popGet (AOP(left), i));
-            emitpcode (POC_MOVWF, popGet (AOP(result), offr + i + 1));
-        } // for i
-        emitpcode (POC_CLRF, popGet (AOP(result), offr));
-        emitpcode (POC_RRF, popGet (AOP(result), offr));
-        break;
+    if(pic14_sameRegs(AOP(result),AOP(left))){
+        /* if left is same as result */
+        for(;size--; offset++) {
+            if(AOP_TYPE(right) == AOP_LIT){
+                int t  = (lit >> (offset*8)) & 0x0FFL;
+                if(t == 0x00L)
+                    continue;
+                else {
+                        emitpcode(POC_MOVLW, popGetLit(t));
+                        emitpcode(POC_XORWF,popGet(AOP(left),offset));
+                }
+            } else {
+                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+                emitpcode(POC_XORWF,popGet(AOP(left),offset));
+            }
+        }
+    } else {
+        // left & result in different registers
+        if(AOP_TYPE(result) == AOP_CRY){
+            // result = bit
+            // if(size), result in bit
+            // if(!size && ifx), conditional oper: if(left ^ right)
+            symbol *tlbl = newiTempLabel(NULL);
+            int sizer = max(AOP_SIZE(left),AOP_SIZE(right));
+            if(size)
+                pic14_emitcode("setb","c");
+            while(sizer--){
+                if((AOP_TYPE(right) == AOP_LIT) &&
+                    (((lit >> (offset*8)) & 0x0FFL) == 0x00L)){
+                    MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
+                } else {
+                    MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
+                    pic14_emitcode("xrl","a,%s",
+                        aopGet(AOP(left),offset,FALSE,FALSE));
+                }
+                pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
+                offset++;
+            }
+            if(size){
+                CLRC;
+                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
+                pic14_outBitC(result);
+            } else if(ifx)
+                jmpTrueOrFalse(ifx, tlbl);
+        } else for(;(size--);offset++){
+            // normal case
+            // result = left & right
+            if(AOP_TYPE(right) == AOP_LIT){
+                int t = (lit >> (offset*8)) & 0x0FFL;
+                switch(t) {
+                case 0x00:
+                    emitpcode(POC_MOVFW,popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+                    break;
+                case 0xff:
+                    emitpcode(POC_COMFW,popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+                    break;
+                default:
+                    emitpcode(POC_MOVLW, popGetLit(t));
+                    emitpcode(POC_XORFW,popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+                }
+                continue;
+            }
 
-    default:
-        shiftLeft_Left2ResultLit (left, result, offr * 8 + shCount-1);
-        shiftLeft_Left2ResultLit (result, result, 1);
-        return; /* prevent clearing result again */
-        break;
-    } // switch
+            // faster than result <- left, anl result,right
+            // and better if result is SFR
+            emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+            emitpcode(POC_XORFW,popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+        }
+    }
 
-    while (0 < offr--)
-    {
-        emitpcode (POC_CLRF, popGet (AOP(result), offr));
-    } // while
+release :
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftRight_Left2ResultLit - shift right by known count          */
+/* genInline - write the inline code out                           */
 /*-----------------------------------------------------------------*/
-
-static void shiftRight_Left2ResultLit (operand *left, operand *result, int shCount, int sign)
+static void genInline (iCode *ic)
 {
-    int size, same, offr, i;
-
-    size = AOP_SIZE(left);
-    if (AOP_SIZE(result) < size) size = AOP_SIZE(result);
+  char *buffer, *bp, *bp1;
+  bool inComment = FALSE;
 
-    same = pic14_sameRegs (AOP(left), AOP(result));
+  FENTRY;
+  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-    offr = shCount / 8;
-    shCount = shCount & 0x07;
+  _G.inLine += (!options.asmpeep);
 
-    size -= offr;
+  buffer = bp = bp1 = Safe_strdup (IC_INLINE (ic));
 
-    if (size)
+  while (*bp)
     {
-        switch (shCount)
+      switch (*bp)
         {
-        case 0: /* takes 0 or 2N cycles (for offr==0) */
-            if (!same || offr) {
-                for (i=0; i < size; i++)
-                    movLeft2Result (left, i + offr, result, i);
-            } // if
-            break;
-
-        case 1: /* takes 1N+1(3) or 2N+1(3) cycles (or offr==0) */
-            emitpComment ("%s:%d: shCount=%d, size=%d, sign=%d, same=%d, offr=%d", __FUNCTION__, __LINE__, shCount, size, sign, same, offr);
-            if (same && offr) {
-                shiftRight_Left2ResultLit (left, result, 8 * offr, sign);
-                shiftRight_Left2ResultLit (result, result, shCount, sign);
-                return; /* prevent sign-extending result again */
-            } else {
-                emitCLRC;
-                if (sign) {
-                    emitpcode (POC_BTFSC, newpCodeOpBit (aopGet (AOP(left), AOP_SIZE(left)-1, FALSE, FALSE), 7, 0));
-                    emitSETC;
-                }
-                for (i = size-1; i >= 0; i--) {
-                    if (same && !offr) {
-                        emitpcode (POC_RRF, popGet (AOP(left), i));
-                    } else {
-                        emitpcode (POC_RRFW, popGet (AOP(left), i + offr));
-                        emitpcode (POC_MOVWF, popGet (AOP(result), i));
-                    }
-                } // for i
-            } // if (offr)
-            break;
-
-        case 4: /* takes 3(6)+5(N-1) = 5N-2(+1) cycles (for offr==0) */
-            /* works in-place/with offr as well */
-            emitpcode (POC_SWAPFW, popGet (AOP(left), offr));
-            emitpcode (POC_ANDLW, popGetLit (0x0F));
-            emitpcode (POC_MOVWF, popGet(AOP(result), 0));
+        case ';':
+          inComment = TRUE;
+          ++bp;
+          break;
 
-            for (i = 1; i < size; i++)
-            {
-                emitpcode (POC_SWAPFW, popGet (AOP(left), i + offr));
-                emitpcode (POC_MOVWF, popGet (AOP(result), i));
-                emitpcode (POC_ANDLW, popGetLit (0xF0));
-                emitpcode (POC_IORWF, popGet (AOP(result), i - 1));
-                emitpcode (POC_XORWF, popGet (AOP(result), i));
-            } // for i
+        case '\n':
+          inComment = FALSE;
+          *bp++ = '\0';
+          if (*bp1)
+            addpCode2pBlock(pb, newpCodeAsmDir(bp1, NULL)); // inline directly, no process
+          bp1 = bp;
+          break;
 
-            if (sign)
+        default:
+          /* Add \n for labels, not dirs such as c:\mydir */
+          if (!inComment && (*bp == ':') && (isspace((unsigned char)bp[1])))
             {
-                emitpcode (POC_MOVLW, popGetLit (0xF0));
-                emitpcode (POC_BTFSC, newpCodeOpBit (aopGet (AOP(result), size-1, FALSE, FALSE), 3, 0));
-                emitpcode (POC_IORWF, popGet (AOP(result), size-1));
-            } // if
-            break;
-
-        case 7: /* takes 2(N-1)+3(4) = 2N+1(2) cycles */
-            /* works in-place/with offr as well */
-            emitpcode (POC_RLFW, popGet (AOP(left), offr));
-            for (i = 0; i < size-1; i++) {
-                emitpcode (POC_RLFW, popGet (AOP(left), offr + i + 1));
-                emitpcode (POC_MOVWF, popGet (AOP(result), i));
-            } // for i
-            emitpcode (POC_CLRF, popGet (AOP(result), size-1));
-            if (!sign) {
-                emitpcode (POC_RLF, popGet (AOP(result), size-1));
-            } else {
-                emitSKPNC;
-                emitpcode (POC_DECF, popGet (AOP(result), size-1));
+              ++bp;
+              *bp = '\0';
+              ++bp;
+              /* print label, use this special format with NULL directive
+               * to denote that the argument should not be indented with tab */
+              addpCode2pBlock(pb, newpCodeAsmDir(NULL, bp1)); // inline directly, no process
+              bp1 = bp;
             }
-            break;
+          else
+            ++bp;
+          break;
+        }
+    }
+  if ((bp1 != bp) && *bp1)
+    addpCode2pBlock(pb, newpCodeAsmDir(bp1, NULL)); // inline directly, no process
 
-        default:
-            shiftRight_Left2ResultLit (left, result, offr * 8 + shCount-1, sign);
-            shiftRight_Left2ResultLit (result, result, 1, sign);
-            return; /* prevent sign extending result again */
-            break;
-        } // switch
-    } // if
+  Safe_free (buffer);
 
-    addSign (result, size, sign);
+  _G.inLine -= (!options.asmpeep);
 }
 
-#if 0
 /*-----------------------------------------------------------------*/
-/* shiftL2Left2Result - shift left two bytes from left to result   */
+/* genRRC - rotate right with carry                                */
 /*-----------------------------------------------------------------*/
-static void shiftL2Left2Result (operand *left, int offl,
-                                operand *result, int offr, int shCount)
+static void genRRC (iCode *ic)
 {
+    operand *left , *result ;
+    int size, offset = 0, same;
+
     FENTRY;
+    /* rotate right with carry */
+    left = IC_LEFT(ic);
+    result=IC_RESULT(ic);
+    aopOp (left,ic,FALSE);
+    aopOp (result,ic,FALSE);
 
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    DEBUGpic14_AopType(__LINE__,left,NULL,result);
 
-    if(pic14_sameRegs(AOP(result), AOP(left))) {
-        switch(shCount) {
-        case 0:
-            break;
-        case 1:
-        case 2:
-        case 3:
+    same = pic14_sameRegs(AOP(result),AOP(left));
 
-            emitpcode(POC_MOVFW,popGet(AOP(result),offr));
-            emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
+    size = AOP_SIZE(result);
 
-            while(--shCount) {
-                emitCLRC;
-                emitpcode(POC_RLF, popGet(AOP(result),offr));
-                emitpcode(POC_RLF, popGet(AOP(result),offr+MSB16));
-            }
+    /* get the lsb and put it into the carry */
+    emitpcode(POC_RRFW, popGet(AOP(left),size-1));
 
-            break;
-        case 4:
-        case 5:
-            emitpcode(POC_MOVLW, popGetLit(0x0f));
-            emitpcode(POC_ANDWF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr));
-            emitpcode(POC_ANDFW, popGet(AOP(result),offr));
-            emitpcode(POC_XORWF, popGet(AOP(result),offr));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr+MSB16));
-            if(shCount >=5) {
-                emitpcode(POC_RLF, popGet(AOP(result),offr));
-                emitpcode(POC_RLF, popGet(AOP(result),offr+MSB16));
-            }
-            break;
-        case 6:
-            emitpcode(POC_RRF,  popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr));
-            emitpcode(POC_RRFW, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ANDLW,popGetLit(0xc0));
-            emitpcode(POC_XORFW,popGet(AOP(result),offr));
-            emitpcode(POC_XORWF,popGet(AOP(result),offr));
-            emitpcode(POC_XORFW,popGet(AOP(result),offr));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            break;
-        case 7:
-            emitpcode(POC_RRFW, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRFW, popGet(AOP(result),offr));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_CLRF, popGet(AOP(result),offr));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr));
-        }
+    offset = 0 ;
 
-    } else {
-        switch(shCount) {
-        case 0:
-            break;
-        case 1:
-        case 2:
-        case 3:
-        /* note, use a mov/add for the shift since the mov has a
-            chance of getting optimized out */
-            emitpcode(POC_MOVFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr));
-            emitpcode(POC_RLFW,  popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr+MSB16));
-
-            while(--shCount) {
-                emitCLRC;
-                emitpcode(POC_RLF, popGet(AOP(result),offr));
-                emitpcode(POC_RLF, popGet(AOP(result),offr+MSB16));
-            }
-            break;
+    while(size--) {
 
-        case 4:
-        case 5:
-            emitpcode(POC_SWAPFW,popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_ANDLW, popGetLit(0xF0));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_SWAPFW,popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-            emitpcode(POC_ANDLW, popGetLit(0xF0));
-            emitpcode(POC_XORWF, popGet(AOP(result),offr));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr+MSB16));
-
-
-            if(shCount == 5) {
-                emitpcode(POC_RLF, popGet(AOP(result),offr));
-                emitpcode(POC_RLF, popGet(AOP(result),offr+MSB16));
-            }
-            break;
-        case 6:
-            emitpcode(POC_RRFW, popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRFW, popGet(AOP(result),offl));
-            emitpcode(POC_MOVWF,  popGet(AOP(result),offr));
-
-            emitpcode(POC_RRF,  popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr));
-            emitpcode(POC_RRFW, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ANDLW,popGetLit(0xc0));
-            emitpcode(POC_XORFW,popGet(AOP(result),offr));
-            emitpcode(POC_XORWF,popGet(AOP(result),offr));
-            emitpcode(POC_XORFW,popGet(AOP(result),offr));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            break;
-        case 7:
-            emitpcode(POC_RRFW, popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_CLRF, popGet(AOP(result),offr));
-            emitpcode(POC_RRF,  popGet(AOP(result),offr));
+        if(same) {
+            emitpcode(POC_RRF, popGet(AOP(left),offset));
+        } else {
+            emitpcode(POC_RRFW, popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
         }
+
+        offset++;
     }
 
+    freeAsmop(left,NULL,ic,TRUE);
+    freeAsmop(result,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftR2Left2Result - shift right two bytes from left to result  */
+/* genRLC - generate code for rotate left with carry               */
 /*-----------------------------------------------------------------*/
-static void shiftR2Left2Result (operand *left, int offl,
-                                operand *result, int offr,
-                                int shCount, int sign)
+static void genRLC (iCode *ic)
 {
-    int same=0;
+    operand *left , *result ;
+    int size, offset = 0;
+    int same;
 
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    same = pic14_sameRegs(AOP(result), AOP(left));
+    /* rotate right with carry */
+    left = IC_LEFT(ic);
+    result=IC_RESULT(ic);
+    aopOp (left,ic,FALSE);
+    aopOp (result,ic,FALSE);
 
-    if(same && ((offl + MSB16) == offr)){
-        same=1;
-        /* don't crash result[offr] */
-        MOVA(aopGet(AOP(left),offl,FALSE,FALSE));
-        pic14_emitcode("xch","a,%s", aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
-    }
-    /* else {
-    movLeft2Result(left,offl, result, offr);
-    MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
-    }
-    */
-    /* a:x >> shCount (x = lsb(result))*/
-    switch(shCount) {
-    case 0:
-        break;
-    case 1:
-    case 2:
-    case 3:
-        if(sign)
-            emitpcode(POC_RLFW,popGet(AOP(left),offl+MSB16));
-        else
-            emitCLRC;
+    DEBUGpic14_AopType(__LINE__,left,NULL,result);
 
-        if(same) {
-            emitpcode(POC_RRF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF,popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_RRFW, popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        }
+    same = pic14_sameRegs(AOP(result),AOP(left));
 
-        while(--shCount) {
-            if(sign)
-                emitpcode(POC_RLFW,popGet(AOP(result),offr+MSB16));
-            else
-                emitCLRC;
-            emitpcode(POC_RRF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF,popGet(AOP(result),offr));
-        }
-        break;
-    case 4:
-    case 5:
-        if(same) {
+    /* move it to the result */
+    size = AOP_SIZE(result);
 
-            emitpcode(POC_MOVLW, popGetLit(0xf0));
-            emitpcode(POC_ANDWF, popGet(AOP(result),offr));
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr));
+    /* get the msb and put it into the carry */
+    emitpcode(POC_RLFW, popGet(AOP(left),size-1));
 
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ANDFW, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_XORWF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_SWAPFW,popGet(AOP(left),offl));
-            emitpcode(POC_ANDLW, popGetLit(0x0f));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr));
-
-            emitpcode(POC_SWAPFW,popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_MOVWF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ANDLW, popGetLit(0xf0));
-            emitpcode(POC_XORWF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr));
-        }
+    offset = 0 ;
 
-        if(shCount >=5) {
-            emitpcode(POC_RRF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
-        }
+    while(size--) {
 
-        if(sign) {
-            emitpcode(POC_MOVLW, popGetLit(0xf0 + (shCount-4)*8 ));
-            emitpcode(POC_BTFSC,
-                newpCodeOpBit(aopGet(AOP(result),offr+MSB16,FALSE,FALSE),7-shCount,0));
-            emitpcode(POC_ADDWF, popGet(AOP(result),offr+MSB16));
+        if(same) {
+            emitpcode(POC_RLF, popGet(AOP(left),offset));
+        } else {
+            emitpcode(POC_RLFW, popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
         }
 
-        break;
+        offset++;
+    }
 
-    case 6:
-        if(same) {
 
-            emitpcode(POC_RLF,  popGet(AOP(result),offr));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
-
-            emitpcode(POC_RLF,  popGet(AOP(result),offr));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RLFW, popGet(AOP(result),offr));
-            emitpcode(POC_ANDLW,popGetLit(0x03));
-            if(sign) {
-                emitpcode(POC_BTFSC,
-                    newpCodeOpBit(aopGet(AOP(result),offr+MSB16,FALSE,FALSE),1,0));
-                emitpcode(POC_IORLW,popGetLit(0xfc));
-            }
-            emitpcode(POC_XORFW,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_XORWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_XORFW,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        } else {
-            emitpcode(POC_RLFW, popGet(AOP(left),offl));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RLFW, popGet(AOP(left),offl+MSB16));
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr));
-            emitpcode(POC_RLFW, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_ANDLW,popGetLit(0x03));
-            if(sign) {
-                emitpcode(POC_BTFSC,
-                    newpCodeOpBit(aopGet(AOP(result),offr+MSB16,FALSE,FALSE),0,0));
-                emitpcode(POC_IORLW,popGetLit(0xfc));
-            }
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            //emitpcode(POC_RLF,  popGet(AOP(result),offr));
+    freeAsmop(left,NULL,ic,TRUE);
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
+/*-----------------------------------------------------------------*/
+/* genGetHbit - generates code get highest order bit               */
+/*-----------------------------------------------------------------*/
+static void genGetHbit (iCode *ic)
+{
+    operand *left, *result;
+    left = IC_LEFT(ic);
+    result=IC_RESULT(ic);
+    aopOp (left,ic,FALSE);
+    aopOp (result,ic,FALSE);
 
-        }
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    /* get the highest order byte into a */
+    MOVA(aopGet(AOP(left),AOP_SIZE(left) - 1,FALSE,FALSE));
+    if(AOP_TYPE(result) == AOP_CRY){
+        pic14_emitcode("rlc","a");
+        pic14_outBitC(result);
+    }
+    else{
+        pic14_emitcode("rl","a");
+        pic14_emitcode("anl","a,#0x01");
+        pic14_outAcc(result);
+    }
 
-        break;
-    case 7:
-        emitpcode(POC_RLFW, popGet(AOP(left),offl));
-        emitpcode(POC_RLFW, popGet(AOP(left),offl+MSB16));
-        emitpcode(POC_MOVWF,popGet(AOP(result),offr));
-        emitpcode(POC_CLRF, popGet(AOP(result),offr+MSB16));
-        if(sign) {
-            emitSKPNC;
-            emitpcode(POC_DECF, popGet(AOP(result),offr+MSB16));
-        } else
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
-  }
+
+    freeAsmop(left,NULL,ic,TRUE);
+    freeAsmop(result,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftLLeftOrResult - shift left one byte from left, or to result*/
+/* AccLsh - shift left accumulator by known count                  */
+/* MARK: pic14 always rotates through CARRY!                       */
 /*-----------------------------------------------------------------*/
-static void shiftLLeftOrResult (operand *left, int offl,
-                                operand *result, int offr, int shCount)
+static void AccLsh (pCodeOp *pcop,int shCount)
 {
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    /* shift left accumulator */
-    AccLsh(left,offl,shCount);
-    /* or with result */
-    emitpcode (POC_IORWF, popGet (AOP(result), offr));
-    assert ( !"broken (modifies left, fails for left==result))" );
+    shCount &= 0x0007;              // shCount : 0..7
+    switch(shCount){
+    case 0 :
+        return;
+        break;
+    case 1 :
+        emitCLRC;
+        emitpcode(POC_RLF,pcop);
+        return;
+        break;
+    case 2 :
+        emitpcode(POC_RLF,pcop);
+        emitpcode(POC_RLF,pcop);
+        break;
+    case 3 :
+        emitpcode(POC_RLF,pcop);
+        emitpcode(POC_RLF,pcop);
+        emitpcode(POC_RLF,pcop);
+        break;
+    case 4 :
+        emitpcode(POC_SWAPF,pcop);
+        break;
+    case 5 :
+        emitpcode(POC_SWAPF,pcop);
+        emitpcode(POC_RLF,pcop);
+        break;
+    case 6 :
+        emitpcode(POC_SWAPF,pcop);
+        emitpcode(POC_RLF,pcop);
+        emitpcode(POC_RLF,pcop);
+        break;
+    case 7 :
+        emitpcode(POC_RRFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        break;
+    }
+    /* clear invalid bits */
+    emitpcode(POC_MOVLW, popGetLit ((unsigned char)(~((1UL << shCount) - 1))));
+    emitpcode(POC_ANDWF, pcop);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftRLeftOrResult - shift right one byte from left,or to result*/
+/* AccRsh - shift right accumulator by known count                 */
+/* MARK: pic14 always rotates through CARRY!                       */
+/* maskmode - 0: leave invalid bits undefined (caller should mask) */
+/*            1: mask out invalid bits (zero-extend)               */
+/*            2: sign-extend result (pretty slow)                  */
 /*-----------------------------------------------------------------*/
-static void shiftRLeftOrResult (operand *left, int offl,
-                                operand *result, int offr, int shCount)
+static void AccRsh (pCodeOp *pcop,int shCount, int mask_mode)
 {
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    shCount &= 0x0007;              // shCount : 0..7
+    switch(shCount){
+    case 0 :
+        return;
+        break;
+    case 1 :
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        else if (mask_mode == 1) emitCLRC;
+        emitpcode(POC_RRF,pcop);
+        return;
+        break;
+    case 2 :
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        if (mask_mode == 2) return;
+        break;
+    case 3 :
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        /* load sign if needed */
+        if (mask_mode == 2) emitpcode(POC_RLFW,pcop);
+        emitpcode(POC_RRF,pcop);
+        if (mask_mode == 2) return;
+        break;
+    case 4 :
+        emitpcode(POC_SWAPF,pcop);
+        break;
+    case 5 :
+        emitpcode(POC_SWAPF,pcop);
+        emitpcode(POC_RRF,pcop);
+        break;
+    case 6 :
+        emitpcode(POC_SWAPF,pcop);
+        emitpcode(POC_RRF,pcop);
+        emitpcode(POC_RRF,pcop);
+        break;
+    case 7 :
+        if (mask_mode == 2)
+        {
+            /* load sign */
+            emitpcode(POC_RLFW,pcop);
+            emitpcode(POC_CLRF,pcop);
+            emitSKPNC;
+            emitpcode(POC_COMF,pcop);
+            return;
+        } else {
+            emitpcode(POC_RLFW,pcop);
+            emitpcode(POC_RLF,pcop);
+        }
+        break;
+    }
+
+    if (mask_mode == 0)
+    {
+        /* leave invalid bits undefined */
+        return;
+    }
 
-    /* shift right accumulator */
-    AccRsh(left,offl,shCount);
-    /* or with result */
-    emitpcode (POC_IORWF, popGet (AOP(result), offr));
-    assert ( !"broken (modifies left, fails for left==result))" );
+    /* clear invalid bits -- zero-extend */
+    emitpcode(POC_MOVLW, popGetLit (0x00ff >> shCount));
+    emitpcode(POC_ANDWF, pcop);
+
+    if (mask_mode == 2) {
+      /* sign-extend */
+      emitpcode(POC_MOVLW, popGetLit (0x00ff << (8 - shCount)));
+      emitpcode(POC_BTFSC, newpCodeOpBit (get_op(pcop,NULL,0), 7 - shCount ,0));
+      emitpcode(POC_IORWF, pcop);
+    }
 }
 
 /*-----------------------------------------------------------------*/
-/* genlshOne - left shift a one byte quantity by known count       */
+/* movLeft2Result - move byte from left to result                  */
 /*-----------------------------------------------------------------*/
-static void genlshOne (operand *result, operand *left, int shCount)
+static void movLeft2Result (operand *left, int offl,
+                            operand *result, int offr)
 {
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    shiftL1Left2Result(left, LSB, result, LSB, shCount);
+    if(!pic14_sameRegs(AOP(left),AOP(result)) || (offl != offr)){
+        aopGet(AOP(left),offl,FALSE,FALSE);
+
+        emitpcode(POC_MOVFW, popGet(AOP(left),offl));
+        emitpcode(POC_MOVWF, popGet(AOP(result),offr));
+    }
 }
 
 /*-----------------------------------------------------------------*/
-/* genlshTwo - left shift two bytes by known amount != 0           */
+/* shiftLeft_Left2ResultLit - shift left by known count            */
 /*-----------------------------------------------------------------*/
-static void genlshTwo (operand *result,operand *left, int shCount)
+
+static void shiftLeft_Left2ResultLit (operand *left, operand *result, int shCount)
 {
-    int size;
+    int size, same, offr, i;
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    size = pic14_getDataSize(result);
+    size = AOP_SIZE(left);
+    if (AOP_SIZE(result) < size) size = AOP_SIZE(result);
 
-    /* if shCount >= 8 */
-    if (shCount >= 8) {
-        shCount -= 8 ;
+    same = pic14_sameRegs (AOP(left), AOP(result));
 
-        if (size > 1){
-            if (shCount)
-                shiftL1Left2Result(left, LSB, result, MSB16, shCount);
-            else
-                movLeft2Result(left, LSB, result, MSB16);
-        }
-        emitpcode(POC_CLRF,popGet(AOP(result),LSB));
-    }
+    offr = shCount / 8;
+    shCount = shCount & 0x07;
 
-    /*  1 <= shCount <= 7 */
-    else {
-        if(size == 1)
-            shiftL1Left2Result(left, LSB, result, LSB, shCount);
-        else
-            shiftL2Left2Result(left, LSB, result, LSB, shCount);
-    }
-}
+    size -= offr;
+
+    switch (shCount)
+    {
+    case 0: /* takes 0 or 2N cycles (for offr==0) */
+        if (!same || offr) {
+            for (i=size-1; i >= 0; i--)
+                movLeft2Result (left, i, result, offr + i);
+        } // if
+        break;
+
+    case 1: /* takes 1N+1 or 2N+1 cycles (or offr==0) */
+        if (same && offr) {
+            shiftLeft_Left2ResultLit (left, result, 8 * offr);
+            shiftLeft_Left2ResultLit (result, result, shCount);
+            return; /* prevent clearing result again */
+        } else {
+            emitCLRC;
+            for (i=0; i < size; i++) {
+                if (same && !offr) {
+                    emitpcode (POC_RLF, popGet (AOP(left), i));
+                } else {
+                    emitpcode (POC_RLFW, popGet (AOP(left), i));
+                    emitpcode (POC_MOVWF, popGet (AOP(result), i + offr));
+                } // if
+            } // for
+        } // if (offr)
+        break;
 
-/*-----------------------------------------------------------------*/
-/* shiftLLong - shift left one long from left to result            */
-/* offl = LSB or MSB16                                             */
-/*-----------------------------------------------------------------*/
-static void shiftLLong (operand *left, operand *result, int offr )
-{
-    char *l;
-    int size = AOP_SIZE(result);
+    case 4: /* takes 3+5(N-1) = 5N-2 cycles (for offr==0) */
+        /* works in-place/with offr as well */
+        emitpcode (POC_SWAPFW, popGet (AOP(left), size-1));
+        emitpcode (POC_ANDLW, popGetLit (0xF0));
+        emitpcode (POC_MOVWF, popGet(AOP(result), size-1+offr));
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(size >= LSB+offr){
-        l = aopGet(AOP(left),LSB,FALSE,FALSE);
-        MOVA(l);
-        pic14_emitcode("add","a,acc");
-        if (pic14_sameRegs(AOP(left),AOP(result)) &&
-            size >= MSB16+offr && offr != LSB )
-            pic14_emitcode("xch","a,%s",
-            aopGet(AOP(left),LSB+offr,FALSE,FALSE));
-        else
-            aopPut(AOP(result),"a",LSB+offr);
-    }
+        for (i = size - 2; i >= 0; i--)
+        {
+            emitpcode (POC_SWAPFW, popGet (AOP(left), i));
+            emitpcode (POC_MOVWF, popGet (AOP(result), i + offr));
+            emitpcode (POC_ANDLW, popGetLit (0x0F));
+            emitpcode (POC_IORWF, popGet (AOP(result), i + offr + 1));
+            emitpcode (POC_XORWF, popGet (AOP(result), i + offr));
+        } // for i
+        break;
 
-    if(size >= MSB16+offr){
-        if (!(pic14_sameRegs(AOP(result),AOP(left)) && size >= MSB16+offr && offr != LSB) ) {
-            l = aopGet(AOP(left),MSB16,FALSE,FALSE);
-            MOVA(l);
-        }
-        pic14_emitcode("rlc","a");
-        if (pic14_sameRegs(AOP(left),AOP(result)) &&
-            size >= MSB24+offr && offr != LSB)
-            pic14_emitcode("xch","a,%s",
-            aopGet(AOP(left),MSB16+offr,FALSE,FALSE));
-        else
-            aopPut(AOP(result),"a",MSB16+offr);
-    }
+    case 7: /* takes 2(N-1)+3 = 2N+1 cycles */
+        /* works in-place/with offr as well */
+        emitpcode (POC_RRFW, popGet (AOP(left), size-1));
+        for (i = size-2; i >= 0; i--) {
+            emitpcode (POC_RRFW, popGet (AOP(left), i));
+            emitpcode (POC_MOVWF, popGet (AOP(result), offr + i + 1));
+        } // for i
+        emitpcode (POC_CLRF, popGet (AOP(result), offr));
+        emitpcode (POC_RRF, popGet (AOP(result), offr));
+        break;
 
-    if(size >= MSB24+offr){
-        if (!(pic14_sameRegs(AOP(left),AOP(left)) && size >= MSB24+offr && offr != LSB)) {
-            l = aopGet(AOP(left),MSB24,FALSE,FALSE);
-            MOVA(l);
-        }
-        pic14_emitcode("rlc","a");
-        if (pic14_sameRegs(AOP(left),AOP(result)) &&
-            size >= MSB32+offr && offr != LSB )
-            pic14_emitcode("xch","a,%s",
-            aopGet(AOP(left),MSB24+offr,FALSE,FALSE));
-        else
-            aopPut(AOP(result),"a",MSB24+offr);
-    }
+    default:
+        shiftLeft_Left2ResultLit (left, result, offr * 8 + shCount-1);
+        shiftLeft_Left2ResultLit (result, result, 1);
+        return; /* prevent clearing result again */
+        break;
+    } // switch
 
-    if(size > MSB32+offr){
-        if (!(pic14_sameRegs(AOP(result),AOP(left)) && size >= MSB32+offr && offr != LSB)) {
-            l = aopGet(AOP(left),MSB32,FALSE,FALSE);
-            MOVA(l);
-        }
-        pic14_emitcode("rlc","a");
-        aopPut(AOP(result),"a",MSB32+offr);
-    }
-    if(offr != LSB)
-        aopPut(AOP(result),zero,LSB);
+    while (0 < offr--)
+    {
+        emitpcode (POC_CLRF, popGet (AOP(result), offr));
+    } // while
 }
 
 /*-----------------------------------------------------------------*/
-/* genlshFour - shift four byte by a known amount != 0             */
+/* shiftRight_Left2ResultLit - shift right by known count          */
 /*-----------------------------------------------------------------*/
-static void genlshFour (operand *result, operand *left, int shCount)
+
+static void shiftRight_Left2ResultLit (operand *left, operand *result, int shCount, int sign)
 {
-    int size;
+    int size, same, offr, i;
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    size = AOP_SIZE(result);
+    size = AOP_SIZE(left);
+    if (AOP_SIZE(result) < size) size = AOP_SIZE(result);
 
-    /* if shifting more that 3 bytes */
-    if (shCount >= 24 ) {
-        shCount -= 24;
-        if (shCount)
-        /* lowest order of left goes to the highest
-        order of the destination */
-        shiftL1Left2Result(left, LSB, result, MSB32, shCount);
-        else
-            movLeft2Result(left, LSB, result, MSB32);
-        aopPut(AOP(result),zero,LSB);
-        aopPut(AOP(result),zero,MSB16);
-        aopPut(AOP(result),zero,MSB32);
-        return;
-    }
+    same = pic14_sameRegs (AOP(left), AOP(result));
 
-    /* more than two bytes */
-    else if ( shCount >= 16 ) {
-        /* lower order two bytes goes to higher order two bytes */
-        shCount -= 16;
-        /* if some more remaining */
-        if (shCount)
-            shiftL2Left2Result(left, LSB, result, MSB24, shCount);
-        else {
-            movLeft2Result(left, MSB16, result, MSB32);
-            movLeft2Result(left, LSB, result, MSB24);
-        }
-        aopPut(AOP(result),zero,MSB16);
-        aopPut(AOP(result),zero,LSB);
-        return;
-    }
+    offr = shCount / 8;
+    shCount = shCount & 0x07;
 
-    /* if more than 1 byte */
-    else if ( shCount >= 8 ) {
-        /* lower order three bytes goes to higher order  three bytes */
-        shCount -= 8;
-        if(size == 2){
-            if(shCount)
-                shiftL1Left2Result(left, LSB, result, MSB16, shCount);
-            else
-                movLeft2Result(left, LSB, result, MSB16);
-        }
-        else{   /* size = 4 */
-            if(shCount == 0){
-                movLeft2Result(left, MSB24, result, MSB32);
-                movLeft2Result(left, MSB16, result, MSB24);
-                movLeft2Result(left, LSB, result, MSB16);
-                aopPut(AOP(result),zero,LSB);
-            }
-            else if(shCount == 1)
-                shiftLLong(left, result, MSB16);
-            else{
-                shiftL2Left2Result(left, MSB16, result, MSB24, shCount);
-                shiftL1Left2Result(left, LSB, result, MSB16, shCount);
-                shiftRLeftOrResult(left, LSB, result, MSB24, 8 - shCount);
-                aopPut(AOP(result),zero,LSB);
-            }
-        }
-    }
+    size -= offr;
 
-    /* 1 <= shCount <= 7 */
-    else if(shCount <= 2){
-        shiftLLong(left, result, LSB);
-        if(shCount == 2)
-            shiftLLong(result, result, LSB);
-    }
-    /* 3 <= shCount <= 7, optimize */
-    else{
-        shiftL2Left2Result(left, MSB24, result, MSB24, shCount);
-        shiftRLeftOrResult(left, MSB16, result, MSB24, 8 - shCount);
-        shiftL2Left2Result(left, LSB, result, LSB, shCount);
-    }
-}
-#endif
+    if (size)
+    {
+        switch (shCount)
+        {
+        case 0: /* takes 0 or 2N cycles (for offr==0) */
+            if (!same || offr) {
+                for (i=0; i < size; i++)
+                    movLeft2Result (left, i + offr, result, i);
+            } // if
+            break;
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genLeftShiftLiteral - left shifting by known count              */
-/*-----------------------------------------------------------------*/
-static void genLeftShiftLiteral (operand *left,
-                                 operand *right,
-                                 operand *result,
-                                 iCode *ic)
-{
-    int shCount = (int) ulFromVal (AOP(right)->aopu.aop_lit);
-    //int size;
+        case 1: /* takes 1N+1(3) or 2N+1(3) cycles (or offr==0) */
+            emitpComment ("%s:%d: shCount=%d, size=%d, sign=%d, same=%d, offr=%d", __FUNCTION__, __LINE__, shCount, size, sign, same, offr);
+            if (same && offr) {
+                shiftRight_Left2ResultLit (left, result, 8 * offr, sign);
+                shiftRight_Left2ResultLit (result, result, shCount, sign);
+                return; /* prevent sign-extending result again */
+            } else {
+                emitCLRC;
+                if (sign) {
+                    emitpcode (POC_BTFSC, newpCodeOpBit (aopGet (AOP(left), AOP_SIZE(left)-1, FALSE, FALSE), 7, 0));
+                    emitSETC;
+                }
+                for (i = size-1; i >= 0; i--) {
+                    if (same && !offr) {
+                        emitpcode (POC_RRF, popGet (AOP(left), i));
+                    } else {
+                        emitpcode (POC_RRFW, popGet (AOP(left), i + offr));
+                        emitpcode (POC_MOVWF, popGet (AOP(result), i));
+                    }
+                } // for i
+            } // if (offr)
+            break;
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    freeAsmop(right,NULL,ic,TRUE);
+        case 4: /* takes 3(6)+5(N-1) = 5N-2(+1) cycles (for offr==0) */
+            /* works in-place/with offr as well */
+            emitpcode (POC_SWAPFW, popGet (AOP(left), offr));
+            emitpcode (POC_ANDLW, popGetLit (0x0F));
+            emitpcode (POC_MOVWF, popGet(AOP(result), 0));
 
-    aopOp(left,ic,FALSE);
-    aopOp(result,ic,FALSE);
+            for (i = 1; i < size; i++)
+            {
+                emitpcode (POC_SWAPFW, popGet (AOP(left), i + offr));
+                emitpcode (POC_MOVWF, popGet (AOP(result), i));
+                emitpcode (POC_ANDLW, popGetLit (0xF0));
+                emitpcode (POC_IORWF, popGet (AOP(result), i - 1));
+                emitpcode (POC_XORWF, popGet (AOP(result), i));
+            } // for i
 
-    size = getSize(operandType(result));
+            if (sign)
+            {
+                emitpcode (POC_MOVLW, popGetLit (0xF0));
+                emitpcode (POC_BTFSC, newpCodeOpBit (aopGet (AOP(result), size-1, FALSE, FALSE), 3, 0));
+                emitpcode (POC_IORWF, popGet (AOP(result), size-1));
+            } // if
+            break;
 
-#if VIEW_SIZE
-    pic14_emitcode("; shift left ","result %d, left %d",size,
-        AOP_SIZE(left));
-#endif
+        case 7: /* takes 2(N-1)+3(4) = 2N+1(2) cycles */
+            /* works in-place/with offr as well */
+            emitpcode (POC_RLFW, popGet (AOP(left), offr));
+            for (i = 0; i < size-1; i++) {
+                emitpcode (POC_RLFW, popGet (AOP(left), offr + i + 1));
+                emitpcode (POC_MOVWF, popGet (AOP(result), i));
+            } // for i
+            emitpcode (POC_CLRF, popGet (AOP(result), size-1));
+            if (!sign) {
+                emitpcode (POC_RLF, popGet (AOP(result), size-1));
+            } else {
+                emitSKPNC;
+                emitpcode (POC_DECF, popGet (AOP(result), size-1));
+            }
+            break;
 
-    /* I suppose that the left size >= result size */
-    if(shCount == 0){
-        while(size--){
-            movLeft2Result(left, size, result, size);
-        }
-    }
+        default:
+            shiftRight_Left2ResultLit (left, result, offr * 8 + shCount-1, sign);
+            shiftRight_Left2ResultLit (result, result, 1, sign);
+            return; /* prevent sign extending result again */
+            break;
+        } // switch
+    } // if
 
-    else if(shCount >= (size * 8))
-        while(size--)
-            aopPut(AOP(result),zero,size);
-        else{
-            switch (size) {
-            case 1:
-                genlshOne (result,left,shCount);
-                break;
-
-            case 2:
-            case 3:
-                genlshTwo (result,left,shCount);
-                break;
-
-            case 4:
-                genlshFour (result,left,shCount);
-                break;
-            }
-        }
-        freeAsmop(left,NULL,ic,TRUE);
-        freeAsmop(result,NULL,ic,TRUE);
+    addSign (result, size, sign);
 }
-#endif
 
 /*-----------------------------------------------------------------*
 * genMultiAsm - repeat assembly instruction for size of register.
@@ -8101,35 +6317,6 @@ static void genAddrOf (iCode *ic)
 
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genFarFarAssign - assignment when both are in far space         */
-/*-----------------------------------------------------------------*/
-static void genFarFarAssign (operand *result, operand *right, iCode *ic)
-{
-    int size = AOP_SIZE(right);
-    int offset = 0;
-    char *l ;
-    /* first push the right side on to the stack */
-    while (size--) {
-        l = aopGet(AOP(right),offset++,FALSE,FALSE);
-        MOVA(l);
-        pic14_emitcode ("push","acc");
-    }
-
-    freeAsmop(right,NULL,ic,FALSE);
-    /* now assign DPTR to result */
-    aopOp(result,ic,FALSE);
-    size = AOP_SIZE(result);
-    while (size--) {
-        pic14_emitcode ("pop","acc");
-        aopPut(AOP(result),"a",--offset);
-    }
-    freeAsmop(result,NULL,ic,FALSE);
-
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genAssign - generate code for assignment                        */
 /*-----------------------------------------------------------------*/
@@ -8320,138 +6507,6 @@ static void genJumpTab (iCode *ic)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* genMixedOperation - gen code for operators between mixed types  */
-/*-----------------------------------------------------------------*/
-/*
-TSD - Written for the PIC port - but this unfortunately is buggy.
-This routine is good in that it is able to efficiently promote
-types to different (larger) sizes. Unfortunately, the temporary
-variables that are optimized out by this routine are sometimes
-used in other places. So until I know how to really parse the
-iCode tree, I'm going to not be using this routine :(.
-*/
-static int genMixedOperation (iCode *ic)
-{
-    FENTRY;
-#if 0
-    operand *result = IC_RESULT(ic);
-    sym_link *ctype = operandType(IC_LEFT(ic));
-    operand *right = IC_RIGHT(ic);
-    int ret = 0;
-    int big,small;
-    int offset;
-
-    iCode *nextic;
-    operand *nextright=NULL,*nextleft=NULL,*nextresult=NULL;
-
-    pic14_emitcode("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    nextic = ic->next;
-    if(!nextic)
-        return 0;
-
-    nextright = IC_RIGHT(nextic);
-    nextleft  = IC_LEFT(nextic);
-    nextresult = IC_RESULT(nextic);
-
-    aopOp(right,ic,FALSE);
-    aopOp(result,ic,FALSE);
-    aopOp(nextright,  nextic, FALSE);
-    aopOp(nextleft,   nextic, FALSE);
-    aopOp(nextresult, nextic, FALSE);
-
-    if (pic14_sameRegs(AOP(IC_RESULT(ic)), AOP(IC_RIGHT(nextic)))) {
-
-        operand *t = right;
-        right = nextright;
-        nextright = t;
-
-        pic14_emitcode(";remove right +","");
-
-    } else   if (pic14_sameRegs(AOP(IC_RESULT(ic)), AOP(IC_LEFT(nextic)))) {
-    /*
-    operand *t = right;
-    right = nextleft;
-    nextleft = t;
-        */
-        pic14_emitcode(";remove left +","");
-    } else
-        return 0;
-
-    big = AOP_SIZE(nextleft);
-    small = AOP_SIZE(nextright);
-
-    switch(nextic->op) {
-
-    case '+':
-        pic14_emitcode(";optimize a +","");
-        /* if unsigned or not an integral type */
-        if (AOP_TYPE(IC_LEFT(nextic)) == AOP_CRY) {
-            pic14_emitcode(";add a bit to something","");
-        } else {
-
-            pic14_emitcode("movf","%s,w",AOP(nextright)->aopu.aop_dir);
-
-            if (!pic14_sameRegs(AOP(IC_LEFT(nextic)), AOP(IC_RESULT(nextic))) ) {
-                pic14_emitcode("addwf","%s,w",AOP(nextleft)->aopu.aop_dir);
-                pic14_emitcode("movwf","%s",aopGet(AOP(IC_RESULT(nextic)),0,FALSE,FALSE));
-            } else
-                pic14_emitcode("addwf","%s,f",AOP(nextleft)->aopu.aop_dir);
-
-            offset = 0;
-            while(--big) {
-
-                offset++;
-
-                if(--small) {
-                    if (!pic14_sameRegs(AOP(IC_LEFT(nextic)), AOP(IC_RESULT(nextic))) ){
-                        pic14_emitcode("movf","%s,w",aopGet(AOP(IC_LEFT(nextic)),offset,FALSE,FALSE));
-                        pic14_emitcode("movwf","%s,f",aopGet(AOP(IC_RESULT(nextic)),offset,FALSE,FALSE) );
-                    }
-
-                    pic14_emitcode("movf","%s,w", aopGet(AOP(IC_LEFT(nextic)),offset,FALSE,FALSE));
-                    emitSKPNC;
-                    pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
-                        AOP(IC_RIGHT(nextic))->aopu.aop_dir,
-                        AOP(IC_RIGHT(nextic))->aopu.aop_dir);
-                    pic14_emitcode(" incf","%s,w", aopGet(AOP(IC_LEFT(nextic)),offset,FALSE,FALSE));
-                    pic14_emitcode("movwf","%s", aopGet(AOP(IC_RESULT(nextic)),offset,FALSE,FALSE));
-
-                } else {
-                    pic14_emitcode("rlf","known_zero,w");
-
-                    /*
-                    if right is signed
-                    btfsc  right,7
-                    addlw ff
-                    */
-                    if (!pic14_sameRegs(AOP(IC_LEFT(nextic)), AOP(IC_RESULT(nextic))) ){
-                        pic14_emitcode("addwf","%s,w",aopGet(AOP(IC_LEFT(nextic)),offset,FALSE,FALSE));
-                        pic14_emitcode("movwf","%s,f",aopGet(AOP(IC_RESULT(nextic)),offset,FALSE,FALSE) );
-                    } else {
-                        pic14_emitcode("addwf","%s,f",aopGet(AOP(IC_RESULT(nextic)),offset,FALSE,FALSE) );
-                    }
-                }
-            }
-            ret = 1;
-        }
-    }
-    ret = 1;
-
-release:
-    freeAsmop(right,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-    freeAsmop(nextright,NULL,ic,TRUE);
-    freeAsmop(nextleft,NULL,ic,TRUE);
-    if(ret)
-        nextic->generated = 1;
-
-    return ret;
-#else
-    return 0;
-#endif
-}
 /*-----------------------------------------------------------------*/
 /* genCast - gen code for casting                                  */
 /*-----------------------------------------------------------------*/
@@ -8612,14 +6667,7 @@ static void genCast (iCode *ic)
     }
 
     /* so we now know that the size of destination is greater
-    than the size of the source.
-    Now, if the next iCode is an operator then we might be
-    able to optimize the operation without performing a cast.
-    */
-    if(0 && genMixedOperation(ic)) {
-        /* XXX: cannot optimize: must copy regs! */
-        goto release;
-    }
+    than the size of the source. */
 
     /* we move to result for the size of source */
     size = AOP_SIZE(right);
index b0f0bd2b74c77ee8f70e2c19eec84ba87fa99f6b..d4a2b772b52d482814272c47bf59ee15cd0c7b2e 100644 (file)
@@ -77,43 +77,7 @@ const char *AopType(short type)
         return "BAD TYPE";
 }
 
-#if 0
-static void DebugAop(asmop *aop)
-{
-        if(!aop)
-                return;
-        printf("%s\n",AopType(aop->type));
-        printf(" current offset: %d\n",aop->coff);
-        printf("           size: %d\n",aop->size);
-        
-        switch(aop->type) {
-        case AOP_LIT:
-                printf("          name: %s\n",aop->aopu.aop_lit->name);
-                break;
-        case AOP_REG:
-                printf("          name: %s\n",aop->aopu.aop_reg[0]->name);
-                break;
-        case AOP_CRY:
-        case AOP_DIR:
-                printf("          name: %s\n",aop->aopu.aop_dir);
-                break;
-        case AOP_STK:
-                printf("   Stack offset: %d\n",aop->aopu.aop_stk);
-                break;
-        case AOP_IMMD:
-                printf("     immediate: %s\n",aop->aopu.aop_immd);
-                break;
-        case AOP_STR:
-                printf("    aop_str[0]: %s\n",aop->aopu.aop_str[0]);
-                break;
-        case AOP_PCODE:
-                //printpCode(stdout,aop->aopu.pcop);
-                break;
-        }
-}
-#endif
-
-const char *pCodeOpType(  pCodeOp *pcop)
+const char *pCodeOpType(pCodeOp *pcop)
 {
         
         if(pcop) {
@@ -261,98 +225,6 @@ static bool genPlusIncr (iCode *ic)
         return FALSE ;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* pic14_outBitAcc - output a bit in acc                                 */
-/*-----------------------------------------------------------------*/
-static void pic14_outBitAcc(operand *result)
-{
-        symbol *tlbl = newiTempLabel(NULL);
-        /* if the result is a bit */
-        FENTRY;
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-        
-        if (AOP_TYPE(result) == AOP_CRY){
-                aopPut(AOP(result),"a",0);
-        }
-        else {
-                pic14_emitcode("jz","%05d_DS_",tlbl->key+100);
-                pic14_emitcode("mov","a,#01");
-                pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-                pic14_outAcc(result);
-        }
-}
-#endif
-
-#if 0
-/* This is the original version of this code.
-*
-* This is being kept around for reference, 
-* because I am not entirely sure I got it right...
-*/
-static void adjustArithmeticResult(iCode *ic)
-{
-        if (AOP_SIZE(IC_RESULT(ic)) == 3 && 
-                AOP_SIZE(IC_LEFT(ic)) == 3   &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
-                aopPut(AOP(IC_RESULT(ic)),
-                aopGet(AOP(IC_LEFT(ic)),2,FALSE,FALSE),
-                2);
-        
-        if (AOP_SIZE(IC_RESULT(ic)) == 3 && 
-                AOP_SIZE(IC_RIGHT(ic)) == 3   &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
-                aopPut(AOP(IC_RESULT(ic)),
-                aopGet(AOP(IC_RIGHT(ic)),2,FALSE,FALSE),
-                2);
-        
-        if (AOP_SIZE(IC_RESULT(ic)) == 3 &&
-                AOP_SIZE(IC_LEFT(ic)) < 3    &&
-                AOP_SIZE(IC_RIGHT(ic)) < 3   &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) {
-                char buffer[5];
-                sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic)))));
-                aopPut(AOP(IC_RESULT(ic)),buffer,2);
-        }
-}
-//#else
-/* This is the pure and virtuous version of this code.
-* I'm pretty certain it's right, but not enough to toss the old 
-* code just yet...
-*/
-static void adjustArithmeticResult(iCode *ic)
-{
-        if (opIsGptr(IC_RESULT(ic)) &&
-                opIsGptr(IC_LEFT(ic))   &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))))
-        {
-                aopPut(AOP(IC_RESULT(ic)),
-                        aopGet(AOP(IC_LEFT(ic)), GPTRSIZE - 1,FALSE,FALSE),
-                        GPTRSIZE - 1);
-        }
-        
-        if (opIsGptr(IC_RESULT(ic)) &&
-                opIsGptr(IC_RIGHT(ic))   &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic))))
-        {
-                aopPut(AOP(IC_RESULT(ic)),
-                        aopGet(AOP(IC_RIGHT(ic)),GPTRSIZE - 1,FALSE,FALSE),
-                        GPTRSIZE - 1);
-        }
-        
-        if (opIsGptr(IC_RESULT(ic))      &&
-                AOP_SIZE(IC_LEFT(ic)) < GPTRSIZE   &&
-                AOP_SIZE(IC_RIGHT(ic)) < GPTRSIZE  &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_LEFT(ic))) &&
-                !pic14_sameRegs(AOP(IC_RESULT(ic)),AOP(IC_RIGHT(ic)))) {
-                char buffer[5];
-                sprintf(buffer,"#%d",pointerCode(getSpec(operandType(IC_LEFT(ic)))));
-                aopPut(AOP(IC_RESULT(ic)),buffer,GPTRSIZE - 1);
-        }
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genAddlit - generates code for addition                         */
 /*-----------------------------------------------------------------*/
@@ -477,12 +349,6 @@ static void genAddLit (iCode *ic, int lit)
                                                         emitpcode(POC_INCFSZ, popGet(AOP(result),0));
                                                         emitpcode(POC_DECF, popGet(AOP(result),MSB16));
                                                         break;
-                                                        /*  case 0xff: * 0xffff *
-                                                        emitpcode(POC_INCFSZW, popGet(AOP(result),0,FALSE,FALSE));
-                                                        emitpcode(POC_INCF, popGet(AOP(result),MSB16,FALSE,FALSE));
-                                                        emitpcode(POC_DECF, popGet(AOP(result),0,FALSE,FALSE));
-                                                        break;
-                                                        */
                                                 default:
                                                         emitpcode(POC_MOVLW,popGetLit(lo));
                                                         emitpcode(POC_ADDWF,popGet(AOP(result),0));
@@ -507,13 +373,7 @@ static void genAddLit (iCode *ic, int lit)
                                                                 emitpcode(POC_MOVLW,popGetLit(hi));
                                                                 emitpcode(POC_ADDWF,popGet(AOP(result),MSB16));
                                                                 break;
-                                                                /*  case 0xff: * 0xHHff *
-                                                                emitpcode(POC_MOVFW, popGet(AOP(result),0,FALSE,FALSE));
-                                                                emitpcode(POC_DECF, popGet(AOP(result),MSB16,FALSE,FALSE));
-                                                                emitpcode(POC_MOVLW,popGetLit(hi));
-                                                                emitpcode(POC_ADDWF,popGet(AOP(result),MSB16,FALSE,FALSE));
-                                                                break;
-                                                                */  default:  /* 0xHHLL */
+                                                        default:  /* 0xHHLL */
                                                                 emitpcode(POC_MOVLW,popGetLit(lo));
                                                                 emitpcode(POC_ADDWF, popGet(AOP(result),0));
                                                                 emitpcode(POC_MOVLW,popGetLit(hi));
@@ -595,30 +455,6 @@ static void genAddLit (iCode *ic, int lit)
                                 offset++;
                                 lit >>= 8;
                         }
-                        
-                        /*
-                                lo = BYTEofLONG(lit,0);
-                        
-                                if(lit < 0x100) {
-                                        if(lo) {
-                                                if(lo == 1) {
-                                                        emitpcode(POC_INCF, popGet(AOP(result),0,FALSE,FALSE));
-                                                        emitSKPNZ;
-                                                } else {
-                                                        emitpcode(POC_MOVLW,popGetLit(lo));
-                                                        emitpcode(POC_ADDWF, popGet(AOP(result),0,FALSE,FALSE));
-                                                        emitSKPNC;
-                                                }
-                                                emitpcode(POC_INCF, popGet(AOP(result),1,FALSE,FALSE));
-                                                emitSKPNZ;
-                                                emitpcode(POC_INCF, popGet(AOP(result),2,FALSE,FALSE));
-                                                emitSKPNZ;
-                                                emitpcode(POC_INCF, popGet(AOP(result),3,FALSE,FALSE));
-                                                
-                                        } 
-                                } 
-                                
-                        */
                 }
         } else {
                 int offset = 1;
@@ -631,23 +467,19 @@ static void genAddLit (iCode *ic, int lit)
                         case 0:
                                 emitpcode(POC_MOVFW, popGet(AOP(left),0));
                                 emitMOVWF(result, 0);
-                                //emitpcode(POC_MOVWF, popGet(AOP(result),0,FALSE,FALSE));
                                 emitMOVWF(result,0);
                                 break;
                         case 1:
                                 emitpcode(POC_INCFW, popGet(AOP(left),0));
-                                //emitpcode(POC_MOVWF, popGet(AOP(result),0,FALSE,FALSE));
                                 emitMOVWF(result,0);
                                 break;
                         case 0xff:
                                 emitpcode(POC_DECFW, popGet(AOP(left),0));
-                                //emitpcode(POC_MOVWF, popGet(AOP(result),0,FALSE,FALSE));
                                 emitMOVWF(result,0);
                                 break;
                         default:
                                 emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
                                 emitpcode(POC_ADDFW, popGet(AOP(left),0));
-                                //emitpcode(POC_MOVWF, popGet(AOP(result),0,FALSE,FALSE));
                                 emitMOVWF(result,0);
                         }
                         
@@ -663,7 +495,6 @@ static void genAddLit (iCode *ic, int lit)
                                 /* We don't know the state of the carry bit at this point */
                                 clear_carry = 1;
                         }
-                        //emitpcode(POC_MOVWF, popGet(AOP(result),0,FALSE,FALSE));
                         emitMOVWF(result,0);
                         while(--size) {
                                 
@@ -681,7 +512,6 @@ static void genAddLit (iCode *ic, int lit)
                                                 
                                         } else {
                                                 emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
-                                                //emitpcode(POC_MOVWF, popGet(AOP(result),offset,FALSE,FALSE));
                                                 emitMOVWF(result,offset);
                                                 emitpcode(POC_MOVFW, popGet(AOP(left),offset));
                                                 emitSKPNC;
@@ -764,11 +594,7 @@ void genPlus (iCode *ic)
         
         if(AOP(IC_RIGHT(ic))->type == AOP_LIT) {
                 /* Add a literal to something else */
-                //bool know_W=0;
                 unsigned lit = (unsigned) ulFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit);
-                //      unsigned l1=0;
-                
-                //      offset = 0;
                 DEBUGpic14_emitcode(";","adding lit to something. size %d",size);
                 
                 genAddLit (ic,  lit);
@@ -813,7 +639,6 @@ void genPlus (iCode *ic)
                                 emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),0));
                                 emitpcode(POC_BTFSC, popGet(AOP(IC_RIGHT(ic)),0));
                                 emitpcode(POC_INCFW, popGet(AOP(IC_LEFT(ic)),0));
-                                //emitpcode(POC_MOVWF, popGet(AOP(IC_RIGHT(ic)),0,FALSE,FALSE));
                                 emitMOVWF(IC_RIGHT(ic),0);
                         }
                         
index 3f4d6a8cb8905e62ca1b44e12b752dfc4ce3f479..7b92ab2e79c96869fbada40157e7c700f9418120 100644 (file)
@@ -68,35 +68,6 @@ static set *emitted = NULL;
 
 static void showAllMemmaps(FILE *of); // XXX: emits initialized symbols
 
-#if 0
-static int
-is_valid_identifier( const char *name )
-{
-  char a;
-  if (!name) return 0;
-  a = *name;
-
-  /* only accept [a-zA-Z_][a-zA-Z0-9_] */
-  if (!((a >= 'a' && a <= 'z')
-        || (a >= 'A' && a <= 'z')
-        || (a == '_')))
-    return 0;
-
-  name++;
-  while ((a = *name++))
-  {
-    if (!((a >= 'a' && a <= 'z')
-        || (a >= 'A' && a <= 'Z')
-        || (a >= '0' && a <= '9')
-        || (a == '_')))
-      return 0;
-  } // while
-
-  /* valid identifier */
-  return 1;
-}
-#endif
-
 static void
 emitPseudoStack(struct dbuf_s *oBuf, struct dbuf_s *oBufExt)
 {
@@ -261,661 +232,6 @@ pic14_constructAbsMap (struct dbuf_s *oBuf, struct dbuf_s *gloBuf)
   } // for i
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* emitRegularMap - emit code for maps with no special cases       */
-/*-----------------------------------------------------------------*/
-static void
-pic14emitRegularMap (memmap * map, bool addPublics, bool arFlag)
-{
-        symbol *sym;
-        int bitvars = 0;;
-
-        /* print the area name */
-        if (addPublics)
-                dbuf_printf (&map->oBuf, ";\t.area\t%s\n", map->sname);
-
-        for (sym = setFirstItem (map->syms); sym;
-        sym = setNextItem (map->syms)) {
-
-                //printf("%s\n",sym->name);
-
-                /* ignore if config word */
-                if (SPEC_ABSA(sym->etype)
-                    && IS_CONFIG_ADDRESS(SPEC_ADDR(sym->etype)))
-                        continue;
-
-                /* if extern then add it into the extern list */
-                if (IS_EXTERN (sym->etype)) {
-                        addSetHead (&externs, sym);
-                        continue;
-                }
-
-                /* if allocation required check is needed
-                then check if the symbol really requires
-                allocation only for local variables */
-                if (arFlag && !IS_AGGREGATE (sym->type) &&
-                        !(sym->_isparm && !IS_REGPARM (sym->etype)) &&
-                        !sym->allocreq && sym->level)
-                        continue;
-
-                /* if global variable & not static or extern
-                and addPublics allowed then add it to the public set */
-                if ((sym->level == 0 ||
-                        (sym->_isparm && !IS_REGPARM (sym->etype))) &&
-                        addPublics &&
-                        !IS_STATIC (sym->etype))
-                {
-                        //fprintf( stderr, "%s: made public %s\n", __FUNCTION__, sym->name );
-                        addSetHead (&publics, sym);
-                }
-
-                // PIC code allocates its own registers - so ignore parameter variable generated by processFuncArgs()
-                if (sym->_isparm)
-                        continue;
-                        /* if extern then do nothing or is a function
-                then do nothing */
-                if (IS_FUNC (sym->type))
-                        continue;
-#if 0
-                /* print extra debug info if required */
-                if (options.debug || sym->level == 0)
-                {
-                        if (!sym->level)        /* global */
-                                if (IS_STATIC (sym->etype))
-                                        dbuf_printf (&map->oBuf, "F%s_", moduleName);           /* scope is file */
-                                else
-                                        dbuf_printf (&map->oBuf, "G_"); /* scope is global */
-                                else
-                                        /* symbol is local */
-                                        dbuf_printf (&map->oBuf, "L%s_", (sym->localof ? sym->localof->name : "-null-"));
-                                dbuf_printf (&map->oBuf, "%s_%d_%d", sym->name, sym->level, sym->block);
-                }
-#endif
-                /* absolute symbols are handled in pic14_constructAbsMap */
-                if (SPEC_ABSA(sym->etype) && IS_DEFINED_HERE(sym))
-                        continue;
-
-                /* if it has an absolute address then generate
-                an equate for this no need to allocate space */
-                if (0 && SPEC_ABSA (sym->etype))
-                {
-                        //if (options.debug || sym->level == 0)
-                        //dbuf_printf (&map->oBuf,"; == 0x%04x\n",SPEC_ADDR (sym->etype));
-
-                        dbuf_printf (&map->oBuf, "%s\tEQU\t0x%04x\n",
-                                sym->rname,
-                                SPEC_ADDR (sym->etype));
-                }
-                else
-                {
-                        /* allocate space */
-
-                        /* If this is a bit variable, then allocate storage after 8 bits have been declared */
-                        /* unlike the 8051, the pic does not have a separate bit area. So we emulate bit ram */
-                        /* by grouping the bits together into groups of 8 and storing them in the normal ram. */
-                        if (IS_BITVAR (sym->etype))
-                        {
-                                bitvars++;
-                        }
-                        else
-                        {
-                            if (!sym->ival) {
-                                emitSymbol (&map->oBuf,
-                                        sym->rname,
-                                        NULL,
-                                        getSize (sym->type) & 0xffff,
-                                        SPEC_ABSA(sym->etype)
-                                                ? SPEC_ADDR(sym->etype)
-                                                : -1,
-                                        0,
-                                        0);
-                            }
-                                /*
-                                {
-                                int i, size;
-
-                                  if ((size = (unsigned int) getSize (sym->type) & 0xffff) > 1)
-                                  {
-                                  for (i = 1; i < size; i++)
-                                  dbuf_printf (&map->oBuf, "\t%s_%d\n", sym->rname, i);
-                                  }
-                                  }
-                                */
-                        }
-                        //dbuf_printf (&map->oBuf, "\t.ds\t0x%04x\n", (unsigned int)getSize (sym->type) & 0xffff);
-                }
-
-                /* if it has a initial value then do it only if
-                it is a global variable */
-                if (sym->ival) {
-                    /* mark symbol as already defined */
-                    pic14_stringInSet(sym->name, &emitted, 1);
-                    pic14_stringInSet(sym->rname, &emitted, 1);
-                }
-#if 0
-                /* if it has a initial value then do it only if
-                it is a global variable */
-                if (sym->ival && sym->level == 0) {
-                        ast *ival = NULL;
-
-                        if (IS_AGGREGATE (sym->type))
-                                ival = initAggregates (sym, sym->ival, NULL);
-                        else
-                                ival = newNode ('=', newAst_VALUE(symbolVal (sym)),
-                                decorateType (resolveSymbols (list2expr (sym->ival)), RESULT_TYPE_NONE));
-                        codeOutBuf = &statsg->oBuf;
-                        GcurMemmap = statsg;
-                        eBBlockFromiCode (iCodeFromAst (ival));
-                        sym->ival = NULL;
-                }
-#endif
-        }
-}
-#endif
-
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* printIvalType - generates ival for int/char                     */
-/*-----------------------------------------------------------------*/
-static void
-printIvalType (symbol *sym, sym_link * type, initList * ilist, pBlock *pb)
-{
-        value *val;
-        unsigned long ulval;
-
-        //fprintf(stderr, "%s\n",__FUNCTION__);
-
-        /* if initList is deep */
-        if (ilist->type == INIT_DEEP)
-                ilist = ilist->init.deep;
-
-        if (!IS_AGGREGATE(sym->type) && getNelements(type, ilist)>1) {
-                werror (W_EXCESS_INITIALIZERS, "scalar", sym->name, sym->lineDef);
-        }
-
-        if (!(val = list2val (ilist))) {
-                // assuming a warning has been thrown
-                val = constCharVal (0);
-        }
-
-        if (val->type != type) {
-                val = valCastLiteral(type, floatFromVal(val));
-        }
-
-        if(val)
-                ulval = ulFromVal (val);
-        else
-                ulval =0;
-
-        switch (getSize (type)) {
-        case 1:
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
-                break;
-
-        case 2:
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,1))));
-                break;
-
-        case 4:
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,0))));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,1))));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,2))));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(BYTE_IN_LONG(ulval,3))));
-                break;
-        }
-}
-
-/*-----------------------------------------------------------------*/
-/* printIvalBitFields - generate initializer for bitfields         */
-/*-----------------------------------------------------------------*/
-static void printIvalBitFields(symbol **sym, initList **ilist, pBlock *pb )
-{
-        value *val ;
-        symbol *lsym = *sym;
-        initList *lilist = *ilist ;
-        unsigned long ival = 0;
-        int size =0;
-
-
-        do {
-                unsigned long i;
-                val = list2val(lilist);
-                if (size) {
-                        if (SPEC_BLEN(lsym->etype) > 8) {
-                                size += ((SPEC_BLEN (lsym->etype) / 8) +
-                                        (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
-                        }
-                } else {
-                        size = ((SPEC_BLEN (lsym->etype) / 8) +
-                                (SPEC_BLEN (lsym->etype) % 8 ? 1 : 0));
-                }
-                i = ulFromVal (val);
-                i <<= SPEC_BSTR (lsym->etype);
-                ival |= i;
-                if (! ( lsym->next &&
-                        (IS_BITFIELD(lsym->next->type)) &&
-                        (SPEC_BSTR(lsym->next->etype)))) break;
-                lsym = lsym->next;
-                lilist = lilist->next;
-        } while (1);
-        switch (size) {
-        case 1:
-                //tfprintf (oFile, "\t!db !constbyte\n",ival);
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival)));
-                break;
-
-        case 2:
-                //tfprintf (oFile, "\t!dw !constword\n",ival);
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival>>8)));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival)));
-                break;
-        case 4:
-                //tfprintf (oFile, "\t!db  !constword,!constword\n",(ival >> 8) & 0xffff, (ival & 0xffff));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival>>24)));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival>>16)));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival>>8)));
-                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(ival)));
-                break;
-        }
-        *sym = lsym;
-        *ilist = lilist;
-}
-
-/*-----------------------------------------------------------------*/
-/* printIvalStruct - generates initial value for structures        */
-/*-----------------------------------------------------------------*/
-static void printIvalStruct (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
-{
-        symbol *sflds;
-        initList *iloop = NULL;
-
-        sflds = SPEC_STRUCT (type)->fields;
-
-        if (ilist) {
-                if (ilist->type != INIT_DEEP) {
-                        werrorfl (sym->fileDef, sym->lineDef, E_INIT_STRUCT, sym->name);
-                        return;
-                }
-
-                iloop = ilist->init.deep;
-        }
-
-        for (; sflds; sflds = sflds->next, iloop = (iloop ? iloop->next : NULL)) {
-                if (IS_BITFIELD(sflds->type)) {
-                        printIvalBitFields(&sflds,&iloop,pb);
-                } else {
-                        printIval (sym, sflds->type, iloop, pb);
-                }
-        }
-        if (iloop) {
-                werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "struct", sym->name);
-        }
-        return;
-}
-
-/*-----------------------------------------------------------------*/
-/* printIvalChar - generates initital value for character array    */
-/*-----------------------------------------------------------------*/
-static int
-printIvalChar (sym_link * type, initList * ilist, pBlock *pb, char *s)
-{
-        value *val;
-        int remain, ilen;
-
-        if(!pb)
-                return 0;
-
-        //fprintf(stderr, "%s\n",__FUNCTION__);
-        if (!s)
-        {
-
-                val = list2val (ilist);
-
-                /* if the value is a character string  */
-                if (IS_ARRAY (val->type) && IS_CHAR (val->etype))
-                {
-                        ilen = DCL_ELEM(val->type);
-
-                        if (!DCL_ELEM (type))
-                                DCL_ELEM (type) = ilen;
-
-                        /* emit string constant */
-                        for (remain = 0; remain < ilen; remain++) {
-                                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(SPEC_CVAL(val->etype).v_char[remain])));
-                        }
-
-                        /* fill array up to desired size */
-                        if ((remain = (DCL_ELEM (type) - ilen)) > 0)
-                                while (remain--)
-                                        //tfprintf (oFile, "\t!db !constbyte\n", 0);
-                                        addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(0)));
-                                return 1;
-                }
-                else
-                        return 0;
-        }
-        else {
-                //printChar (oFile, s, strlen (s) + 1);
-
-                for(remain=0; remain<(int)strlen(s); remain++) {
-                        addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(s[remain])));
-                        //fprintf(stderr,"0x%02x ",s[remain]);
-                }
-                //fprintf(stderr,"\n");
-        }
-        return 1;
-}
-
-/*-----------------------------------------------------------------*/
-/* printIvalArray - generates code for array initialization        */
-/*-----------------------------------------------------------------*/
-static void
-printIvalArray (symbol * sym, sym_link * type, initList * ilist,
-                                pBlock *pb)
-{
-        initList *iloop;
-        unsigned size = 0;
-
-        if(!pb)
-                return;
-        if (ilist) {
-                /* take care of the special   case  */
-                /* array of characters can be init  */
-                /* by a string                      */
-                if (IS_CHAR (type->next)) {
-                        //fprintf(stderr,"%s:%d - is_char\n",__FUNCTION__,__LINE__);
-                        if (!IS_LITERAL(list2val(ilist)->etype)) {
-                                werror (W_INIT_WRONG);
-                                return;
-                        }
-                        if (printIvalChar (type,
-                                (ilist->type == INIT_DEEP ? ilist->init.deep : ilist),
-                                pb, SPEC_CVAL (sym->etype).v_char))
-                                return;
-                }
-                /* not the special case */
-                if (ilist->type != INIT_DEEP) {
-                        werrorfl (ilist->filename, ilist->lineno, E_INIT_STRUCT, sym->name);
-                        return;
-                }
-
-                for (iloop=ilist->init.deep; iloop; iloop=iloop->next) {
-                        if ((++size > DCL_ELEM(type)) && DCL_ELEM(type)) {
-                                werrorfl (sym->fileDef, sym->lineDef, W_EXCESS_INITIALIZERS, "array", sym->name);
-                                break;
-                        }
-                        printIval (sym, type->next, iloop, pb);
-                }
-        }
-
-        if (DCL_ELEM(type)) {
-                // pad with zeros if needed
-                if (size<DCL_ELEM(type)) {
-                        size = (DCL_ELEM(type) - size) * getSize(type->next);
-                        while (size--) {
-                                //tfprintf (oFile, "\t!db !constbyte\n", 0);
-                                addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(0)));
-                        }
-                }
-        } else {
-                // we have not been given a size, but we now know it
-                DCL_ELEM (type) = size;
-        }
-
-        return;
-}
-
-/*-----------------------------------------------------------------*/
-/* printIvalPtr - generates code for initial value of pointers     */
-/*-----------------------------------------------------------------*/
-static void
-printIvalPtr (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
-{
-        value *val;
-
-        if (!ilist || !pb)
-                return;
-
-        fprintf (stderr, "FIXME: initializers for pointers...\n");
-        printTypeChain (type, stderr);
-
-        fprintf (stderr, "symbol: %s, DCL_TYPE():%d, DCL_ELEM():%d, IS_ARRAY():%d", sym->rname, DCL_TYPE(type), DCL_ELEM(type), IS_ARRAY(type));
-        fprintf (stderr, "ilist: type=%d (INIT_DEEP=%d, INIT_NODE=%d)\n", ilist->type, INIT_DEEP, INIT_NODE);
-
-        if (ilist && (ilist->type == INIT_DEEP))
-          ilist = ilist->init.deep;
-
-        /* function pointers */
-        if (IS_FUNC (type->next))
-        {
-                assert ( !"function pointers not yet handled" );
-                //printIvalFuncPtr (type, ilist, pb);
-        }
-
-        if (!(val = initPointer (ilist, type)))
-                return;
-
-        if (IS_CHAR (type->next))
-        {
-                if (printIvalChar (type, ilist, pb, NULL)) return;
-        }
-
-        /* check the type */
-        if (compareType (type, val->type) == 0)
-        {
-                werrorfl (ilist->filename, ilist->lineno, W_INIT_WRONG);
-                printFromToType (val->type, type);
-        }
-
-        if (IS_LITERAL (val->etype))
-        {
-                switch (getSize (type))
-                {
-                case 1:
-                        fprintf (stderr, "BYTE: %i\n", (unsigned char) ulFromVal (val) & 0x00FF);
-                        break;
-                case 2:
-                        fprintf (stderr, "WORD: %i\n", (unsigned int) ulFromVal (val) & 0x00FFFF);
-                        break;
-                case 3: /* gneric pointers */
-                        assert ( !"generic pointers not yet handled" );
-                case 4:
-                        fprintf (stderr, "LONG: %i\n", (unsigned int) ulFromVal (val) & 0x0000FFFFFFFF);
-                        break;
-                default:
-                        assert ( !"invaild size of value -- aborting" );
-                } // switch
-
-                return;
-        } // if (IS_LITERAL)
-
-        /* now handle symbolic values */
-        switch (getSize (type))
-        {
-        case 1:
-                fprintf (stderr, "BYTE: %s", val->name);
-                break;
-        case 2:
-                fprintf (stderr, "WORD: %s", val->name);
-                break;
-        case 4:
-                fprintf (stderr, "LONG: %s", val->name);
-                break;
-        default:
-                assert ( !"invalid size of (symbolic) value -- aborting" );
-        } // switch
-}
-
-/*-----------------------------------------------------------------*/
-/* printIval - generates code for initial value                    */
-/*-----------------------------------------------------------------*/
-static void
-printIval (symbol * sym, sym_link * type, initList * ilist, pBlock *pb)
-{
-        if (!ilist || !pb)
-                return;
-
-        /* if structure then    */
-        if (IS_STRUCT (type))
-        {
-                //fprintf(stderr,"%s struct: %s\n",__FUNCTION__, sym->rname);
-                printIvalStruct (sym, type, ilist, pb);
-                return;
-        }
-
-        /* if this is an array   */
-        if (IS_ARRAY (type))
-        {
-                //fprintf(stderr,"%s array: %s\n",__FUNCTION__, sym->rname);
-                printIvalArray (sym, type, ilist, pb);
-                return;
-        }
-
-        /* if this is a pointer */
-        if (IS_PTR (type))
-        {
-                //fprintf(stderr,"%s pointer: %s\n",__FUNCTION__, sym->rname);
-                printIvalPtr (sym, type, ilist, pb);
-                return;
-        }
-
-        /* if type is SPECIFIER */
-        if (IS_SPEC (type))
-        {
-                //fprintf(stderr,"%s spec %s\n",__FUNCTION__, sym->rname);
-                printIvalType (sym, type, ilist, pb);
-                return;
-        }
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* emitStaticSeg - emitcode for the static segment                 */
-/*-----------------------------------------------------------------*/
-static void
-pic14emitStaticSeg (memmap * map)
-{
-        symbol *sym;
-
-        dbuf_printf (&map->oBuf, ";\t.area\t%s\n", map->sname);
-
-        //fprintf(stderr, "%s\n",__FUNCTION__);
-
-        /* for all variables in this segment do */
-        for (sym = setFirstItem (map->syms); sym;
-        sym = setNextItem (map->syms))
-        {
-                /* if extern then add it into the extern list */
-                if (IS_EXTERN (sym->etype)) {
-                        addSetHead (&externs, sym);
-                        continue;
-                }
-
-                /* if it is not static add it to the public
-                table */
-                if (!IS_STATIC (sym->etype))
-                        addSetHead (&publics, sym);
-
-                /* print extra debug info if required */
-                if (options.debug || sym->level == 0)
-                {
-                        if (!sym->level)
-                        {                       /* global */
-                                if (IS_STATIC (sym->etype))
-                                        dbuf_printf (&code->oBuf, "F%s_", moduleName);  /* scope is file */
-                                else
-                                        dbuf_printf (&code->oBuf, "G_");        /* scope is global */
-                        }
-                        else
-                                /* symbol is local */
-                                dbuf_printf (&code->oBuf, "L%s_",
-                                (sym->localof ? sym->localof->name : "-null-"));
-                        dbuf_printf (&code->oBuf, "%s_%d_%d", sym->name, sym->level, sym->block);
-
-                }
-
-                /* if it has an absolute address */
-                if (SPEC_ABSA (sym->etype))
-                {
-                        if (options.debug || sym->level == 0)
-                                dbuf_printf (&code->oBuf, " == 0x%04x\n", SPEC_ADDR (sym->etype));
-
-                        dbuf_printf (&code->oBuf, "%s\t=\t0x%04x\n",
-                                sym->rname,
-                                SPEC_ADDR (sym->etype));
-                }
-                else
-                {
-                        if (options.debug || sym->level == 0)
-                                dbuf_printf (&code->oBuf, " == .\n");
-
-                        /* if it has an initial value */
-                        if (sym->ival)
-                        {
-#if 0
-                                pBlock *pb;
-
-                                dbuf_printf (&code->oBuf, "%s:\n", sym->rname);
-                                noAlloc++;
-                                resolveIvalSym (sym->ival, sym->type);
-                                //printIval (sym, sym->type, sym->ival, &code->oBuf);
-                                pb = newpCodeChain(NULL, 'P',newpCodeCharP("; Starting pCode block for Ival"));
-                                addpBlock(pb);
-                                addpCode2pBlock(pb,newpCodeLabel(sym->rname,-1));
-
-                                printIval (sym, sym->type, sym->ival, pb);
-                                noAlloc--;
-#endif
-                        }
-                        else
-                        {
-
-                                /* allocate space */
-                                dbuf_printf (&code->oBuf, "%s:\n", sym->rname);
-                                /* special case for character strings */
-                                if (IS_ARRAY (sym->type) && IS_CHAR (sym->type->next) &&
-                                        SPEC_CVAL (sym->etype).v_char)
-                                        pCodeConstString(sym->rname , SPEC_CVAL (sym->etype).v_char);
-                                        /*printChar (code->oFile,
-                                        SPEC_CVAL (sym->etype).v_char,
-                                strlen (SPEC_CVAL (sym->etype).v_char) + 1);*/
-                                else
-                                        dbuf_printf (&code->oBuf, "\t.ds\t0x%04x\n", (unsigned int) getSize (sym->type) & 0xffff);
-                        }
-                }
-        }
-
-}
-#endif
-
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* emitMaps - emits the code for the data portion the code         */
-/*-----------------------------------------------------------------*/
-static void
-pic14emitMaps ()
-{
-        pic14_constructAbsMap (&sfr->oBuf);
-        emitPseudoStack(&sfr->oBuf, &sfr->oBuf);
-/* no special considerations for the following
-        data, idata & bit & xdata */
-        pic14emitRegularMap (data, TRUE, TRUE);
-        pic14emitRegularMap (idata, TRUE, TRUE);
-        pic14emitRegularMap (bit, TRUE, FALSE);
-        pic14emitRegularMap (xdata, TRUE, TRUE);
-        pic14emitRegularMap (sfr, TRUE, FALSE);
-        pic14emitRegularMap (sfrbit, FALSE, FALSE);
-        pic14emitRegularMap (code, TRUE, FALSE);
-        pic14emitStaticSeg (statsg);
-        pic14emitStaticSeg (c_abs);
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* createInterruptVect - creates the interrupt vector              */
 /*-----------------------------------------------------------------*/
@@ -987,113 +303,6 @@ pic14_stringInSet(const char *str, set **world, int autoAdd)
   return 0;
 }
 
-#if 0
-static int
-pic14_emitSymbolIfNew(FILE *file, const char *fmt, const char *sym, int checkLocals)
-{
-  if (!pic14_stringInSet(sym, &emitted, 1)) {
-    /* sym was not in emittedSymbols */
-    if (!checkLocals || !pic14_stringInSet(sym, &pic14_localFunctions, 0)) {
-      /* sym is not a locally defined function---avoid bug #1443651 */
-      fprintf( file, fmt, sym );
-      return 0;
-    }
-  }
-  return 1;
-}
-#endif
-
-#if 0
-/*-------------------------------------------------------------------*/
-/* emitSymbol - write a symbol definition only if it is not    */
-/*                    already present                                */
-/*-------------------------------------------------------------------*/
-static void
-emitSymbol (struct dbuf_s *oBuf, const char *name, const char *section_type, int size, int addr, int useEQU, int globalize)
-{
-    static unsigned int sec_idx = 0;
-
-    /* workaround: variables declared via `sbit' result in a numeric
-     * identifier (0xHH), EQU'ing them is invalid, so just ignore it.
-     * sbit is heavily used in the inc2h-generated header files!
-     */
-    if (!is_valid_identifier(name))
-    {
-        //fprintf( stderr, "%s:%s:%u: ignored symbol: %s\n", __FILE__, __FUNCTION__, __LINE__, name );
-        return;
-    }
-
-    /* check whether the symbol is already defined */
-    if (pic14_stringInSet(name, &emitted, 1)) return;
-
-    /* new symbol -- define it */
-    //fprintf (stderr, "%s: emitting %s (%d)\n", __FUNCTION__, name, size);
-    if (useEQU) {
-        dbuf_printf (oBuf, "%s\tEQU\t0x%04x\n", name, addr);
-    } else {
-        /* we place each symbol into a section of its own to allow the linker
-         * to distribute the data into all available memory banks */
-        if (!section_type) section_type = "udata";
-        if (addr != -1)
-        {
-            /* absolute symbols are handled in pic14_constructAbsMap */
-            /* do nothing */
-        } else {
-            if (globalize) dbuf_printf (oBuf, "\tglobal\t%s\n", name);
-            dbuf_printf (oBuf, "udata_%s_%u\t%s\n", moduleName,
-                    sec_idx++, section_type);
-            dbuf_printf (oBuf, "%s\tres\t%d\n", name, size);
-        }
-    }
-}
-#endif
-
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* printExterns - generates extern for external variables          */
-/*-----------------------------------------------------------------*/
-static void
-pic14printExterns (FILE * afile)
-{
-        symbol *sym;
-
-        fprintf (afile, "%s", iComments2);
-        fprintf (afile, "; extern variables in this module\n");
-        fprintf (afile, "%s", iComments2);
-
-        for (sym = setFirstItem (externs); sym; sym = setNextItem (externs))
-                pic14_emitSymbolIfNew(afile, "\textern %s\n", sym->rname, 1);
-}
-
-/*-----------------------------------------------------------------*/
-/* printPublics - generates .global for publics                    */
-/*-----------------------------------------------------------------*/
-static void
-pic14printPublics (FILE * afile)
-{
-  symbol *sym;
-
-  fprintf (afile, "%s", iComments2);
-  fprintf (afile, "; public variables in this module\n");
-  fprintf (afile, "%s", iComments2);
-
-  for (sym = setFirstItem (publics); sym;
-      sym = setNextItem (publics)) {
-
-    if(!IS_BITFIELD(sym->type) && ((IS_FUNC(sym->type) || sym->allocreq))) {
-      if (!IS_BITVAR(sym->type))
-        pic14_emitSymbolIfNew(afile, "\tglobal %s\n", sym->rname, 0);
-    } else {
-      /* Absolute variables are defines in the asm file as equates and thus can not be made global. */
-      /* Not any longer! */
-      //if (!SPEC_ABSA (sym->etype))
-      pic14_emitSymbolIfNew(afile, "\tglobal %s\n", sym->rname, 0);
-    }
-  }
-}
-#endif
-
 static void
 pic14printLocals (struct dbuf_s *oBuf)
 {
@@ -1294,31 +503,6 @@ picglue ()
                 pic14_options.isLibrarySource = 1;
         }
 
-#if 0
-        if (mainf && IFFUNC_HASBODY(mainf->type)) {
-
-                pBlock *pb = newpCodeChain(NULL,'X',newpCodeCharP("; Starting pCode block"));
-                addpBlock(pb);
-
-                /* entry point @ start of CSEG */
-                addpCode2pBlock(pb,newpCodeLabel("__sdcc_program_startup",-1));
-                /* put in the call to main */
-                addpCode2pBlock(pb,newpCode(POC_CALL,newpCodeOp("_main",PO_STR)));
-
-                if (options.mainreturn) {
-
-                        addpCode2pBlock(pb,newpCodeCharP(";\treturn from main will return to caller\n"));
-                        addpCode2pBlock(pb,newpCode(POC_RETURN,NULL));
-
-                } else {
-
-                        addpCode2pBlock(pb,newpCodeCharP(";\treturn from main will lock up\n"));
-                        addpCode2pBlock(pb,newpCode(POC_GOTO,newpCodeOp("$",PO_STR)));
-
-                }
-        }
-#endif
-
         /* At this point we've got all the code in the form of pCode structures */
         /* Now it needs to be rearranged into the order it should be placed in the */
         /* code space */
@@ -1333,8 +517,6 @@ picglue ()
         if (options.debug)
                 cdbStructBlock (0);
 
-        /* emit code for the all the variables declared */
-        //pic14emitMaps ();
         /* do the overlay segments */
         pic14emitOverlay(&ovrBuf);
 
@@ -1389,32 +571,6 @@ picglue ()
                 port->genAssemblerPreamble(asmFile);
         }
 
-        /* print the global variables in this module */
-        //pic14printPublics (asmFile);
-
-        /* print the extern variables in this module */
-        //pic14printExterns (asmFile);
-
-        /* copy the sfr segment */
-#if 0
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "; special function registers\n");
-        fprintf (asmFile, "%s", iComments2);
-        dbuf_write_and_destroy (&sfr->oBuf, asmFile);
-
-
-        if (udata_section_name) {
-                sprintf(udata_name,"%s",udata_section_name);
-        } else {
-                sprintf(udata_name,"data_%s",moduleName);
-        }
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "; udata\n");
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "%s\tudata\n", udata_name);
-        dbuf_write_and_destroy(&data->oBuf, asmFile);
-#endif
-
         /* Put all variables into a cblock */
         AnalyzeBanking();
 
@@ -1430,48 +586,6 @@ picglue ()
         fprintf (asmFile, "%s", iComments2);
         dbuf_write_and_destroy (&ovrBuf, asmFile);
 
-#if 0
-
-        /* create the stack segment MOF */
-        if (mainf && IFFUNC_HASBODY(mainf->type)) {
-                fprintf (asmFile, "%s", iComments2);
-                fprintf (asmFile, "; Stack segment in internal ram \n");
-                fprintf (asmFile, "%s", iComments2);
-                fprintf (asmFile, ";\t.area\tSSEG\t(DATA)\n"
-                        ";__start__stack:\n;\t.ds\t1\n\n");
-        }
-
-        /* create the idata segment */
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "; indirectly addressable internal ram data\n");
-        fprintf (asmFile, "%s", iComments2);
-        dbuf_write_and_destroy (&idata->oBuf, asmFile);
-
-        /* if external stack then reserve space of it */
-        if (mainf && IFFUNC_HASBODY(mainf->type) && options.useXstack ) {
-                fprintf (asmFile, "%s", iComments2);
-                fprintf (asmFile, "; external stack \n");
-                fprintf (asmFile, "%s", iComments2);
-                fprintf (asmFile,";\t.area XSEG (XDATA)\n"); /* MOF */
-                fprintf (asmFile,";\t.ds 256\n");
-        }
-
-        /* copy xtern ram data */
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "; external ram data\n");
-        fprintf (asmFile, "%s", iComments2);
-        dbuf_write_and_destroy (&xdata->oBuf, asmFile);
-
-#endif
-
-        /* copy the bit segment */
-#if 0
-        fprintf (asmFile, "%s", iComments2);
-        fprintf (asmFile, "; bit data\n");
-        fprintf (asmFile, "%s", iComments2);
-        dbuf_write_and_destroy (&bit->oBuf, asmFile);
-#endif
-
         /* copy the interrupt vector table */
         if (mainf && IFFUNC_HASBODY(mainf->type))
           dbuf_write_and_destroy (&vBuf, asmFile);
@@ -1519,56 +633,6 @@ picglue ()
 #define DEBUGprintf 1 ? (void)0 : (void)printf
 #endif
 
-
-#if 0
-/*
- * Emit all memmaps.
- */
-static void
-showInitList(initList *list, int level)
-{
-    static const char *list_type[] = { "INIT_NODE", "INIT_DEEP", "INIT_HOLE" };
-    static const char *ast_type[] = { "EX_OP", "EX_VALUE", "EX_LINK", "EX_OPERAND" };
-    struct ast *ast;
-    while (list) {
-        printf ("      %d: type %u (%s), init %p, next %p\n", level, list->type, list_type[list->type], list->init.node, list->next);
-        if (list->type == INIT_DEEP) {
-            showInitList(list->init.deep, level + 1);
-        } else if (list->type == INIT_NODE) {
-            ast = list->init.node;
-            printf ("        type %u (%s), level %d, block %d, seqPoint %d\n",
-                    ast->type, ast_type[ast->type], ast->level, ast->block, ast->seqPoint);
-            if (ast->type == EX_VALUE) {
-                printf ("          VAL %lf\n", floatFromVal(ast->opval.val));
-            } else if (ast->type == EX_LINK) {
-                printTypeChain(ast->opval.lnk, NULL);
-            } else if (ast->type == EX_OP) {
-                printf ("          OP %u\n", ast->opval.op);
-            }
-        } // if
-        list = list->next;
-    } // while
-}
-#endif
-
-#if 0
-/*
- * DEBUG: Print a value.
- */
-static void
-printValue(value *val)
-{
-    printf ("value %p: name %s, type %p, etype %p, sym %s, vArgs %d, lit 0x%lx/%ld\n",
-            val, val->name, val->type, val->etype,
-            val->sym ? val->sym->name : NULL, val->vArgs,
-            (long) ulFromVal (val), (long) ulFromVal (val));
-    printTypeChain(val->type, stdout);
-    printf ("\n");
-    printTypeChain(val->etype, stdout);
-    printf ("\n");
-}
-#endif
-
 static char *
 parseIvalAst (ast *node, int *inCodeSpace) {
 #define LEN 4096
@@ -1720,7 +784,6 @@ emitIvals(struct dbuf_s *oBuf, symbol *sym, initList *list, long lit, int size)
     if (constExprTree(node) && (val = constExprValue(node, 0))) {
         op = operandFromValue(val);
         DEBUGprintf ("%s: constExpr ", __FUNCTION__);
-        //printValue(val);
     } else if (IS_AST_VALUE(node)) {
         op = operandFromAst(node, 0);
     } else if (IS_AST_OP(node)) {
@@ -2110,3 +1173,4 @@ showAllMemmaps(FILE *of)
 
     extBuf = gloBuf = gloDefBuf = ivalBuf = NULL;
 }
+
index b06c144c845d45d66b35ad1f639d4398bb238d74..8707cc99921c3e0b91d9b59222c59cb6bbab304a 100644 (file)
@@ -5,7 +5,6 @@
     it easier to set a breakpoint using the debugger.
 */
 #include "common.h"
-#include "dbuf_string.h"
 #include "MySystem.h"
 #include "SDCCmacro.h"
 
@@ -163,61 +162,6 @@ _pic14_finaliseOptions (void)
   
   port->mem.default_local_map = data;
   port->mem.default_globl_map = data;
-#if 0
-  /* Hack-o-matic: if we are using the flat24 model,
-  * adjust pointer sizes.
-  */
-  if (options.model == MODEL_FLAT24)
-  {
-    
-    fprintf (stderr, "*** WARNING: you should use the '-mds390' option "
-      "for DS80C390 support. This code generator is "
-      "badly out of date and probably broken.\n");
-    
-    port->s.fptr_size = 3;
-    port->s.gptr_size = 4;
-    port->stack.isr_overhead++; /* Will save dpx on ISR entry. */
-#if 1
-    port->stack.call_overhead++;  /* This acounts for the extra byte 
-                                     * of return addres on the stack.
-                                     * but is ugly. There must be a 
-                                     * better way.
-                                     */
-#endif
-    fReturn = fReturn390;
-    fReturnSize = 5;
-  }
-  
-  if (options.model == MODEL_LARGE)
-  {
-    port->mem.default_local_map = xdata;
-    port->mem.default_globl_map = xdata;
-  }
-  else
-  {
-    port->mem.default_local_map = data;
-    port->mem.default_globl_map = data;
-  }
-  
-  if (options.stack10bit)
-  {
-    if (options.model != MODEL_FLAT24)
-    {
-      fprintf (stderr,
-        "*** warning: 10 bit stack mode is only supported in flat24 model.\n");
-      fprintf (stderr, "\t10 bit stack mode disabled.\n");
-      options.stack10bit = 0;
-    }
-    else
-    {
-    /* Fixup the memory map for the stack; it is now in
-    * far space and requires a FPOINTER to access it.
-    */
-      istack->fmap = 1;
-      istack->ptrType = FPOINTER;
-    }
-  }
-#endif
 }
 
 static void
@@ -253,42 +197,13 @@ _pic14_genAssemblerPreamble (FILE * of)
 static int
 _pic14_genIVT (struct dbuf_s * oBuf, symbol ** interrupts, int maxInterrupts)
 {
-  int i;
-  
-  if (options.model != MODEL_FLAT24)
-  {
-    /* Let the default code handle it. */
-    return FALSE;
-  }
-  
-  dbuf_printf (oBuf, "\t;ajmp\t__sdcc_gsinit_startup\n");
-  
-  /* now for the other interrupts */
-  for (i = 0; i < maxInterrupts; i++)
-  {
-    if (interrupts[i])
-    {
-      dbuf_printf (oBuf, "\t;ljmp\t%s\n\t.ds\t4\n", interrupts[i]->rname);
-    }
-    else
-    {
-      dbuf_printf (oBuf, "\t;reti\n\t.ds\t7\n");
-    }
-  }
-  
-  return TRUE;
+  /* Let the default code handle it. */
+  return FALSE;
 }
 
 static bool
 _hasNativeMulFor (iCode *ic, sym_link *left, sym_link *right)
 {
-/*
-sym_link *test = NULL;
-value *val;
-  */
-  
-  //fprintf(stderr,"checking for native mult\n");
-  
   if ( ic->op != '*')
   {
     return FALSE;
@@ -300,35 +215,6 @@ value *val;
   
   /* use library functions for more complex maths */
   return FALSE;
-
-  /*
-  if ( IS_LITERAL (left))
-  {
-  fprintf(stderr,"left is lit\n");
-  test = left;
-  val = OP_VALUE (IC_LEFT (ic));
-  }
-  else if ( IS_LITERAL (right))
-  {
-  fprintf(stderr,"right is lit\n");
-  test = left;
-  val = OP_VALUE (IC_RIGHT (ic));
-  }
-  else
-  {
-  fprintf(stderr,"oops, neither is lit so no\n");
-  return FALSE;
-  }
-  
-    if ( getSize (test) <= 2)
-    {
-    fprintf(stderr,"yep\n");
-    return TRUE;
-    }
-    fprintf(stderr,"nope\n");
-    
-    return FALSE;
-  */
 }
 
 /* Indicate which extended bit operations this port supports */
@@ -546,3 +432,4 @@ PORT pic_port =
   1,            /* globals & local static allowed */
   PORT_MAGIC
 };
+
index 1149e6dbca0e5615ca5d4a4571031d3c8fc8cafe..61e69e8569517c8b65180078e080fbe029b45c2f 100644 (file)
@@ -78,13 +78,6 @@ static unsigned peakIdx = 0; /* This keeps track of the peak register index for
 /*                      Forward declarations                    */
 /****************************************************************/
 
-#if 0
-static void genericAnalyze(pCode *pc);
-static void AnalyzeGOTO(pCode *pc);
-static void AnalyzeSKIP(pCode *pc);
-static void AnalyzeRETURN(pCode *pc);
-#endif
-
 static void genericDestruct(pCode *pc);
 static void genericPrint(FILE *of,pCode *pc);
 
@@ -103,7 +96,6 @@ static pBlock *newpBlock(void);
 
 static pCodeInstruction pciADDWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ADDWF,
@@ -125,7 +117,6 @@ static pCodeInstruction pciADDWF = {
 
 static pCodeInstruction pciADDFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ADDFW,
@@ -147,7 +138,6 @@ static pCodeInstruction pciADDFW = {
 
 static pCodeInstruction pciADDLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ADDLW,
@@ -169,7 +159,6 @@ static pCodeInstruction pciADDLW = {
 
 static pCodeInstruction pciANDLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ANDLW,
@@ -191,7 +180,6 @@ static pCodeInstruction pciANDLW = {
 
 static pCodeInstruction pciANDWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ANDWF,
@@ -213,7 +201,6 @@ static pCodeInstruction pciANDWF = {
 
 static pCodeInstruction pciANDFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_ANDFW,
@@ -235,7 +222,6 @@ static pCodeInstruction pciANDFW = {
 
 static pCodeInstruction pciBCF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_BCF,
@@ -257,7 +243,6 @@ static pCodeInstruction pciBCF = {
 
 static pCodeInstruction pciBSF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_BSF,
@@ -279,7 +264,6 @@ static pCodeInstruction pciBSF = {
 
 static pCodeInstruction pciBTFSC = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_BTFSC,
@@ -301,7 +285,6 @@ static pCodeInstruction pciBTFSC = {
 
 static pCodeInstruction pciBTFSS = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_BTFSS,
@@ -323,7 +306,6 @@ static pCodeInstruction pciBTFSS = {
 
 static pCodeInstruction pciCALL = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_CALL,
@@ -345,7 +327,6 @@ static pCodeInstruction pciCALL = {
 
 static pCodeInstruction pciCOMF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_COMF,
@@ -367,7 +348,6 @@ static pCodeInstruction pciCOMF = {
 
 static pCodeInstruction pciCOMFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_COMFW,
@@ -389,7 +369,6 @@ static pCodeInstruction pciCOMFW = {
 
 static pCodeInstruction pciCLRF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_CLRF,
@@ -411,7 +390,6 @@ static pCodeInstruction pciCLRF = {
 
 static pCodeInstruction pciCLRW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_CLRW,
@@ -433,7 +411,6 @@ static pCodeInstruction pciCLRW = {
 
 static pCodeInstruction pciCLRWDT = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_CLRWDT,
@@ -455,7 +432,6 @@ static pCodeInstruction pciCLRWDT = {
 
 static pCodeInstruction pciDECF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_DECF,
@@ -477,7 +453,6 @@ static pCodeInstruction pciDECF = {
 
 static pCodeInstruction pciDECFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_DECFW,
@@ -499,7 +474,6 @@ static pCodeInstruction pciDECFW = {
 
 static pCodeInstruction pciDECFSZ = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_DECFSZ,
@@ -521,7 +495,6 @@ static pCodeInstruction pciDECFSZ = {
 
 static pCodeInstruction pciDECFSZW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_DECFSZW,
@@ -543,7 +516,6 @@ static pCodeInstruction pciDECFSZW = {
 
 static pCodeInstruction pciGOTO = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeGOTO,
                genericDestruct,
                genericPrint},
                POC_GOTO,
@@ -565,7 +537,6 @@ static pCodeInstruction pciGOTO = {
 
 static pCodeInstruction pciINCF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_INCF,
@@ -587,7 +558,6 @@ static pCodeInstruction pciINCF = {
 
 static pCodeInstruction pciINCFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_INCFW,
@@ -609,7 +579,6 @@ static pCodeInstruction pciINCFW = {
 
 static pCodeInstruction pciINCFSZ = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_INCFSZ,
@@ -631,7 +600,6 @@ static pCodeInstruction pciINCFSZ = {
 
 static pCodeInstruction pciINCFSZW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeSKIP,
                genericDestruct,
                genericPrint},
                POC_INCFSZW,
@@ -653,7 +621,6 @@ static pCodeInstruction pciINCFSZW = {
 
 static pCodeInstruction pciIORWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_IORWF,
@@ -675,7 +642,6 @@ static pCodeInstruction pciIORWF = {
 
 static pCodeInstruction pciIORFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_IORFW,
@@ -697,7 +663,6 @@ static pCodeInstruction pciIORFW = {
 
 static pCodeInstruction pciIORLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_IORLW,
@@ -719,7 +684,6 @@ static pCodeInstruction pciIORLW = {
 
 static pCodeInstruction pciMOVF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_MOVF,
@@ -741,7 +705,6 @@ static pCodeInstruction pciMOVF = {
 
 static pCodeInstruction pciMOVFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_MOVFW,
@@ -763,7 +726,6 @@ static pCodeInstruction pciMOVFW = {
 
 static pCodeInstruction pciMOVWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_MOVWF,
@@ -827,7 +789,6 @@ static pCodeInstruction pciNOP = {
 
 static pCodeInstruction pciRETFIE = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeRETURN,
                genericDestruct,
                genericPrint},
                POC_RETFIE,
@@ -849,7 +810,6 @@ static pCodeInstruction pciRETFIE = {
 
 static pCodeInstruction pciRETLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeRETURN,
                genericDestruct,
                genericPrint},
                POC_RETLW,
@@ -871,7 +831,6 @@ static pCodeInstruction pciRETLW = {
 
 static pCodeInstruction pciRETURN = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   AnalyzeRETURN,
                genericDestruct,
                genericPrint},
                POC_RETURN,
@@ -893,7 +852,6 @@ static pCodeInstruction pciRETURN = {
 
 static pCodeInstruction pciRLF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_RLF,
@@ -915,7 +873,6 @@ static pCodeInstruction pciRLF = {
 
 static pCodeInstruction pciRLFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_RLFW,
@@ -937,7 +894,6 @@ static pCodeInstruction pciRLFW = {
 
 static pCodeInstruction pciRRF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_RRF,
@@ -959,7 +915,6 @@ static pCodeInstruction pciRRF = {
 
 static pCodeInstruction pciRRFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_RRFW,
@@ -981,7 +936,6 @@ static pCodeInstruction pciRRFW = {
 
 static pCodeInstruction pciSUBWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_SUBWF,
@@ -1003,7 +957,6 @@ static pCodeInstruction pciSUBWF = {
 
 static pCodeInstruction pciSUBFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_SUBFW,
@@ -1025,7 +978,6 @@ static pCodeInstruction pciSUBFW = {
 
 static pCodeInstruction pciSUBLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_SUBLW,
@@ -1047,7 +999,6 @@ static pCodeInstruction pciSUBLW = {
 
 static pCodeInstruction pciSWAPF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_SWAPF,
@@ -1069,7 +1020,6 @@ static pCodeInstruction pciSWAPF = {
 
 static pCodeInstruction pciSWAPFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_SWAPFW,
@@ -1091,7 +1041,6 @@ static pCodeInstruction pciSWAPFW = {
 
 static pCodeInstruction pciTRIS = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_TRIS,
@@ -1113,7 +1062,6 @@ static pCodeInstruction pciTRIS = {
 
 static pCodeInstruction pciXORWF = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_XORWF,
@@ -1135,7 +1083,6 @@ static pCodeInstruction pciXORWF = {
 
 static pCodeInstruction pciXORFW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_XORFW,
@@ -1157,7 +1104,6 @@ static pCodeInstruction pciXORFW = {
 
 static pCodeInstruction pciXORLW = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_XORLW,
@@ -1180,7 +1126,6 @@ static pCodeInstruction pciXORLW = {
 
 static pCodeInstruction pciBANKSEL = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_BANKSEL,
@@ -1202,7 +1147,6 @@ static pCodeInstruction pciBANKSEL = {
 
 static pCodeInstruction pciPAGESEL = {
        {PC_OPCODE, NULL, NULL, 0, 0, NULL, 
-               //   genericAnalyze,
                genericDestruct,
                genericPrint},
                POC_PAGESEL,
@@ -1485,6 +1429,7 @@ static char getpBlock_dbName(pBlock *pb)
        
        return pb->dbName;
 }
+
 void pBlockConvert2ISR(pBlock *pb)
 {
        if(!pb)
@@ -1610,6 +1555,7 @@ void pcode_test(void)
                }
        }
 }
+
 /*-----------------------------------------------------------------*/
 /* int RegCond(pCodeOp *pcop) - if pcop points to the STATUS reg-  */
 /*      ister, RegCond will return the bit being referenced.       */
@@ -1724,7 +1670,6 @@ pCode *newpCodeWild(int pCodeID, pCodeOp *optional_operand, pCodeOp *optional_la
        pcw->pci.from = pcw->pci.to = pcw->pci.label = NULL;
        pcw->pci.pc.pb = NULL;
        
-       //  pcw->pci.pc.analyze = genericAnalyze;
        pcw->pci.pc.destruct = genericDestruct;
        pcw->pci.pc.print = genericPrint;
        
@@ -1740,38 +1685,6 @@ pCode *newpCodeWild(int pCodeID, pCodeOp *optional_operand, pCodeOp *optional_la
        
 }
 
-/*-----------------------------------------------------------------*/
-/* newPcodeInlineP - create a new pCode from a char string           */
-/*-----------------------------------------------------------------*/
-
-#if 0
-static pCode *newpCodeInlineP(char *cP)
-{
-       
-       pCodeComment *pcc ;
-       
-       pcc = Safe_calloc(1,sizeof(pCodeComment));
-       
-       pcc->pc.type = PC_INLINE;
-       pcc->pc.prev = pcc->pc.next = NULL;
-       pcc->pc.id = PCodeID();
-       //pcc->pc.from = pcc->pc.to = pcc->pc.label = NULL;
-       pcc->pc.pb = NULL;
-       
-       //  pcc->pc.analyze = genericAnalyze;
-       pcc->pc.destruct = genericDestruct;
-       pcc->pc.print = genericPrint;
-       
-       if(cP)
-               pcc->comment = Safe_strdup(cP);
-       else
-               pcc->comment = NULL;
-       
-       return ( (pCode *)pcc);
-       
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* newPcodeCharP - create a new pCode from a char string           */
 /*-----------------------------------------------------------------*/
@@ -1789,7 +1702,6 @@ pCode *newpCodeCharP(char *cP)
        //pcc->pc.from = pcc->pc.to = pcc->pc.label = NULL;
        pcc->pc.pb = NULL;
        
-       //  pcc->pc.analyze = genericAnalyze;
        pcc->pc.destruct = genericDestruct;
        pcc->pc.print = genericPrint;
        
@@ -1820,7 +1732,6 @@ pCode *newpCodeFunction(char *mod,char *f,int isPublic)
        //pcf->pc.from = pcf->pc.to = pcf->pc.label = NULL;
        pcf->pc.pb = NULL;
        
-       //  pcf->pc.analyze = genericAnalyze;
        pcf->pc.destruct = genericDestruct;
        pcf->pc.print = pCodePrintFunction;
        
@@ -1878,7 +1789,6 @@ static pCode *newpCodeFlow(void )
        pcflow->pc.prev = pcflow->pc.next = NULL;
        pcflow->pc.pb = NULL;
        
-       //  pcflow->pc.analyze = genericAnalyze;
        pcflow->pc.destruct = destructpCodeFlow;
        pcflow->pc.print = genericPrint;
        
@@ -2023,7 +1933,6 @@ pCode *newpCodeLabel(char *name, int key)
        //pcl->pc.from = pcl->pc.to = pcl->pc.label = NULL;
        pcl->pc.pb = NULL;
        
-       //  pcl->pc.analyze = genericAnalyze;
        pcl->pc.destruct = pCodeLabelDestruct;
        pcl->pc.print = pCodePrintLabel;
        
@@ -2258,25 +2167,6 @@ pCodeOp *newpCodeOpBit(char *name, int ibit, int inBitSpace)
        return pcop;
 }
 
-#if 0
-static pCodeOp *newpCodeOpBitReg(regs *reg, int ibit, int inBitSpace)
-{
-    pCodeOp *pcop;
-
-    assert(reg);
-
-    pcop = Safe_calloc(1,sizeof(pCodeOpRegBit));
-    pcop->name = reg->name;
-    pcop->type = PO_GPR_BIT;
-    PCORB(pcop)->bit = ibit;
-    PCORB(pcop)->inBitSpace = inBitSpace;
-    PCOR(pcop)->r = reg;
-    PCOR(pcop)->index = 0;
-    PCOR(pcop)->rIdx = reg->rIdx;
-    return pcop;
-}
-#endif
-
 /*-----------------------------------------------------------------*
 * pCodeOp *newpCodeOpReg(int rIdx) - allocate a new register
 *
@@ -2385,70 +2275,6 @@ pCodeOp *newpCodeOp(char *name, PIC_OPTYPE type)
        return pcop;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-static void pCodeConstString(char *name, char *value)
-{
-       pBlock *pb;
-       unsigned i;
-       
-       //  fprintf(stderr, " %s  %s  %s\n",__FUNCTION__,name,value);
-       
-       if(!name || !value)
-               return;
-       
-       pb = newpCodeChain(NULL, 'P',newpCodeCharP("; Starting pCode block"));
-       
-       addpBlock(pb);
-       
-       sprintf(buffer,"; %s = %s",name,value);
-       for (i=strlen(buffer); i--; ) {
-               unsigned char c = buffer[i];
-               if (c=='\r' || c=='\n') {
-                       memmove(buffer+i+1,buffer+i,strlen(buffer)-i+1);
-                       buffer[i] = '\\';
-                       if (c=='\r') buffer[i+1] = 'r';
-                       else if (c=='\n') buffer[i+1] = 'n';
-               }
-       }
-       
-       addpCode2pBlock(pb,newpCodeCharP(buffer));
-       addpCode2pBlock(pb,newpCodeLabel(name,-1));
-       
-       do {
-               addpCode2pBlock(pb,newpCode(POC_RETLW,newpCodeOpLit(*value)));
-       }while (*value++);
-       
-       
-}
-
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-static void pCodeReadCodeTable(void)
-{
-       pBlock *pb;
-       
-       fprintf(stderr, " %s\n",__FUNCTION__);
-       
-       pb = newpCodeChain(NULL, 'P',newpCodeCharP("; Starting pCode block"));
-       
-       addpBlock(pb);
-       
-       addpCode2pBlock(pb,newpCodeCharP("; ReadCodeTable - built in function"));
-       addpCode2pBlock(pb,newpCodeCharP("; Inputs: temp1,temp2 = code pointer"));
-       addpCode2pBlock(pb,newpCodeCharP("; Outpus: W (from RETLW at temp2:temp1)"));
-       addpCode2pBlock(pb,newpCodeLabel("ReadCodeTable:",-1));
-       
-       addpCode2pBlock(pb,newpCode(POC_MOVFW,newpCodeOpRegFromStr("temp2")));
-       addpCode2pBlock(pb,newpCode(POC_MOVWF,newpCodeOpRegFromStr("PCLATH")));
-       addpCode2pBlock(pb,newpCode(POC_MOVFW,newpCodeOpRegFromStr("temp1")));
-       addpCode2pBlock(pb,newpCode(POC_MOVWF,newpCodeOpRegFromStr("PCL")));
-       
-       
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* addpCode2pBlock - place the pCode into the pBlock linked list   */
 /*-----------------------------------------------------------------*/
@@ -2866,21 +2692,6 @@ void pCodeDeleteChain(pCode *f,pCode *t)
        }
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-static void pBlockRegs(FILE *of, pBlock *pb)
-{
-       
-       regs  *r;
-       
-       r = setFirstItem(pb->tregisters);
-       while (r) {
-               r = setNextItem(pb->tregisters);
-       }
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
 char *get_op(pCodeOp *pcop,char *buffer, size_t size)
@@ -3176,31 +2987,6 @@ static void genericPrint(FILE *of, pCode *pc)
           fprintf(of,",rIdx=r0x%X",pcor->rIdx);
       }
     }
-#if 0
-    {
-      pBranch *dpb = pc->to;   // debug
-      while(dpb) {
-        switch ( dpb->pc->type) {
-        case PC_OPCODE:
-          fprintf(of, "\t;%s", PCI(dpb->pc)->mnemonic);
-          break;
-        case PC_LABEL:
-          fprintf(of, "\t;label %d", PCL(dpb->pc)->key);
-          break;
-        case PC_FUNCTION:
-          fprintf(of, "\t;function %s", ( (PCF(dpb->pc)->fname) ? (PCF(dpb->pc)->fname) : "[END]"));
-          break;
-        case PC_FLOW:
-          fprintf(of, "\t;flow");
-          break;
-        case PC_COMMENT:
-        case PC_WILD:
-          break;
-        }
-        dpb = dpb->next;
-      }
-    }
-#endif
     fprintf(of,"\n");
     break;
 
@@ -3242,7 +3028,6 @@ static void genericPrint(FILE *of, pCode *pc)
     break;
 
   case PC_CSOURCE:
-//    fprintf(of,";#CSRC\t%s %d\n;  %s\n", PCCS(pc)->file_name, PCCS(pc)->line_number, PCCS(pc)->line);
     fprintf(of,"%s\t.line\t%d; \"%s\"\t%s\n", (options.debug?"":";"), PCCS(pc)->line_number, PCCS(pc)->file_name, PCCS(pc)->line);
     break;
 
@@ -3303,6 +3088,7 @@ static void pCodePrintFunction(FILE *of, pCode *pc)
                        fprintf(of,"; exit point [can't find entry point]\n");
        }
 }
+
 /*-----------------------------------------------------------------*/
 /* pCodePrintLabel - prints label                                  */
 /*-----------------------------------------------------------------*/
@@ -3382,7 +3168,8 @@ pBranch * pBranchAppend(pBranch *h, pBranch *n)
        
        return h;
        
-}  
+}
+
 /*-----------------------------------------------------------------*/
 /* pBranchLink - given two pcodes, this function will link them    */
 /*               together through their pBranches                  */
@@ -3411,110 +3198,6 @@ static void pBranchLink(pCodeFunction *f, pCodeFunction *t)
        
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* pBranchFind - find the pBranch in a pBranch chain that contains */
-/*               a pCode                                           */
-/*-----------------------------------------------------------------*/
-static pBranch *pBranchFind(pBranch *pb,pCode *pc)
-{
-       while(pb) {
-               
-               if(pb->pc == pc)
-                       return pb;
-               
-               pb = pb->next;
-       }
-       
-       return NULL;
-}
-
-/*-----------------------------------------------------------------*/
-/* pCodeUnlink - Unlink the given pCode from its pCode chain.      */
-/*-----------------------------------------------------------------*/
-static void pCodeUnlink(pCode *pc)
-{
-       pBranch *pb1,*pb2;
-       pCode *pc1;
-       
-       if(!pc->prev || !pc->next) {
-               fprintf(stderr,"unlinking bad pCode in %s:%d\n",__FILE__,__LINE__);
-               exit(1);
-       }
-       
-       /* first remove the pCode from the chain */
-       pc->prev->next = pc->next;
-       pc->next->prev = pc->prev;
-       
-       /* Now for the hard part... */
-       
-       /* Remove the branches */
-       
-       pb1 = pc->from;
-       while(pb1) {
-       pc1 = pb1->pc;    /* Get the pCode that branches to the
-       * one we're unlinking */
-       
-       /* search for the link back to this pCode (the one we're
-       * unlinking) */
-       if(pb2 = pBranchFind(pc1->to,pc)) {
-               pb2->pc = pc->to->pc;  // make the replacement
-               
-                                                          /* if the pCode we're unlinking contains multiple 'to'
-                                                          * branches (e.g. this a skip instruction) then we need
-               * to copy these extra branches to the chain. */
-               if(pc->to->next)
-                       pBranchAppend(pb2, pc->to->next);
-       }
-       
-       pb1 = pb1->next;
-       }
-       
-       
-}
-#endif
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-#if 0
-static void genericAnalyze(pCode *pc)
-{
-       switch(pc->type) {
-       case PC_WILD:
-       case PC_COMMENT:
-               return;
-       case PC_LABEL:
-       case PC_FUNCTION:
-       case PC_OPCODE:
-               {
-                       // Go through the pCodes that are in pCode chain and link
-                       // them together through the pBranches. Note, the pCodes
-                       // are linked together as a contiguous stream like the 
-                       // assembly source code lines. The linking here mimics this
-                       // except that comments are not linked in.
-                       // 
-                       pCode *npc = pc->next;
-                       while(npc) {
-                               if(npc->type == PC_OPCODE || npc->type == PC_LABEL) {
-                                       pBranchLink(pc,npc);
-                                       return;
-                               } else
-                                       npc = npc->next;
-                       }
-                       /* reached the end of the pcode chain without finding
-                       * an instruction we could link to. */
-               }
-               break;
-       case PC_FLOW:
-               fprintf(stderr,"analyze PC_FLOW\n");
-               
-               return;
-       case PC_BAD:
-               fprintf(stderr,";A bad pCode is being used\n");
-               
-       }
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
 static int compareLabel(pCode *pc, pCodeOpLabel *pcop_label)
@@ -3575,28 +3258,6 @@ static pCode * findLabelinpBlock(pBlock *pb,pCodeOpLabel *pcop_label)
                return NULL;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* findLabel - Search the pCode for a particular label             */
-/*-----------------------------------------------------------------*/
-static pCode * findLabel(pCodeOpLabel *pcop_label)
-{
-       pBlock *pb;
-       pCode  *pc;
-       
-       if(!the_pFile)
-               return NULL;
-       
-       for(pb = the_pFile->pbHead; pb; pb = pb->next) {
-               if( (pc = findLabelinpBlock(pb,pcop_label)) != NULL)
-                       return pc;
-       }
-       
-       fprintf(stderr,"Couldn't find label %s\n", pcop_label->pcop.name);
-       return NULL;
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* findNextpCode - given a pCode, find the next of type 'pct'      */
 /*                 in the linked list                              */
@@ -3691,63 +3352,6 @@ pCode * findPrevInstruction(pCode *pci)
   return NULL;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* findFunctionEnd - given a pCode find the end of the function    */
-/*                   that contains it                              */
-/*-----------------------------------------------------------------*/
-static pCode * findFunctionEnd(pCode *pc)
-{
-       while(pc) {
-               if(pc->type == PC_FUNCTION &&  !(PCF(pc)->fname))
-                       return pc;
-               
-               pc = pc->next;
-       }
-       
-       fprintf(stderr,"Couldn't find function end\n");
-       return NULL;
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* AnalyzeLabel - if the pCode is a label, then merge it with the  */
-/*                instruction with which it is associated.         */
-/*-----------------------------------------------------------------*/
-static void AnalyzeLabel(pCode *pc)
-{
-       
-       pCodeUnlink(pc);
-       
-}
-#endif
-
-#if 0
-static void AnalyzeGOTO(pCode *pc)
-{
-       
-       pBranchLink(pc,findLabel( (pCodeOpLabel *) (PCI(pc)->pcop) ));
-       
-}
-
-static void AnalyzeSKIP(pCode *pc)
-{
-       
-       pBranchLink(pc,findNextInstruction(pc->next));
-       pBranchLink(pc,findNextInstruction(pc->next->next));
-       
-}
-
-static void AnalyzeRETURN(pCode *pc)
-{
-       
-       //  branch_link(pc,findFunctionEnd(pc->next));
-       
-}
-
-#endif
-
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
 regs * getRegFromInstruction(pCode *pc)
@@ -4308,139 +3912,6 @@ static void LinkFlow(pBlock *pb)
                
        }
 }
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-
-#if 0
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-static int isPCinFlow(pCode *pc, pCode *pcflow)
-{
-       
-       if(!pc || !pcflow)
-               return 0;
-       
-       if(!isPCI(pc) || !PCI(pc)->pcflow || !isPCFL(pcflow) )
-               return 0;
-       
-       if( PCI(pc)->pcflow->pc.seq == pcflow->seq)
-               return 1;
-       
-       return 0;
-}
-#endif
-
-#if 0
-static int isREGinBank(regs *reg, int bank)
-{
-
-       if(!reg || !pic)
-               return 0;
-
-       if((int)((reg->address | reg->alias) & pic->bankMask & bank) == bank)
-               return 1;
-
-       return 0;
-}
-
-static int REGallBanks(regs *reg)
-{
-
-       if(!reg || !pic)
-               return 0;
-
-       return ((reg->address | reg->alias) & pic->bankMask);
-
-}
-#endif
-
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-/*
-static void BanksUsedFlow2(pCode *pcflow)
-{
-       pCode *pc=NULL;
-       
-       int bank = -1;
-       bool RegUsed = 0;
-       
-       regs *reg;
-       
-       if(!isPCFL(pcflow)) {
-               fprintf(stderr, "BanksUsed - pcflow is not a flow object ");
-               return;
-       }
-       
-       pc = findNextInstruction(pcflow->next);
-       
-       PCFL(pcflow)->lastBank = -1;
-       
-       while(isPCinFlow(pc,pcflow)) {
-               
-               int bank_selected = isBankInstruction(pc);
-               
-               //if(PCI(pc)->pcflow) 
-               //fprintf(stderr,"BanksUsedFlow2, looking at seq %d\n",PCI(pc)->pcflow->pc.seq);
-               
-               if(bank_selected > 0) {
-                       //fprintf(stderr,"BanksUsed - mucking with bank %d\n",bank_selected);
-                       
-                       // This instruction is modifying banking bits before accessing registers
-                       if(!RegUsed)
-                               PCFL(pcflow)->firstBank = -1;
-                       
-                       if(PCFL(pcflow)->lastBank == -1)
-                               PCFL(pcflow)->lastBank = 0;
-                       
-                       bank = (1 << (bank_selected & (PIC_RP0_BIT | PIC_RP1_BIT)));
-                       if(bank_selected & SET_BANK_BIT)
-                               PCFL(pcflow)->lastBank |= bank;
-                       
-                       
-               } else { 
-                       reg = getRegFromInstruction(pc);
-                       
-                       if(reg && !isREGinBank(reg, bank)) {
-                               int allbanks = REGallBanks(reg);
-                               if(bank == -1)
-                                       PCFL(pcflow)->firstBank = allbanks;
-                               
-                               PCFL(pcflow)->lastBank = allbanks;
-                               
-                               bank = allbanks;
-                       }
-                       RegUsed = 1;
-                                                               }
-                                                               
-               pc = findNextInstruction(pc->next);
-       }
-       
-       //  fprintf(stderr,"BanksUsedFlow2 flow seq=%3d, first bank = 0x%03x, Last bank 0x%03x\n",
-       //    pcflow->seq,PCFL(pcflow)->firstBank,PCFL(pcflow)->lastBank);
-}
-*/
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-/*
-static void BanksUsedFlow(pBlock *pb)
-{
-       pCode *pcflow;
-       
-       
-       //pb->pcHead->print(stderr, pb->pcHead);
-       
-       pcflow = findNextpCode(pb->pcHead, PC_FLOW);
-       //pcflow->print(stderr,pcflow);
-       
-       for( pcflow = findNextpCode(pb->pcHead, PC_FLOW); 
-       pcflow != NULL;
-       pcflow = findNextpCode(pcflow->next, PC_FLOW) ) {
-               
-               BanksUsedFlow2(pcflow);
-       }
-       
-}
-*/
 
 static void pCodeReplace (pCode *old, pCode *new)
 {
@@ -5233,8 +4704,6 @@ void AnalyzeBanking(void)
        AnalyzeFlow(0);
        AnalyzeFlow(1);
        
-       //  for(pb = the_pFile->pbHead; pb; pb = pb->next)
-       //    BanksUsedFlow(pb);
        for(pb = the_pFile->pbHead; pb; pb = pb->next)
                FixRegisterBanking(pb);
 
@@ -5513,21 +4982,6 @@ void AnalyzepCode(char dbName)
        buildCallTree();
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* ispCodeFunction - returns true if *pc is the pCode of a         */
-/*                   function                                      */
-/*-----------------------------------------------------------------*/
-static bool ispCodeFunction(pCode *pc)
-{
-       
-       if(pc && pc->type == PC_FUNCTION && PCF(pc)->fname)
-               return 1;
-       
-       return 0;
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* findFunction - Search for a function by name (given the name)   */
 /*                in the set of all functions that are in a pBlock */
@@ -5559,22 +5013,6 @@ static pCode *findFunction(char *fname)
        return NULL;
 }
 
-#if 0
-static void MarkUsedRegisters(set *regset)
-{
-       
-       regs *r1,*r2;
-       
-       for(r1=setFirstItem(regset); r1; r1=setNextItem(regset)) {
-               r2 = pic14_regWithIdx(r1->rIdx);
-               if (r2) {
-                       r2->isFree = 0;
-                       r2->wasUsed = 1;
-               }
-       }
-}
-#endif
-
 static void pBlockStats(FILE *of, pBlock *pb)
 {
        
@@ -5620,136 +5058,6 @@ static void pBlockStats(FILE *of, pBlock *pb)
        }
 }
 
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-#if 0
-static void sequencepCode(void)
-{
-       pBlock *pb;
-       pCode *pc;
-       
-       
-       for(pb = the_pFile->pbHead; pb; pb = pb->next) {
-               
-               pb->seq = GpCodeSequenceNumber+1;
-               
-               for( pc = pb->pcHead; pc; pc = pc->next)
-                       pc->seq = ++GpCodeSequenceNumber;
-       }
-       
-}
-#endif
-
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-/*
-static set *register_usage(pBlock *pb)
-{
-       pCode *pc,*pcn;
-       set *registers=NULL;
-       set *registersInCallPath = NULL;
-       
-       / * check recursion * /
-               
-               pc = setFirstItem(pb->function_entries);
-       
-       if(!pc)
-               return registers;
-       
-       pb->visited = 1;
-       
-       if(pc->type != PC_FUNCTION)
-               fprintf(stderr,"%s, first pc is not a function???\n",__FUNCTION__);
-       
-       pc = setFirstItem(pb->function_calls);
-       for( ; pc; pc = setNextItem(pb->function_calls)) {
-               
-               if(pc->type == PC_OPCODE && PCI(pc)->op == POC_CALL) {
-                       char *dest = get_op_from_instruction(PCI(pc));
-                       
-                       pcn = findFunction(dest);
-                       if(pcn) 
-                               registersInCallPath = register_usage(pcn->pb);
-               } else
-                       fprintf(stderr,"BUG? pCode isn't a POC_CALL %d\n",__LINE__);
-               
-       }
-       
-#ifdef PCODE_DEBUG
-       pBlockStats(stderr,pb);  // debug
-#endif
-       
-       // Mark the registers in this block as used.
-       
-       MarkUsedRegisters(pb->tregisters);
-       if(registersInCallPath) {
-               / * registers were used in the functions this pBlock has called * /
-               / * so now, we need to see if these collide with the ones we are * /
-               / * using here * /
-               
-                       regs *r1,*r2, *newreg;
-               
-               DFPRINTF((stderr,"comparing registers\n"));
-               
-               r1 = setFirstItem(registersInCallPath);
-               while(r1) {
-                       if (r1->type != REG_STK) {
-                               r2 = setFirstItem(pb->tregisters);
-                               
-                               while(r2 && (r2->type != REG_STK)) {
-                                       
-                                       if(r2->rIdx == r1->rIdx) {
-                                               newreg = pic14_findFreeReg(REG_GPR);
-                                               
-                                               
-                                               if(!newreg) {
-                                                       DFPRINTF((stderr,"Bummer, no more registers.\n"));
-                                                       exit(1);
-                                               }
-                                               
-                                               DFPRINTF((stderr,"Cool found register collision nIdx=%d moving to %d\n",
-                                                       r1->rIdx, newreg->rIdx));
-                                               r2->rIdx = newreg->rIdx;
-                                               if(newreg->name)
-                                                       r2->name = Safe_strdup(newreg->name);
-                                               else
-                                                       r2->name = NULL;
-                                               newreg->isFree = 0;
-                                               newreg->wasUsed = 1;
-                                       }
-                                       r2 = setNextItem(pb->tregisters);
-                               }
-                       }
-                       
-                       r1 = setNextItem(registersInCallPath);
-               }
-               
-               / * Collisions have been resolved. Now free the registers in the call path * /
-               r1 = setFirstItem(registersInCallPath);
-               while(r1) {
-                       newreg = pic14_regWithIdx(r1->rIdx);
-                       if (newreg) newreg->isFree = 1;
-                       r1 = setNextItem(registersInCallPath);
-               }
-               
-       }// else
-       //      MarkUsedRegisters(pb->registers);
-       
-       registers = unionSets(pb->tregisters, registersInCallPath, THROW_NONE);
-#ifdef PCODE_DEBUG
-       if(registers) 
-               DFPRINTF((stderr,"returning regs\n"));
-       else
-               DFPRINTF((stderr,"not returning regs\n"));
-       
-       DFPRINTF((stderr,"pBlock after register optim.\n"));
-       pBlockStats(stderr,pb);  // debug
-#endif
-       
-       return registers;
-}
-*/
-
 /*-----------------------------------------------------------------*/
 /* printCallTree - writes the call tree to a file                  */
 /*                                                                 */
@@ -5800,6 +5108,19 @@ static void pct2(FILE *of,pBlock *pb,int indent)
 }
 
 #if 0
+/*-----------------------------------------------------------------*/
+/* ispCodeFunction - returns true if *pc is the pCode of a         */
+/*                   function                                      */
+/*-----------------------------------------------------------------*/
+static bool ispCodeFunction(pCode *pc)
+{
+
+       if(pc && pc->type == PC_FUNCTION && PCF(pc)->fname)
+               return 1;
+
+       return 0;
+}
+
 /*-----------------------------------------------------------------*/
 /* printCallTree - writes the call tree to a file                  */
 /*                                                                 */
index 46d72ea1d4e89fc9b5fe46e580d2350f8f2ce99c..e8cefd86797e2bf19871791945fc19f7f3e8141a 100644 (file)
@@ -114,13 +114,6 @@ struct regs;
 #define PIC_PIE_BIT  6   /* Peripheral Interrupt Enable */
 #define PIC_GIE_BIT  7   /* Global Interrupt Enable */
 
-/***********************************************************************
- *  Operand types 
- ***********************************************************************/
-#define POT_RESULT  0
-#define POT_LEFT    1
-#define POT_RIGHT   2
-
 
 /***********************************************************************
  *
@@ -306,15 +299,7 @@ typedef struct pCodeOp
        char *name;
 
 } pCodeOp;
-#if 0
-typedef struct pCodeOpBit
-{
-       pCodeOp pcop;
-       int bit;
-       unsigned int inBitSpace: 1; /* True if in bit space, else
-                                   just a bit of a register */
-} pCodeOpBit;
-#endif
+
 typedef struct pCodeOpLit
 {
        pCodeOp pcop;
@@ -359,16 +344,6 @@ typedef struct pCodeOpRegBit
                                    just a bit of a register */
 } pCodeOpRegBit;
 
-
-typedef struct pCodeOpRegPtr
-{
-       pCodeOpReg  pcor;       // The Register containing this bit
-
-       //  PIC_OPTYPE subtype;     // The type of this register.
-       //  unsigned int inBitSpace: 1; /* True if in bit space, else
-
-} pCodeOpRegPtr;
-
 typedef struct pCodeOpStr /* Only used here for the name of fn being called or jumped to */
 {
        pCodeOp  pcop;
@@ -417,7 +392,6 @@ typedef struct pCode
         * in C++. The subsequent structures that "inherit"
         * the pCode structure will initialize these function
         * pointers to something useful */
-       //  void (*analyze) (struct pCode *_this);
        void (*destruct)(struct pCode *_this);
        void (*print)  (FILE *of,struct pCode *_this);
 
@@ -474,12 +448,6 @@ typedef struct pCodeFlow
        pCode *end;   /* Last pCode in this flow. Note that
                         the first pCode is pc.next */
 
-       /*  set **uses;   * map the pCode instruction inCond and outCond conditions 
-        * in this array of set's. The reason we allocate an 
-        * array of pointers instead of declaring each type of 
-        * usage is because there are port dependent usage definitions */
-       //int nuses;    /* number of uses sets */
-
        set *from;    /* flow blocks that can send control to this flow block */
        set *to;      /* flow blocks to which this one can send control */
        struct pCodeFlow *ancestor; /* The most immediate "single" pCodeFlow object that
@@ -729,11 +697,6 @@ typedef struct pCodePeep {
        pCodeWildBlock target;     // code we'd like to optimize
        pCodeWildBlock replace;    // and this is what we'll optimize it with.
 
-       //pBlock *target;
-       //pBlock replace;            // and this is what we'll optimize it with.
-
-
-
        /* (Note: a wildcard register is a place holder. Any register
         * can be replaced by the wildcard when the pcode is being 
         * compared to the target. */
@@ -790,7 +753,6 @@ typedef struct peepCommand {
 #define PCAD(x)          ((pCodeAsmDir *)(x))
 
 #define PCOP(x)   ((pCodeOp *)(x))
-//#define PCOB(x)   ((pCodeOpBit *)(x))
 #define PCOL(x)   ((pCodeOpLit *)(x))
 #define PCOI(x)   ((pCodeOpImmd *)(x))
 #define PCOLAB(x) ((pCodeOpLabel *)(x))
@@ -916,3 +878,4 @@ int getpCodePeepCommand(char *cmd);
 int pCodeSearchCondition(pCode *pc, unsigned int cond, int contIfSkip);
 
 #endif // __PCODE_H__
+
index 682928567e27904e5b7b300eec1540d94515ead5..76767d04c77639c92acb631f83327a4e9b269289 100644 (file)
 
 #include "pcodeflow.h"
 
-#if 0
-
-/* 
-In the section that follows, an exhaustive flow "tree" is built.
-It's not a tree that's really built, but instead every possible
-flow path is constructed. 
-
-  This is really overkill...
-*/
-
-static set *FlowTree=NULL;
-
-static void dbg_dumpFlowTree(set *FlowTree)
-{
-       set *segment;
-       pCodeFlow *pcflow;
-       
-       fprintf(stderr,"Flow Tree: \n");
-       
-       for(segment = setFirstItem(FlowTree); segment; segment=setNextItem(FlowTree)) {
-               
-               fprintf(stderr,"Segment:\n");
-               
-               for(pcflow=PCFL(setFirstItem(segment)); pcflow; pcflow=PCFL(setNextItem(segment))) {
-                       fprintf(stderr, "  0x%03x",pcflow->pc.seq);
-               }
-               fprintf(stderr,"\n");
-       }
-       
-}
-
-
-
-
-/*-----------------------------------------------------------------*
-* void BuildFlowSegment(set *segment, pCodeFlow *pcflow)
-*-----------------------------------------------------------------*/
-static void BuildFlowSegment(set *segment, pCodeFlow *pcflow)
-{
-       
-       int nNextFlow=0;
-       pCodeFlowLink *pcflowLink=NULL;
-       
-       /* Add this flow to the set if it's not in there already */
-       if(isinSet(segment, pcflow)) {
-               addSetHead(&FlowTree, segment);
-               return;
-       }
-       
-       addSetHead(&segment, pcflow);
-       
-       /* Continue to add contiguous flows */
-       
-       while( pcflow->to && ((nNextFlow = elementsInSet(pcflow->to)) == 1)) {
-               pcflowLink = (pCodeFlowLink *)(setFirstItem(pcflow->to));
-               pcflow = pcflowLink->pcflow;
-               
-               if(isinSet(segment, pcflow)) {
-                       addSetIfnotP(&FlowTree, segment);
-                       return;
-               }
-               
-               addSetIfnotP(&segment, pcflow);
-               
-       }
-       
-       /* Branch: for each branch, duplicate the set and recursively call */
-       if(pcflow->to && nNextFlow>=2) {
-               pCodeFlow *pcflow_to;
-               
-               set *branch_segment=NULL;
-               
-               pcflowLink = (pCodeFlowLink *)(setFirstItem(pcflow->to));
-               pcflow_to = pcflowLink->pcflow;
-               
-               addSetIfnotP(&segment, pcflow);
-               
-               pcflowLink = (pCodeFlowLink *)(setNextItem(pcflow->to));
-               
-               while(pcflowLink) {
-                       
-                       branch_segment = setFromSet(segment);
-                       BuildFlowSegment(setFromSet(segment),pcflowLink->pcflow);
-                       pcflowLink = (pCodeFlowLink *)(setNextItem(pcflow->to));
-               }
-               
-               /* add the first branch to this segment */
-               BuildFlowSegment(segment,pcflow_to);
-               
-       }
-       
-       addSetIfnotP(&FlowTree, segment);
-       
-       /* done */
-}
-
-/*-----------------------------------------------------------------*
-* void BuildFlowTree(pBlock *pb)
-*-----------------------------------------------------------------*/
-void BuildFlowTree(pBlock *pb)
-{
-       pCodeFlow *pcflow;
-       set *segment;
-       
-       FlowTree = newSet();
-       
-       /* Start with the first flow object of this pBlock */
-       
-       pcflow = PCFL(findNextpCode(pb->pcHead, PC_FLOW));
-       
-       segment = newSet();
-       BuildFlowSegment(segment, pcflow);
-       
-       pb->FlowTree = FlowTree;
-       
-       dbg_dumpFlowTree(FlowTree);
-}
-#endif
-
 #if 0
 static void dbg_dumpFlow(pBlock *pb)
 {
index d80d8f3f4cb13838d8445fdb85e3821ca02b9791..129158937e6f6e782c6f669e0a0e5dc533c6afe0 100644 (file)
 
 #define IS_PCCOMMENT(x) ( x && (x->type==PC_COMMENT))
 
-/****************************************************************/
-/*
-* rootRules - defined in SDCCpeep.c
-*  This is a pointer to the (parsed) peephole rules that are
-* defined in peep.def.
-*/
-
-//extern peepRule *rootRules;
-
-
-
 
 /****************************************************************/
 /****************************************************************/
@@ -62,32 +51,6 @@ typedef struct pCodePeepSnippets
 
 static pCodePeepSnippets  *peepSnippets=NULL;
 
-/****************************************************************/
-/*                                                              */
-/* curPeep                                                      */
-/*                                                              */
-/****************************************************************/
-
-//static pCodePeep          *curPeep=NULL;
-
-/****************************************************************/
-/*                                                              */
-/* curBlock                                                     */
-/*                                                              */
-/****************************************************************/
-
-//static pBlock             *curBlock=NULL;
-
-
-/****************************************************************/
-/*                                                              */
-/* max wild cards in a peep rule                                */
-/*                                                              */
-/****************************************************************/
-
-//static int                sMaxWildVar   = 0;
-//static int                sMaxWildMnem  = 0;
-
 
 typedef struct pCodeToken 
 {
@@ -126,9 +89,6 @@ typedef struct parsedPattern {
 
 #define MAX_PARSEDPATARR 50
 static parsedPattern parsedPatArr[MAX_PARSEDPATARR];
-#if 0
-static unsigned int parsedPatIdx=0;
-#endif
 
 typedef enum {
        PCP_LABEL=1,
@@ -367,10 +327,6 @@ static void * cvt_altpat_mnem0a(void *pp, pCodeWildBlock *pcwb)
        DFPRINTF((stderr,"altpat_mnem0a wild mnem # %d\n",  p[0].pct[1].tok.n));
        
        /* Save the index of the maximum wildcard mnemonic */
-       
-       //if(p[0].pct[1].tok.n > sMaxWildVar)
-       //  sMaxWildMnem = p[0].pct[1].tok.n;
-       
        if(p[0].pct[1].tok.n > pcwb->nwildpCodes)
                pcwb->nwildpCodes = p[0].pct[1].tok.n;
        
@@ -478,9 +434,6 @@ static void * cvt_altpat_mnem1a(void *pp,pCodeWildBlock *pcwb)
                newpCodeOpWild(p[1].pct[1].tok.n, pcwb, pcosubtype)));
        
        /* Save the index of the maximum wildcard variable */
-       //if(p[1].pct[1].tok.n > sMaxWildVar)
-       //  sMaxWildVar = p[1].pct[1].tok.n;
-       
        if(p[1].pct[1].tok.n > pcwb->nvars)
                pcwb->nvars = p[1].pct[1].tok.n;
        
@@ -619,9 +572,6 @@ static void * cvt_altpat_mnem2a(void *pp,pCodeWildBlock *pcwb)
                newpCodeOpWild(p[1].pct[1].tok.n, pcwb, pcosubtype)));
        
        /* Save the index of the maximum wildcard variable */
-       //if(p[1].pct[1].tok.n > sMaxWildVar)
-       //  sMaxWildVar = p[1].pct[1].tok.n;
-       
        if(p[1].pct[1].tok.n > pcwb->nvars)
                pcwb->nvars = p[1].pct[1].tok.n;
        
@@ -1126,8 +1076,6 @@ static int parseTokens(pCodeWildBlock *pcwb, pCode **pcret)
                                //  pc->print(stderr,pc);
                                //if(pc && pc->destruct) pc->destruct(pc); dumps core?
                                
-                               //if(curBlock && pc)
-                               //addpCode2pBlock(curBlock, pc);
                                if(pc) {
                                        if (pcret) {
                                                *pcret = pc;
@@ -1189,29 +1137,6 @@ static void peepRuleBlock2pCodeBlock(lineNode *ln, pCodeWildBlock *pcwb)
        }
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/*                                                                 */
-/*-----------------------------------------------------------------*/
-static pCode *AssembleLine(char *line)
-{
-       pCode *pc=NULL;
-       
-       if(!line || !*line) {
-               fprintf(stderr,"WARNING returning NULL in AssembleLine\n");
-               return NULL;
-       }
-       
-       tokenizeLineNode(line);
-
-       if(parseTokens(NULL,&pc))
-               fprintf(stderr, "WARNING: unable to assemble line:\n%s\n",line);
-       
-       return pc;
-       
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* peepRuleCondition                                               */
 /*-----------------------------------------------------------------*/
@@ -1326,23 +1251,12 @@ void peepRules2pCode(peepRule *rules)
                //DFPRINTF((stderr,"finished target, here it is in pcode form:\n"));
                //printpBlock(stderr, currentRule->target.pb);
                
-               //DFPRINTF((stderr,"target with labels merged:\n"));
-               //pBlockMergeLabels(curBlock);
                pBlockMergeLabels(currentRule->target.pb);
                //printpBlock(stderr, currentRule->replace.pb);
                
-               //#ifdef PCODE_DEBUG
-               //    printpBlock(stderr, curBlock);
-               //#endif
-               //DFPRINTF((stderr,"\nReplaced by:\n"));
-               
-               
                /* Convert the replace block */
                peepRuleBlock2pCodeBlock(pr->replace, &currentRule->replace);
                
-               //DFPRINTF((stderr,"finished replace block, here it is in pcode form:\n"));
-               //printpBlock(stderr, curBlock);
-               
                //DFPRINTF((stderr,"replace with labels merged:\n"));
                
                pBlockMergeLabels(currentRule->replace.pb);
@@ -1376,18 +1290,6 @@ void peepRules2pCode(peepRule *rules)
        
 }
 
-#if 0
-static void printpCodeString(FILE *of, pCode *pc, int max)
-{
-       int i=0;
-       
-       while(pc && (i++<max)) {
-               pc->print(of,pc);
-               pc = pc->next;
-       }
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* _DLL * DLL_append                                               */
 /*                                                                 */ 
index 69f55a7c045e909b54a036909db918203f631a33..c115b3213ab9df8b8d6a7a56cd79eec6a74d6b47 100644 (file)
@@ -36,105 +36,6 @@ pcoderegs.c
 static int total_registers_saved=0;
 static int register_optimization=1;
 
-/*-----------------------------------------------------------------*
-* void AddRegToFlow(regs *reg, pCodeFlow *pcfl)
-*-----------------------------------------------------------------*/
-/*
-static void AddRegToFlow(regs *reg, pCodeFlow *pcfl)
-{
-
-       if(!reg || ! pcfl || !isPCFL(pcflow))
-       return;
-
-       if(!pcfl->registers) 
-       pcfl->registers =  newSet();
-       
-}
-*/
-
-
-#if 0
-/*-----------------------------------------------------------------*
-* 
-*-----------------------------------------------------------------*/
-static void dbg_regusage(set *fregs)
-{
-       regs *reg;
-       pCode *pcfl;
-       pCode *pc;
-       
-       
-       for (reg = setFirstItem(fregs) ; reg ;
-       reg = setNextItem(fregs)) {
-               
-               if(elementsInSet(reg->reglives.usedpCodes)) {
-                       
-                       fprintf (stderr, "%s  addr=0x%03x rIdx=0x%03x",
-                               reg->name,
-                               reg->address,
-                               reg->rIdx);
-                       
-                       pcfl = setFirstItem(reg->reglives.usedpFlows);
-                       if(pcfl)
-                               fprintf(stderr, "\n   used in seq");
-                       
-                       while(pcfl) {
-                               fprintf(stderr," 0x%03x",pcfl->seq);
-                               pcfl = setNextItem(reg->reglives.usedpFlows);
-                       }
-                       
-                       pcfl = setFirstItem(reg->reglives.assignedpFlows);
-                       if(pcfl)
-                               fprintf(stderr, "\n   assigned in seq");
-                       
-                       while(pcfl) {
-                               fprintf(stderr," 0x%03x",pcfl->seq);
-                               pcfl = setNextItem(reg->reglives.assignedpFlows);
-                       }
-                       
-                       pc = setFirstItem(reg->reglives.usedpCodes);
-                       if(pc)
-                               fprintf(stderr, "\n   used in instructions ");
-                       
-                       while(pc) {
-                               pcfl = PCODE(PCI(pc)->pcflow);
-                               if(pcfl)
-                                       fprintf(stderr," 0x%03x:",pcfl->seq);
-                               fprintf(stderr,"0x%03x",pc->seq);
-                               
-                               pc = setNextItem(reg->reglives.usedpCodes);
-                       }
-                       
-                       fprintf(stderr, "\n");
-               }
-       }
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*
-* 
-*-----------------------------------------------------------------*/
-static void dbg_dumpregusage(void)
-{
-       
-       fprintf(stderr,"***  Register Usage  ***\n");
-       fprintf(stderr,"InternalRegs:\n");
-       dbg_regusage(dynInternalRegs);
-       fprintf(stderr,"AllocRegs:\n");
-       dbg_regusage(dynAllocRegs);
-       fprintf(stderr,"StackRegs:\n");
-       dbg_regusage(dynStackRegs);
-       fprintf(stderr,"DirectRegs:\n");
-       dbg_regusage(dynDirectRegs);
-       fprintf(stderr,"DirectBitRegs:\n");
-       dbg_regusage(dynDirectBitRegs);
-       fprintf(stderr,"ProcessorRegs:\n");
-       dbg_regusage(dynProcessorRegs);
-       
-}
-#endif
-
 /*-----------------------------------------------------------------*
 * void pCodeRegMapLiveRangesInFlow(pCodeFlow *pcfl)
 *-----------------------------------------------------------------*/
@@ -228,8 +129,6 @@ void pCodeRegMapLiveRanges(pBlock *pb)
        }
 #endif
        
-       //  dbg_dumpregusage();
-       
 }
 
 
@@ -474,23 +373,6 @@ static int regIsSpecial (regs *reg, int mayBeGlobal)
   return 0;
 }
 
-#if 0
-static int regIsLocal (regs *reg)
-{
-       if (!reg) return 1;
-       /* temporaries are local */
-       if (reg->type == REG_TMP) return 1;
-       /* registers named r0x... are local */
-       if (reg->name && !strncmp(reg->name,"r0x", 3))
-       {
-               //fprintf (stderr, "reg %s is not marked REG_TMP...\n", reg->name);
-               return 1;
-       }
-
-       return 0;
-}
-#endif
-
 /*-----------------------------------------------------------------*
 * void pCodeOptime2pCodes(pCode *pc1, pCode *pc2) 
 *
@@ -843,804 +725,6 @@ static void OptimizeRegUsage(set *fregs, int optimize_multi_uses, int optimize_l
        }
 }
 
-#if 0
-
-/* The following routines implement pCode optimizations based on
- * dataflow analysis. The effects should be similar to those
- * of pCodeOptime2pCodes() but more powerful.
- *
- * Unfortunately, the current approach (comparing operands by
- * their associated registers) is seriously flawed:
- * Some pCodeOps do not provide access to their repsective regs
- * (PO_DIRs are created from arbitrary strings, immediates need
- * to take offset and index into account, ...)
- *
- * This has to be rewritten based on pCodeOps instead of regs...
- */
-
-/* ------------------------------------------------------------------
-   Returns TRUE iff reg1 and reg2 are the same registers.
-   ------------------------------------------------------------------ */
-
-static int sameRegs (const regs *reg1, const regs *reg2)
-{
-       if (reg1 == reg2) return 1;
-       if (!reg1 || !reg2) return 0;
-       assert (reg1->name && reg2->name);
-
-       /* Compare names, as rIdx is not unique... */
-       if (!strcmp(reg1->name, reg2->name)) return 1;
-
-       /* Name mismatch -- not the same register. */
-       return 0;
-}
-
-/* ------------------------------------------------------------------
-   Returns 1 if the register is live at pc (read in this flow),
-   returns -1 if the register is NOT live at pc (assigned a new value
-   prior to readingi the old value in this flow) or
-   return 0 if the register is not mentioned.
-   ------------------------------------------------------------------ */
-
-static int checkRegInFlow (regs **reg, int *cond, pCode *pc)
-{
-       const int verbose = 0;
-       /* find next PCI at or after pc */
-       while (pc && isPCFL(pc)) pc = pc->next;
-
-       assert (reg && cond);
-
-       /* remove pseudo flags from cond */
-       *cond &= ~(PCC_REGISTER | PCC_EXAMINE_PCOP);
-
-       if (verbose && pc)
-       {
-               fprintf (stderr, "Checking for reg %s, cond %x on pc ", *reg ? (*reg)->name : "<none>", *cond); pc->print (stderr, pc);
-       }
-       
-       while (pc && !isPCFL(pc))
-       {
-               if (verbose)
-               {
-                       fprintf (stderr, "        now checking for reg %s, cond %x on pc ", *reg ? (*reg)->name : "<none>", *cond);
-                       pc->print (stderr, pc);
-               }
-               if (isPCI(pc))
-               {
-                       pCode *pcprev;
-                       regs *op = NULL;
-                       int prevIsSkip = 0;
-                       
-                       pcprev = findPrevInstruction (pc);
-                       if (pcprev && isPCI_SKIP(pcprev))
-                               prevIsSkip = 1;
-
-                       if ((PCI(pc)->inCond | PCI(pc)->outCond) & PCC_REGISTER)
-                       {
-                               op = getRegFromInstruction (pc);
-
-                               /* pCodeOpRegBits do not provide register information... */
-                               //if (!op) { __asm__("int3"); pc->print (stderr, pc); }
-                               //assert (op);
-                               if (!op) 
-                               {
-                                       if (reg)
-                                               return 1; /* assume `reg' is alive */
-                               }
-
-                               /* SPECIAL CASE: jump to unknown destination -- assume everything alive */
-                               if (op->type == PO_PCL)
-                               {
-                                       return 1;
-                               }
-                       } // if
-
-                       if (PCI(pc)->inCond & PCC_REGISTER)
-                       {
-                               /* `op' is live (possibly read) */
-                               if (*reg && sameRegs (op, *reg))
-                               {
-                                       if (verbose)
-                                       {
-                                               fprintf (stderr, "reg is read in pc ");
-                                               pc->print (stderr, pc);
-                                       }
-                                       return 1;
-                               }
-                       }
-
-                       /* handle additional implicit operands */
-                       switch (PCI(pc)->op)
-                       {
-                       case POC_CALL: /* read arguments from WREG, clobbers WREG */
-                               if (*cond & PCC_W)
-                               {
-                                       if (verbose)
-                                       {
-                                               fprintf (stderr, "conditions are read at pc ");
-                                               pc->print (stderr, pc);
-                                       }
-                                       return 1;
-                               }
-                               *cond &= ~PCC_W;
-                               break;
-                       case POC_RETURN: /* returns WREG to caller */
-                               //fprintf (stderr, "reached RETURN, reg %s, cond %x\n", *reg ? (*reg)->name : "<none>", *cond);
-                               if (*cond & PCC_W)
-                               {
-                                       if (verbose)
-                                       {
-                                               fprintf (stderr, "conditions are read at pc ");
-                                               pc->print (stderr, pc);
-                                       }
-                                       return 1;
-                               }
-                               /* afterwards, no condition is alive */
-                               *cond = 0;
-                               /* afterwards, all local registers are dead */
-                               if (*reg && regIsLocal (*reg)) *reg = NULL;
-                               break;
-                       case POC_RETLW:
-                       case POC_RETFIE: /* this does not erturn WREG to the "caller", thus its rather a RETLW */
-                               /* this discards WREG */
-                               *cond &= ~PCC_W;
-                               /* afterwards, no condition is alive */
-                               *cond = 0;
-                               /* afterwards, all local registers are dead */
-                               if (*reg && regIsLocal (*reg)) *reg = NULL;
-                               break;
-                       default:
-                               /* no implicit arguments */
-                               break;
-                       }
-
-                       if (PCI(pc)->inCond & (*cond))
-                       {
-                               /* a condition is read */
-                               if (verbose)
-                               {
-                                       fprintf (stderr, "conditions are read at pc ");
-                                       pc->print (stderr, pc);
-                               }
-                               return 1;
-                       }
-
-                       /* remove outConds from `cond' */
-                       (*cond) &= ~(PCI(pc)->outCond);
-
-                       if (PCI(pc)->outCond & PCC_REGISTER)
-                       {
-                               /* `op' is (possibly) discarded */
-                               if (*reg && !prevIsSkip && sameRegs (op, *reg))
-                               {
-                                       if (verbose)
-                                       {
-                                               fprintf (stderr, "reg is assigned (cont'd) at pc ");
-                                               pc->print (stderr, pc);
-                                       }
-                                       *reg = NULL;
-                               }
-                       }
-
-                       /* have all interesting conditions/registers been discarded? */
-                       if (!(*reg) && !(*cond))
-                       {
-                               if (verbose)
-                               {
-                                       fprintf (stderr, "reg and conditions are discarded after ");
-                                       pc->print (stderr, pc);
-                               }
-                               return -1;
-                       }
-               } // if
-
-               pc = pc->next;
-       } // while
-
-       /* no use of (or only conditional writes to) `reg' found in flow */
-       if (verbose)
-       {
-               fprintf (stderr, "analysis inconclusive: reg %s, cond %x remains\n", *reg ? "remains" : "is void", *cond);
-       }
-       return 0;
-}
-
-/* ------------------------------------------------------------------
-   This will return 1 only if
-   - reg is NULL or of type REG_TMP
-   - reg is NULL or its value is discarded after pc
-   - cond is 0 or all conditions are overwritten before being used
-   ------------------------------------------------------------------ */
-
-typedef struct {
-  pCode *pc;
-  regs *reg;
-  int cond;
-} df_state_t;
-
-df_state_t *df_free_states = NULL;
-
-static df_state_t *
-df_newState (regs *reg, int cond, pCode *pc)
-{
-       df_state_t *state;
-
-       if (df_free_states) {
-         state = df_free_states;
-         df_free_states = (df_state_t *)df_free_states->pc;
-       } else {
-         state = Safe_calloc(1, sizeof(df_state_t));
-       }
-       state->pc = pc;
-       state->reg = reg;
-       state->cond = cond;
-       return state;
-}
-
-static int
-df_containsState (set *set, df_state_t *state)
-{
-       /* scan set for presence of `state' */
-       df_state_t *curr;
-       for (curr = setFirstItem (set); curr; curr = setNextItem (set))
-       {
-               if ((curr->pc == state->pc)
-                       && (curr->reg == state->reg)
-                       && (curr->cond == state->cond))
-               {
-                       /* `state' found */
-                       return 1;
-               }
-       }
-       return 0;
-}
-
-static void
-df_releaseState (df_state_t *state)
-{
-       state->pc = (pCode *)df_free_states;
-       df_free_states = (df_state_t *)state;
-       state->reg = NULL;
-       state->cond = 0;
-}
-
-static void
-df_removeStates ()
-{
-       df_state_t *next;
-       while (df_free_states)
-       {
-               next = (df_state_t *)df_free_states->pc;
-               Safe_free(df_free_states);
-               df_free_states = next;
-       } // while
-}
-
-static int regIsDead (regs *reg, int cond, pCode *pc)
-{
-       set *seenStates = NULL;
-       set *todo = NULL;
-       pCode *curr;
-       df_state_t *state;
-       int result = 1;
-       
-       /* sanity checks */
-       if (reg && !regIsLocal (reg)) return 0;
-
-       pc = findNextInstruction (pc->next);
-
-       addSet (&todo, df_newState(reg, cond, pc));
-
-       while ((result == 1) && (state = getSet (&todo)))
-       {
-               int res;
-               
-               if (df_containsState (seenStates, state)) continue;
-               addSet (&seenStates, state);
-
-               curr = state->pc;
-               reg = state->reg;
-               cond = state->cond;
-               
-               //fprintf (stderr, "Checking for reg %s/cond %x at pc ", reg ? reg->name : "<none>", cond);
-               //curr->print (stderr, curr);
-
-               res = checkRegInFlow (&reg, &cond, curr);
-               switch (res)
-               {
-               case 1: /* `reg' or `cond' is read---not dead */
-                       result = 0;
-                       break;
-               case -1: /* `reg' and `cond' are discarded in this flow---need to check other open flows */
-                       break;
-               default: /* `reg' is not read and (possibly) not assigned---check successor flows */
-                       if (curr)
-                       {
-                               pCodeFlow *pcfl = PCI(curr)->pcflow;
-                               pCodeFlowLink *link;
-                               pCode *first;
-                               assert (pcfl);
-
-                               for (link = setFirstItem(pcfl->to); link; link = setNextItem (pcfl->to))
-                               {
-                                       /* add the first pCodeInstruction in the new flow to `todo' */
-                                       first = findNextInstruction (&link->pcflow->pc);
-                                       if (first) addSet (&todo, df_newState (reg, cond, first));
-                               } // for
-                       }
-                       break;
-               } // switch
-       } // while
-
-       /* clean up */
-       while (NULL != (state = getSet (&todo))) { df_releaseState (state); }
-       while (NULL != (state = getSet (&seenStates))) { df_releaseState (state); }
-
-       /* if result remained 1, `reg' is not even possibly read and thus dead */
-       return result;
-}
-
-
-
-/* ------------------------------------------------------------------
-   Safely remove a pCode.
-   This needs to check that the previous instruction was no SKIP
-   (otherwise the SKIP instruction would have to be removed as well,
-   which may not be done for SFRs (side-effects on read possible)).
-   ------------------------------------------------------------------ */
-
-static int pCodeRemove (pCode *pc, const char *comment)
-{
-       pCode *pcprev, *pcnext;
-       unsigned int result = 0;
-       
-       /* Sanity checks. */
-       if (!pc) return 0;
-       if (!isPCI(pc)) return 0;
-
-       pcprev = findPrevInstruction (pc->prev);
-       if (pcprev && isPCI_SKIP(pcprev))
-       {
-               /* bail out until we know how to fix the Flow... */
-               //return 0;
-
-               /* we also need to remove the preceeding SKIP instruction(s) */
-               result = pCodeRemove (pcprev, "=DF= removing preceeding SKIP as well");
-               if (!result)
-               {
-                       /* previous instruction could not be removed -- this cannot be removed as well */
-                       return result;
-               }
-               /* FIXME: We now have to update the flow! */
-       } // if
-
-       /* do not remove pCodes with SFRs as operands (even reading them might cause side effects) */
-       {
-               regs *reg;
-               reg = getRegFromInstruction (pc);
-               /* accesses to the STATUS register aer always safe, but others... */
-               if (reg && reg->type == REG_SFR && reg->pc_type != PO_STATUS) return result;
-       }
-
-       /* MUST SUCEED FROM NOW ON (or revert the changes done since NOW ;-)) */
-       
-       /* fix flow */
-       if (PCI(pc)->pcflow && PCI(pc)->pcflow->end == pc)
-       {
-               pCode *pcprev;
-               pcprev = findPrevInstruction (pc->prev);
-               if (PCI(pcprev)->pcflow == PCI(pc)->pcflow)
-               {
-                       PCI(pc)->pcflow->end = pcprev;
-               } else {
-                       pBlock *pb = pc->pb;
-                       RegsUnMapLiveRanges();
-                       unBuildFlow(pb);
-                       BuildFlow(pb);
-                       LinkFlow(pb);
-                       BuildFlowTree(pb);
-                       for (pb = the_pFile->pbHead; pb; pb = pb->next)
-                       {
-                               pCodeRegMapLiveRanges(pb);
-                       }
-               }
-       }
-       
-       /* attach labels to next instruction */
-       pcnext = findNextInstruction (pc->next);
-       if (pcnext)
-       {
-               PCI(pcnext)->label = pBranchAppend (PCI(pcnext)->label, PCI(pc)->label);
-               if (!PCI(pcnext)->cline) PCI(pcnext)->cline = PCI(pc)->cline;
-       }
-       else
-       {
-               fprintf (stderr, "Cannot move a label...\n");
-               exit(EXIT_FAILURE);
-       }
-       
-       if (comment)
-       {
-               char buffer[512];
-               int size = 512;
-               char *pbuff = &buffer[0];
-               
-               SNPRINTF (pbuff, size, "; %s:%u(%s): %s", __FILE__, __LINE__, __FUNCTION__, comment);
-               pCodeInsertAfter(pc->prev, newpCodeCharP (&buffer[0]));
-       } // if
-
-       if (1)
-       {
-               /* replace removed pCode with out-commented version of itself */
-               char buffer[512];
-               int size = 512;
-               char *pbuff = &buffer[0];
-               
-               SNPRINTF (pbuff, size, "; %s:%u(%s): ", __FILE__, __LINE__, __FUNCTION__);
-               size -= strlen(pbuff);
-               pbuff += strlen(pbuff);
-               pCode2str (pbuff, size, pc);
-               pCodeInsertAfter(pc->prev, newpCodeCharP (&buffer[0]));
-       }
-
-       pc->destruct (pc);
-       return result+1;
-}
-
-/* ------------------------------------------------------------------
-   Find and remove dead pCodes.
-   ------------------------------------------------------------------ */
-
-static int removeIfDeadPCI (pCode *pc)
-{
-       pCode *pcnext = NULL;
-       pCode *curr;
-       unsigned int outCond;
-       unsigned int result = 0;
-       regs *dst;
-       
-       if (!pc) return 0;
-       dst = NULL;
-       
-       /* skip non-PCIs */
-       pcnext = findNextInstruction (pc->next);
-       if (!isPCI(pc)) return 0;
-
-       switch (PCI(pc)->op)
-       {
-       case POC_ADDLW:
-       case POC_ADDWF:
-       case POC_ADDFW:
-       case POC_ANDLW:
-       case POC_ANDWF:
-       case POC_ANDFW:
-       case POC_BCF:
-       case POC_BSF:
-       //case POC_BTFSC:
-       //case POC_BTFSS:
-       //case POC_CALL:
-       case POC_COMF:
-       case POC_COMFW:
-       case POC_CLRF:
-       case POC_CLRW:
-       //case POC_CLRWDT:
-       case POC_DECF:
-       case POC_DECFW:
-       //case POC_DECFSZ:
-       //case POC_DECFSZW:
-       //case POC_GOTO:
-       case POC_INCF:
-       case POC_INCFW:
-       //case POC_INCFSZ:
-       //case POC_INCFSZW:
-       case POC_IORLW:
-       case POC_IORWF:
-       case POC_IORFW:
-       case POC_MOVF:
-       case POC_MOVFW:
-       case POC_MOVLW:
-       case POC_MOVWF:
-       case POC_NOP:
-       //case POC_RETLW:
-       //case POC_RETURN:
-       //case POC_RETFIE:
-       case POC_RLF:
-       case POC_RLFW:
-       case POC_RRF:
-       case POC_RRFW:
-       case POC_SUBLW:
-       case POC_SUBWF:
-       case POC_SUBFW:
-       case POC_SWAPF:
-       case POC_SWAPFW:
-       //case POC_TRIS:
-       case POC_XORLW:
-       case POC_XORWF:
-       case POC_XORFW:
-       //case POC_BANKSEL:
-       //case POC_PAGESEL:
-               break;
-       
-       default:
-               /* do not remove unknown PCIs */
-               return 0;
-       } // switch
-
-       /* redundant checks---those instructions may never be removed */
-       if (isPCI_BRANCH(pc)) return 0;
-       if (isPCI_SKIP(pc)) return 0;
-       
-       outCond = PCI(pc)->outCond;
-       curr = pcnext;
-
-       /* unknown operands assigned to, then ignore */
-       if ((outCond & (PCC_REGISTER | PCC_C | PCC_Z | PCC_DC | PCC_W)) != outCond)
-               return 0;
-       
-       if (outCond & PCC_REGISTER)
-       {
-               dst = getRegFromInstruction (pc);
-               if (!dst) return 0;
-
-               /* special reg? */
-               if (!regIsLocal (dst)) return 0;
-               if (regIsSpecial (dst,0)) return 0;
-       }
-       
-       //fprintf (stderr, "--> checking for liveness pc "); pc->print (stderr, pc);
-       if (regIsDead (dst, outCond, pc))
-       {
-               /* no result from pc has been used -- pc is `dead' */
-               //fprintf (stderr, "--> reg %s and cond %x assumed unused\n", dst ? dst->name : "<none>", outCond);
-               //fprintf (stderr, "--> removing dead pc "); pc->print (stderr, pc);
-               result = pCodeRemove (pc, "=DF= removed dead pCode");
-       }
-       
-       return result;
-}
-
-/* ------------------------------------------------------------------
-   This routine is intended to safely replace one pCodeInstruction
-   with a different pCodeInstruction.
-   If desired, the replaced pCode will be left in (commented out) for
-   debugging.
-   Further, an optional comment can be inserted to indicate the
-   reason for the possible removal of the pCode.
-   ------------------------------------------------------------------ */
-
-static void replace_PCI (pCodeInstruction *pc, pCodeInstruction *newpc, char *comment)
-{
-  newpc->from =  pBranchAppend (newpc->from, pc->from);
-  newpc->to = pBranchAppend (newpc->to, pc->to);
-  newpc->label = pBranchAppend (newpc->label, pc->label);
-  //newpc->pcflow = pc->pcflow; // updated in pCodeInsertAfter, ->pb is as well
-  newpc->cline = pc->cline;
-
-  newpc->pc.seq = pc->pc.seq;
-
-  pCodeInsertAfter (&pc->pc, &newpc->pc);
-
-  /* FIXME: replacing pc will break the liverange maps (usedpCodes, ...) */
-  pCodeRegMapLiveRanges( pc->pBlock ); /*FIXME:UNTESTED*/
-  
-  if (comment)
-  {
-    pCodeInsertAfter (&pc->pc, newpCodeCharP (comment));
-  } // if
-
-  if (1)
-  {
-    /* replace pc with commented out version of itself */
-    char buffer[1024], buffer2[1024];
-    char *pbuff = &buffer[0];
-    int size=1024;
-    pCode2str (&buffer2[0],1024,&pc->pc);
-    SNPRINTF (pbuff,size,"%s:%u(%s): removed pCode was %s\t", __FILE__, __LINE__, __FUNCTION__, &buffer2[0]);
-    pCodeInsertAfter (&pc->pc, newpCodeCharP (&buffer[0]));
-  } // if
-
-  pc->pc.destruct (&pc->pc);
-}
-
-/* ------------------------------------------------------------------
-   Find the first (unique) assignment to `reg' (prior to pc).
-   ------------------------------------------------------------------ */
-
-static pCode *findAssignmentToReg (regs *reg, pCode *pc)
-{
-       pCode *curr;
-       
-       assert (pc && isPCI(pc) && reg);
-
-       curr = findPrevInstruction (pc->prev);
-       
-       while (curr && PCI(curr)->pcflow == PCI(pc)->pcflow)
-       {
-               if (PCI(curr)->outCond & PCC_REGISTER)
-               {
-                       regs *op = getRegFromInstruction (curr);
-                       if (op && (sameRegs(op,reg)))
-                               return curr;
-               } // if
-               curr = findPrevInstruction (curr->prev);
-       } // while
-       
-       /* no assignment to reg found */
-       return NULL;
-}
-
-/* ------------------------------------------------------------------
-   Find a register that holds the same value as `reg' (an alias).
-   ------------------------------------------------------------------ */
-
-static regs *findRegisterAlias (regs *reg, pCode *pc)
-{
-       pCode *curr;
-
-       if(!reg) return NULL;
-
-       if (regIsSpecial (reg, 0)) return NULL;
-
-       curr = findAssignmentToReg (reg, pc);
-
-       /* no assignment found --> no alias found */
-       if (!curr) return NULL;
-
-       switch (PCI(curr)->op)
-       {
-       case POC_MOVWF:
-               /* find previous assignment to WREG */
-               while (curr && !(PCI(curr)->outCond & PCC_W))
-                       curr = findPrevInstruction (curr->prev);
-               if (curr && PCI(curr)->op == POC_MOVFW)
-               {
-                       regs *op = getRegFromInstruction (curr);
-                       /* alias must not be changed since assignment... */
-                       if (PCI(curr)->pcop)
-                       {
-                               switch (PCI(curr)->pcop->type)
-                               {
-                               case PO_GPR_REGISTER:
-                               case PO_GPR_TEMP:
-                                       /* these operands are ok */
-                                       break;
-                               default:
-                                       /* not a plain register operand */
-                                       return NULL;
-                                       break;
-                               }
-                       }
-                       if (!op || regIsSpecial (op, 0) || !regIsUnchangedSince (op, pc, curr)) return NULL;
-                       //fprintf (stderr, "found register alias for %s: %s\n", reg->name, op && op->name ? op->name : "<no name>");
-                       return op;
-               } else {
-                       /* unknown source to WREG -- unknown register alias */
-                       return NULL;
-               }
-               break;
-       
-       default:
-               /* unhandled instruction -- assume unknown source, no alias */
-               return NULL;
-       }
-
-       /* no alias found */
-       return NULL;
-}
-
-/* ------------------------------------------------------------------
-   Analyze a single pCodeInstruction's dataflow relations and replace
-   it with a better variant if possible.
-   ------------------------------------------------------------------ */
-
-static void analyzeAndReplacePCI (pCodeInstruction *pci)
-{
-       regs *op_reg, *alias_reg;
-       
-       assert (pci);
-
-       if (!isPCI(pci)) return;
-       
-       switch (pci->op)
-       {
-       case POC_MOVFW:
-       case POC_ADDFW:
-       case POC_ANDFW:
-       case POC_IORFW:
-       case POC_XORFW:
-               /* try to find a different source register */
-               op_reg = getRegFromInstruction (&pci->pc);
-               if (pci->op == POC_MOVFW) /* touches Z */
-               {
-                       pCode *assignment = findAssignmentToReg (op_reg, &pci->pc);
-                       if (assignment && isPCI(assignment) && (PCI(assignment)->op == POC_CLRF))
-                       {
-                               replace_PCI (pci, PCI(newpCode(POC_MOVLW, newpCodeOpLit(0))), "replaced with CLRF");
-                               return;
-                       }                       
-               }
-               
-               alias_reg = findRegisterAlias (op_reg, &pci->pc);
-               if (alias_reg)
-               {
-                       replace_PCI (pci, PCI(newpCode(pci->op, newpCodeOpRegFromStr (alias_reg->name))), "=DF= replaced with move from register alias");
-               }
-               break;
-
-       default:
-               /* do not optimize */
-               break;
-       } // switch
-}
-
-/* ------------------------------------------------------------------
-   Find and remove dead pCodes.
-   ------------------------------------------------------------------ */
-
-static int removeDeadPCIs (void)
-{
-       pBlock *pb;
-       unsigned int removed = 0;
-       
-       if (!the_pFile) return removed;
-       
-       do {
-               removed = 0;
-               
-               /* iterate over all pBlocks */
-               for (pb = the_pFile->pbHead; pb; pb = pb->next)
-               {
-                       pCode *pc, *pcnext = NULL;
-                       
-                       /* iterate over all pCodes */
-                       for (pc = findNextInstruction (pb->pcHead); pc; pc = pcnext)
-                       {
-                               pcnext = findNextInstruction (pc->next);
-                               removed += removeIfDeadPCI (pc);
-                       } // while
-               } // for pb
-
-               fprintf (stderr, "[removed %u dead pCodes]\n", removed);
-       } while (removed);
-       
-       return 0;
-}
-
-/* ------------------------------------------------------------------
-   This routine tries to optimize the dataflow by...
-   (1) 
-   
-   This routine leaves in dead pCodes (assignments whose results are
-   not used) -- these should be removed in a following sweep phase.
-   ------------------------------------------------------------------ */
-
-static void optimizeDataflow (void)
-{
-       pBlock *pb;
-       
-       if (!the_pFile) return;
-
-       //fprintf (stderr, "%s:%u(%s): Starting optimization...\n", __FILE__, __LINE__, __FUNCTION__);
-       
-       /* iterate over all pBlocks */
-       for (pb = the_pFile->pbHead; pb; pb = pb->next)
-       {
-               pCode *pc, *pcnext = NULL;
-               
-               /* iterate over all pCodes */
-               for (pc = findNextInstruction (pb->pcHead); pc; pc = pcnext)
-               {
-                       pcnext = findNextInstruction (pc->next);
-                       analyzeAndReplacePCI (PCI(pc));
-               } // while
-       } // for pb
-
-       while (removeDeadPCIs ()) { /* remove dead codes in multiple passes */};
-       df_removeStates ();
-}
-
-#endif
-
 /*-----------------------------------------------------------------*
 * void pCodeRegOptimeRegUsage(pBlock *pb) 
 *-----------------------------------------------------------------*/
@@ -1681,16 +765,6 @@ void pCodeRegOptimizeRegUsage(int level)
        
        if(total_registers_saved == t) 
                DFPRINTF((stderr, "No registers saved on this pass\n"));
-
-
-       /*
-               fprintf(stderr,"dynamically allocated regs:\n");
-               dbg_regusage(dynAllocRegs);
-               fprintf(stderr,"stack regs:\n");
-               dbg_regusage(dynStackRegs);
-               fprintf(stderr,"direct regs:\n");
-               dbg_regusage(dynDirectRegs);
-       */
 }
 
 
index 8c4c3e9901e30efca04707487bf66737ed5d40a7..46c8723fb81460aff9eaa05ad21d86d5bf3e0d1f 100644 (file)
@@ -1022,22 +1022,6 @@ nfreeRegsType (int type)
         return nFreeRegs (type);
 }
 
-#if 0
-static void writeSetUsedRegs(FILE *of, set *dRegs)
-{
-
-        regs *dReg;
-
-        for (dReg = setFirstItem(dRegs) ; dReg ;
-        dReg = setNextItem(dRegs)) {
-
-                if(dReg->wasUsed)
-                        fprintf (of, "\t%s\n",dReg->name);
-        }
-
-}
-#endif
-
 static void packBits(set *bregs)
 {
         set *regset;
@@ -1136,30 +1120,6 @@ static void bitEQUs(FILE *of, set *bregs)
 
 }
 
-#if 0
-static void aliasEQUs(FILE *of, set *fregs, int use_rIdx)
-{
-        regs *reg;
-
-
-        for (reg = setFirstItem(fregs) ; reg ;
-        reg = setNextItem(fregs)) {
-
-                if(reg->wasUsed) {
-                        if(use_rIdx)
-                                fprintf (of, "%s\tEQU\t0x%03x\n",
-                                reg->name,
-                                reg->rIdx);
-                        else
-                                fprintf (of, "%s\tEQU\t0x%03x\n",
-                                reg->name,
-                                reg->address);
-                }
-        }
-
-}
-#endif
-
 void writeUsedRegs(FILE *of)
 {
 
@@ -2478,100 +2438,6 @@ createRegMask (eBBlock ** ebbs, int count)
                 }
         }
 }
-#if 0
-/* This was the active version */
-/*-----------------------------------------------------------------*/
-/* rematStr - returns the rematerialized string for a remat var    */
-/*-----------------------------------------------------------------*/
-static symbol *
-rematStr (symbol * sym)
-{
-        char *s = buffer;
-        iCode *ic = sym->rematiCode;
-        symbol *psym = NULL;
-
-        debugLog ("%s\n", __FUNCTION__);
-
-        //printf ("%s\n", s);
-
-        /* if plus or minus print the right hand side */
-
-        if (ic->op == '+' || ic->op == '-') {
-
-                iCode *ric = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
-
-                sprintf (s, "(%s %c 0x%04x)",
-                        OP_SYMBOL (IC_LEFT (ric))->rname,
-                        ic->op,
-                        (int) operandLitValue (IC_RIGHT (ic)));
-
-
-                //fprintf(stderr, "ralloc.c:%d OOPS %s\n",__LINE__,s);
-
-                psym = newSymbol (OP_SYMBOL (IC_LEFT (ric))->rname, 1);
-                psym->offset = (int) operandLitValue (IC_RIGHT (ic));
-
-                return psym;
-        }
-
-        sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
-        psym = newSymbol (OP_SYMBOL (IC_LEFT (ic))->rname, 1);
-
-        //printf ("ralloc.c:%d %s\n", __LINE__,buffer);
-        return psym;
-}
-#endif
-
-#if 0
-/* deprecated version */
-/*-----------------------------------------------------------------*/
-/* rematStr - returns the rematerialized string for a remat var    */
-/*-----------------------------------------------------------------*/
-static char *
-rematStr (symbol * sym)
-{
-        char *s = buffer;
-        iCode *ic = sym->rematiCode;
-
-        debugLog ("%s\n", __FUNCTION__);
-        while (1)
-        {
-
-                printf ("%s\n", s);
-                /* if plus or minus print the right hand side */
-                /*
-                if (ic->op == '+' || ic->op == '-') {
-                sprintf(s,"0x%04x %c ",(int) operandLitValue(IC_RIGHT(ic)),
-                ic->op );
-                s += strlen(s);
-                ic = OP_SYMBOL(IC_LEFT(ic))->rematiCode;
-                continue ;
-                }
-                */
-                if (ic->op == '+' || ic->op == '-')
-                {
-                        iCode *ric = OP_SYMBOL (IC_LEFT (ic))->rematiCode;
-                        sprintf (s, "(%s %c 0x%04x)",
-                                OP_SYMBOL (IC_LEFT (ric))->rname,
-                                ic->op,
-                                (int) operandLitValue (IC_RIGHT (ic)));
-
-                        //s += strlen(s);
-                        //ic = OP_SYMBOL(IC_LEFT(ic))->rematiCode;
-                        //continue ;
-                        //fprintf(stderr, "ralloc.c:%d OOPS %s\n",__LINE__,s);
-                        return buffer;
-                }
-
-                /* we reached the end */
-                sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname);
-                break;
-        }
-
-        printf ("%s\n", buffer);
-        return buffer;
-}
-#endif
 
 /*-----------------------------------------------------------------*/
 /* regTypeNum - computes the type & number of registers required   */
@@ -2697,67 +2563,6 @@ regTypeNum ()
 
 }
 
-#if 0
-static
-DEFSETFUNC (markRegFree)
-{
-        ((regs *)item)->isFree = 1;
-
-        return 0;
-}
-
-static
-DEFSETFUNC (deallocReg)
-{
-        fprintf(stderr,"deallocting register %s\n",((regs *)item)->name);
-        ((regs *)item)->isFree = 1;
-        ((regs *)item)->wasUsed = 0;
-
-        return 0;
-}
-
-/*-----------------------------------------------------------------*/
-/* freeAllRegs - mark all registers as free                        */
-/*-----------------------------------------------------------------*/
-static void
-pic14_freeAllRegs ()
-{
-        //  int i;
-
-        debugLog ("%s\n", __FUNCTION__);
-
-        applyToSet(dynAllocRegs,markRegFree);
-        applyToSet(dynStackRegs,markRegFree);
-
-        /*
-        for (i = 0; i < pic14_nRegs; i++)
-        regspic14[i].isFree = 1;
-        */
-}
-
-/*-----------------------------------------------------------------*/
-/*-----------------------------------------------------------------*/
-static void
-pic14_deallocateAllRegs ()
-{
-        //  int i;
-
-        debugLog ("%s\n", __FUNCTION__);
-
-        applyToSet(dynAllocRegs,deallocReg);
-
-        /*
-        for (i = 0; i < pic14_nRegs; i++) {
-                if(regspic14[i].pc_type == PO_GPR_TEMP) {
-                regspic14[i].isFree = 1;
-                regspic14[i].wasUsed = 0;
-                }
-        }
-        */
-}
-#endif
-
-
 /*-----------------------------------------------------------------*/
 /* deallocStackSpil - this will set the stack pointer back         */
 /*-----------------------------------------------------------------*/
@@ -4124,8 +3929,6 @@ pic14_assignRegisters (ebbIndex * ebbi)
         _G.slocNum = 0;
         setToNull ((void *) &_G.stackSpil);
         setToNull ((void *) &_G.spiltSet);
-        /* mark all registers as free */
-        //pic14_freeAllRegs ();
 
         debugLog ("leaving\n<><><><><><><><><><><><><><><><><>\n");
         pic14_debugLogClose ();