Use 'ao-dbg' instead of 's51' to communicate with TeleMetrum
[fw/sdcc] / src / pic / gen.c
index 5cc81a41a7f6d2ee077d4d31cf8b0b9e8a9dbf28..a2482345d8cf644255cb770a7ffb6c44b8de79f4 100644 (file)
       Made everything static
 -------------------------------------------------------------------------*/
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include "SDCCglobl.h"
-#include "newalloc.h"
-
-#include "common.h"
-#include "SDCCpeeph.h"
-#include "ralloc.h"
-#include "pcode.h"
+/*
+ * This is the down and dirty file with all kinds of
+ * kludgy & hacky stuff. This is what it is all about
+ * CODE GENERATION for a specific MCU . some of the
+ * routines may be reusable, will have to see.
+ */
+
 #include "gen.h"
 #include "glue.h"
 
-/* The PIC port(s) need not differentiate between POINTER and FPOINTER. */
-#define PIC_IS_DATA_PTR(x)  (IS_DATA_PTR(x) || IS_FARPTR(x))
-#define PIC_IS_FARPTR(x)    (PIC_IS_DATA_PTR(x))
-
-extern void genUMult8X8_16 (operand *, operand *,operand *,pCodeOpReg *);
-extern void genSMult8X8_16 (operand *, operand *,operand *,pCodeOpReg *);
-void genMult8X8_8 (operand *, operand *,operand *);
-extern void printpBlock(FILE *of, pBlock *pb);
-
-static int labelOffset=0;
-extern int debug_verbose;
-extern int pic14_hasInterrupt;
-//static int optimized_for_speed = 0;
+/*
+ * Imports
+ */
+extern struct dbuf_s *codeOutBuf;
+extern set *externs;
 
-/* max_key keeps track of the largest label number used in
-a function. This is then used to adjust the label offset
-for the next function.
-*/
-static int max_key=0;
-static int GpsuedoStkPtr=0;
-static int pic14_inISR = 0;
 
-pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func);
-extern char *get_op( pCodeOp *pcop,char *buff,size_t buf_size);
-const char *AopType(short type);
+static pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func);
+static pCodeOp *popRegFromString(char *str, int size, int offset);
+static int aop_isLitLike(asmop *aop);
 
-#define BYTEofLONG(l,b) ( (l>> (b<<3)) & 0x00ff)
+/* The PIC port(s) need not differentiate between POINTER and FPOINTER. */
+#define PIC_IS_DATA_PTR(x)  (IS_DATA_PTR(x) || IS_FARPTR(x))
 
-/* this is the down and dirty file with all kinds of
-kludgy & hacky stuff. This is what it is all about
-CODE GENERATION for a specific MCU . some of the
-routines may be reusable, will have to see */
+/*
+ * max_key keeps track of the largest label number used in
+ * a function. This is then used to adjust the label offset
+ * for the next function.
+ */
+static int max_key = 0;
+static int labelOffset = 0;
+static int GpsuedoStkPtr = 0;
+static int pic14_inISR = 0;
 
 static char *zero = "0x00";
 static char *one  = "0x01";
 static char *spname = "sp";
 
-char *fReturnpic14[] = {"temp1","temp2","temp3","temp4" };
 unsigned fReturnSizePic = 4; /* shared with ralloc.c */
+static char *fReturnpic14[] = {"temp1","temp2","temp3","temp4" };
 static char **fReturn = fReturnpic14;
 
-//static char *accUse[] = {"a","b"};
-
-//static short rbank = -1;
-
 static struct {
-    short r0Pushed;
-    short r1Pushed;
     short accInUse;
     short inLine;
     short debugLine;
@@ -99,9 +80,10 @@ static struct {
     set *sendSet;
 } _G;
 
-/* Resolved ifx structure. This structure stores information
-about an iCode ifx that makes it easier to generate code.
-*/
+/*
+ * Resolved ifx structure. This structure stores information
+ * about an iCode ifx that makes it easier to generate code.
+ */
 typedef struct resolvedIfx {
     symbol *lbl;     /* pointer to a label */
     int condition;   /* true or false ifx */
@@ -109,22 +91,9 @@ typedef struct resolvedIfx {
                       * is generated */
 } resolvedIfx;
 
-extern int pic14_ptrRegReq ;
-extern int pic14_nRegs;
-extern struct dbuf_s *codeOutBuf;
-static void saverbank (int, iCode *,bool);
-
 static lineNode *lineHead = NULL;
 static lineNode *lineCurr = NULL;
-
-#if 0
-static unsigned char   SLMask[] = {0xFF ,0xFE, 0xFC, 0xF8, 0xF0,
-0xE0, 0xC0, 0x80, 0x00};
-static unsigned char   SRMask[] = {0xFF, 0x7F, 0x3F, 0x1F, 0x0F,
-0x07, 0x03, 0x01, 0x00};
-#endif
-
-static  pBlock *pb;
+static pBlock *pb;
 
 /*-----------------------------------------------------------------*/
 /*  my_powof2(n) - If `n' is an integaer power of 2, then the      */
@@ -168,7 +137,7 @@ void DEBUGpic14_AopType(int line_no, operand *left, operand *right, operand *res
 
 }
 
-void DEBUGpic14_AopTypeSign(int line_no, operand *left, operand *right, operand *result)
+static void DEBUGpic14_AopTypeSign(int line_no, operand *left, operand *right, operand *result)
 {
 
     DEBUGpic14_emitcode ("; ","line = %d, signs: result %s=%c, left %s=%c, right %s=%c",
@@ -249,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);
 }
@@ -281,14 +245,11 @@ void emitpcode_real(PIC_OPCODE poc, pCodeOp *pcop)
     }
 }
 
-void emitpcodeNULLop(PIC_OPCODE poc)
+static void emitpcodeNULLop(PIC_OPCODE poc)
 {
-
     addpCode2pBlock(pb,newpCode(poc,NULL));
-
 }
 
-
 /*-----------------------------------------------------------------*/
 /* pic14_emitcode - writes the code into a file : for now it is simple    */
 /*-----------------------------------------------------------------*/
@@ -337,95 +298,10 @@ pic14_emitDebuggerSymbol (char * debugSym)
     _G.debugLine = 0;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* getFreePtr - returns r0 or r1 whichever is free or can be pushed*/
-/*-----------------------------------------------------------------*/
-static regs *getFreePtr (iCode *ic, asmop **aopp, bool result)
-{
-    bool r0iu = FALSE , r1iu = FALSE;
-    bool r0ou = FALSE , r1ou = FALSE;
-
-    /* the logic: if r0 & r1 used in the instruction
-    then we are in trouble otherwise */
-
-    /* first check if r0 & r1 are used by this
-    instruction, in which case we are in trouble */
-    if ((r0iu = bitVectBitValue(ic->rUsed,R0_IDX)) &&
-        (r1iu = bitVectBitValue(ic->rUsed,R1_IDX)))
-    {
-        goto endOfWorld;
-    }
-
-    r0ou = bitVectBitValue(ic->rMask,R0_IDX);
-    r1ou = bitVectBitValue(ic->rMask,R1_IDX);
-
-    /* if no usage of r0 then return it */
-    if (!r0iu && !r0ou) {
-        ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX);
-        (*aopp)->type = AOP_R0;
-
-        return (*aopp)->aopu.aop_ptr = pic14_regWithIdx(R0_IDX);
-    }
-
-    /* if no usage of r1 then return it */
-    if (!r1iu && !r1ou) {
-        ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX);
-        (*aopp)->type = AOP_R1;
-
-        return (*aopp)->aopu.aop_ptr = pic14_regWithIdx(R1_IDX);
-    }
-
-    /* now we know they both have usage */
-    /* if r0 not used in this instruction */
-    if (!r0iu) {
-        /* push it if not already pushed */
-        if (!_G.r0Pushed) {
-            //pic14_emitcode ("push","%s",
-            //        pic14_regWithIdx(R0_IDX)->dname);
-            _G.r0Pushed++ ;
-        }
-
-        ic->rUsed = bitVectSetBit(ic->rUsed,R0_IDX);
-        (*aopp)->type = AOP_R0;
-
-        return (*aopp)->aopu.aop_ptr = pic14_regWithIdx(R0_IDX);
-    }
-
-    /* if r1 not used then */
-
-    if (!r1iu) {
-        /* push it if not already pushed */
-        if (!_G.r1Pushed) {
-            //pic14_emitcode ("push","%s",
-            //        pic14_regWithIdx(R1_IDX)->dname);
-            _G.r1Pushed++ ;
-        }
-
-        ic->rUsed = bitVectSetBit(ic->rUsed,R1_IDX);
-        (*aopp)->type = AOP_R1;
-        return pic14_regWithIdx(R1_IDX);
-    }
-
-endOfWorld :
-    /* I said end of world but not quite end of world yet */
-    /* if this is a result then we can push it on the stack*/
-    if (result) {
-        (*aopp)->type = AOP_STK;
-        return NULL;
-    }
-
-    /* other wise this is true end of the world */
-    werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
-        "getFreePtr should never reach here");
-    exit(0);
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* newAsmop - creates a new asmOp                                  */
 /*-----------------------------------------------------------------*/
-asmop *newAsmop (short type)
+static asmop *newAsmop (short type)
 {
     asmop *aop;
 
@@ -434,20 +310,6 @@ asmop *newAsmop (short type)
     return aop;
 }
 
-static void genSetDPTR(int n)
-{
-    if (!n)
-    {
-        pic14_emitcode(";", "Select standard DPTR");
-        pic14_emitcode("mov", "dps, #0x00");
-    }
-    else
-    {
-        pic14_emitcode(";", "Select alternate DPTR");
-        pic14_emitcode("mov", "dps, #0x01");
-    }
-}
-
 /*-----------------------------------------------------------------*/
 /* resolveIfx - converts an iCode ifx into a form more useful for  */
 /*              generating code                                    */
@@ -464,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);
@@ -475,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                                   */
@@ -530,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;
     }
@@ -566,14 +401,6 @@ static asmop *aopForSym (iCode *ic,symbol *sym,bool result)
     allocDirReg (IC_LEFT(ic));
 
     aop->size = FPTRSIZE;
-    /*
-    DEBUGpic14_emitcode(";","%d size = %d, name =%s",__LINE__,aop->size,sym->rname);
-    sym->aop = aop = newAsmop(AOP_DPTR);
-    pic14_emitcode ("mov","dptr,#%s", sym->rname);
-    aop->size = getSize(sym->type);
-
-      DEBUGpic14_emitcode(";","%d size = %d",__LINE__,aop->size);
-    */
 
     /* if it is in code space */
     if (IN_CODESPACE(space))
@@ -626,7 +453,7 @@ static asmop *aopForRemat (operand *op) // x symbol *sym)
     return aop;
 }
 
-int aopIdx (asmop *aop, int offset)
+static int aopIdx (asmop *aop, int offset)
 {
     if(!aop)
         return -1;
@@ -637,6 +464,7 @@ int aopIdx (asmop *aop, int offset)
     return aop->aopu.aop_reg[offset]->rIdx;
 
 }
+
 /*-----------------------------------------------------------------*/
 /* regsInCommon - two operands have some registers in common       */
 /*-----------------------------------------------------------------*/
@@ -820,21 +648,6 @@ void aopOp (operand *op, iCode *ic, bool result)
             return;
         }
 
-#if 0
-        /* WREG is not usable as an ordinary operand with PIC architecture,
-         * one might introduce a scratch register that can be used to make
-         * WREG accesible as an operand... disable WREG for now */
-        if (sym->accuse) {
-            int i;
-            aop = op->aop = sym->aop = newAsmop(AOP_ACC);
-            aop->size = getSize(sym->type);
-            for ( i = 0 ; i < 2 ; i++ )
-                aop->aopu.aop_str[i] = accUse[i];
-            DEBUGpic14_emitcode(";","%d size=%d",__LINE__,aop->size);
-            return;
-        }
-#endif
-
         if (sym->ruonly ) {
             if(sym->isptr) {    // && sym->uptr
                 aop = op->aop = sym->aop = newAsmop(AOP_PCODE);
@@ -927,85 +740,10 @@ void freeAsmop (operand *op, asmop *aaop, iCode *ic, bool pop)
     if (!aop)
         return ;
 
-    if (aop->freed)
-        goto dealloc;
-
     aop->freed = 1;
 
-    /* depending on the asmop type only three cases need work AOP_RO
-    , AOP_R1 && AOP_STK */
-#if 0
-    switch (aop->type) {
-    case AOP_R0 :
-        if (_G.r0Pushed ) {
-            if (pop) {
-                pic14_emitcode ("pop","ar0");
-                _G.r0Pushed--;
-            }
-        }
-        bitVectUnSetBit(ic->rUsed,R0_IDX);
-        break;
-
-    case AOP_R1 :
-        if (_G.r1Pushed ) {
-            if (pop) {
-                pic14_emitcode ("pop","ar1");
-                _G.r1Pushed--;
-            }
-        }
-        bitVectUnSetBit(ic->rUsed,R1_IDX);
-        break;
-
-    case AOP_STK :
-        {
-            int sz = aop->size;
-            int stk = aop->aopu.aop_stk + aop->size;
-            bitVectUnSetBit(ic->rUsed,R0_IDX);
-            bitVectUnSetBit(ic->rUsed,R1_IDX);
-
-            getFreePtr(ic,&aop,FALSE);
-
-            if (options.stack10bit)
-            {
-                /* I'm not sure what to do here yet... */
-                /* #STUB */
-                fprintf(stderr,
-                    "*** Warning: probably generating bad code for "
-                    "10 bit stack mode.\n");
-            }
-
-            if (stk) {
-                pic14_emitcode ("mov","a,_bp");
-                pic14_emitcode ("add","a,#0x%02x",((char)stk) & 0xff);
-                pic14_emitcode ("mov","%s,a",aop->aopu.aop_ptr->name);
-            } else {
-                pic14_emitcode ("mov","%s,_bp",aop->aopu.aop_ptr->name);
-            }
-
-            while (sz--) {
-                pic14_emitcode("pop","acc");
-                pic14_emitcode("mov","@%s,a",aop->aopu.aop_ptr->name);
-                if (!sz) break;
-                pic14_emitcode("dec","%s",aop->aopu.aop_ptr->name);
-            }
-            op->aop = aop;
-            freeAsmop(op,NULL,ic,TRUE);
-            if (_G.r0Pushed) {
-                pic14_emitcode("pop","ar0");
-                _G.r0Pushed--;
-            }
-
-            if (_G.r1Pushed) {
-                pic14_emitcode("pop","ar1");
-                _G.r1Pushed--;
-            }
-        }
-    }
-#endif
-
-dealloc:
     /* all other cases just dealloc */
-    if (op ) {
+    if (op) {
         op->aop = NULL;
         if (IS_SYMOP(op)) {
             OP_SYMBOL(op)->aop = NULL;
@@ -1016,6 +754,33 @@ dealloc:
     }
 }
 
+/*-----------------------------------------------------------------*/
+/* pic14aopLiteral - string from a literal value                   */
+/*-----------------------------------------------------------------*/
+static unsigned int pic14aopLiteral (value *val, int offset)
+{
+        union {
+                float f;
+                unsigned char c[4];
+        } fl;
+
+        /* if it is a float then it gets tricky */
+        /* otherwise it is fairly simple */
+        if (!IS_FLOAT(val->type)) {
+                unsigned long v = ulFromVal (val);
+
+                return ( (v >> (offset * 8)) & 0xff);
+        }
+
+        /* it is type float */
+        fl.f = (float) floatFromVal(val);
+#ifdef WORDS_BIGENDIAN
+        return fl.c[3-offset];
+#else
+        return fl.c[offset];
+#endif
+}
+
 /*-----------------------------------------------------------------*/
 /* aopGet - for fetching value of the aop                          */
 /*-----------------------------------------------------------------*/
@@ -1035,65 +800,6 @@ char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
     /* depending on type */
     switch (aop->type) {
 
-    case AOP_R0:
-    case AOP_R1:
-        DEBUGpic14_emitcode(";","%d",__LINE__);
-        /* if we need to increment it */
-        while (offset > aop->coff) {
-            pic14_emitcode ("inc","%s",aop->aopu.aop_ptr->name);
-            aop->coff++;
-        }
-
-        while (offset < aop->coff) {
-            pic14_emitcode("dec","%s",aop->aopu.aop_ptr->name);
-            aop->coff--;
-        }
-
-        aop->coff = offset ;
-        if (aop->paged) {
-            pic14_emitcode("movx","a,@%s",aop->aopu.aop_ptr->name);
-            return (dname ? "acc" : "a");
-        }
-        sprintf(s,"@%s",aop->aopu.aop_ptr->name);
-        rs = Safe_calloc(1,strlen(s)+1);
-        strcpy(rs,s);
-        return rs;
-
-    case AOP_DPTR:
-    case AOP_DPTR2:
-        DEBUGpic14_emitcode(";","%d",__LINE__);
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(1);
-        }
-
-        while (offset > aop->coff) {
-            pic14_emitcode ("inc","dptr");
-            aop->coff++;
-        }
-
-        while (offset < aop->coff) {
-            pic14_emitcode("lcall","__decdptr");
-            aop->coff--;
-        }
-
-        aop->coff = offset;
-        if (aop->code) {
-            pic14_emitcode("clr","a");
-            pic14_emitcode("movc","a,@a+dptr");
-        }
-        else {
-            pic14_emitcode("movx","a,@dptr");
-        }
-
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(0);
-        }
-
-        return (dname ? "acc" : "a");
-
-
     case AOP_IMMD:
         if (bit16)
             sprintf (s,"%s",aop->aopu.aop_immd);
@@ -1132,10 +838,6 @@ char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
         //pic14_emitcode(";","%d",__LINE__);
         return aop->aopu.aop_dir;
 
-    case AOP_ACC:
-        DEBUGpic14_emitcode(";Warning -pic port ignoring get(AOP_ACC)","%d",__LINE__);
-        return "AOP_accumulator_bug";
-
     case AOP_LIT:
         sprintf(s, "0x%02x", pic14aopLiteral (aop->aopu.aop_lit, offset));
         rs = Safe_strdup(s);
@@ -1180,11 +882,10 @@ char *aopGet (asmop *aop, int offset, bool bit16, bool dname)
   exit(0);
 }
 
-
 /*-----------------------------------------------------------------*/
 /* popGetTempReg - create a new temporary pCodeOp                  */
 /*-----------------------------------------------------------------*/
-pCodeOp *popGetTempReg(void)
+static pCodeOp *popGetTempReg(void)
 {
 
     pCodeOp *pcop;
@@ -1201,13 +902,14 @@ pCodeOp *popGetTempReg(void)
 /*-----------------------------------------------------------------*/
 /* popReleaseTempReg - create a new temporary pCodeOp                  */
 /*-----------------------------------------------------------------*/
-void popReleaseTempReg(pCodeOp *pcop)
+static void popReleaseTempReg(pCodeOp *pcop)
 {
 
     if(pcop && pcop->type == PO_GPR_TEMP && PCOR(pcop)->r)
         PCOR(pcop)->r->isFree = 1;
 
 }
+
 /*-----------------------------------------------------------------*/
 /* popGetLabel - create a new pCodeOp of type PO_LABEL             */
 /*-----------------------------------------------------------------*/
@@ -1225,7 +927,7 @@ pCodeOp *popGetLabel(unsigned int key)
 /*-------------------------------------------------------------------*/
 /* popGetHighLabel - create a new pCodeOp of type PO_LABEL with offset=1 */
 /*-------------------------------------------------------------------*/
-pCodeOp *popGetHighLabel(unsigned int key)
+static pCodeOp *popGetHighLabel(unsigned int key)
 {
     pCodeOp *pcop;
     pcop = popGetLabel(key);
@@ -1245,18 +947,16 @@ pCodeOp *popGetLit(unsigned int lit)
 /*-----------------------------------------------------------------*/
 /* popGetImmd - asm operator to pcode immediate conversion         */
 /*-----------------------------------------------------------------*/
-pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func)
+static pCodeOp *popGetImmd(char *name, unsigned int offset, int index,int is_func)
 {
 
     return newpCodeOpImmd(name, offset,index, 0, is_func);
 }
 
-extern set *externs;
-
 /*-----------------------------------------------------------------*/
 /* popGetWithString - asm operator to pcode operator conversion            */
 /*-----------------------------------------------------------------*/
-pCodeOp *popGetWithString(char *str, int isExtern)
+static pCodeOp *popGetWithString(char *str, int isExtern)
 {
     pCodeOp *pcop;
 
@@ -1304,7 +1004,7 @@ pCodeOp *popGetExternal (char *str, int isReg)
 /*-----------------------------------------------------------------*/
 /* popRegFromString -                                              */
 /*-----------------------------------------------------------------*/
-pCodeOp *popRegFromString(char *str, int size, int offset)
+static pCodeOp *popRegFromString(char *str, int size, int offset)
 {
 
     pCodeOp *pcop = Safe_calloc(1,sizeof(pCodeOpReg) );
@@ -1335,7 +1035,7 @@ pCodeOp *popRegFromString(char *str, int size, int offset)
 
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
-pCodeOp *popRegFromIdx(int rIdx)
+static pCodeOp *popRegFromIdx(int rIdx)
 {
     pCodeOp *pcop;
 
@@ -1384,38 +1084,12 @@ pCodeOp *popGet (asmop *aop, int offset) //, bool bit16, bool dname)
     /* depending on type */
     switch (aop->type) {
 
-    case AOP_R0:
-    case AOP_R1:
-    case AOP_DPTR:
-    case AOP_DPTR2:
-    case AOP_ACC:
-        DEBUGpic14_emitcode(";8051 legacy","%d type = %s",__LINE__,AopType(aop->type));
-        return NULL;
-
     case AOP_IMMD:
         DEBUGpic14_emitcode(";","%d",__LINE__);
         return popGetImmd(aop->aopu.aop_immd,offset,0,0);
 
     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:
         {
@@ -1449,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;
@@ -1570,22 +1235,6 @@ void aopPut (asmop *aop, char *s, int offset)
 
     case AOP_REG:
         if (strcmp(aop->aopu.aop_reg[offset]->name,s) != 0) {
-            //strcmp(aop->aopu.aop_reg[offset]->dname,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__);
 
@@ -1615,81 +1264,6 @@ void aopPut (asmop *aop, char *s, int offset)
         }
         break;
 
-    case AOP_DPTR:
-    case AOP_DPTR2:
-
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(1);
-        }
-
-        if (aop->code) {
-            werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
-                "aopPut writting to code space");
-            exit(0);
-        }
-
-        while (offset > aop->coff) {
-            aop->coff++;
-            pic14_emitcode ("inc","dptr");
-        }
-
-        while (offset < aop->coff) {
-            aop->coff-- ;
-            pic14_emitcode("lcall","__decdptr");
-        }
-
-        aop->coff = offset;
-
-        /* if not in accumulater */
-        MOVA(s);
-
-        pic14_emitcode ("movx","@dptr,a");
-
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(0);
-        }
-        break;
-
-    case AOP_R0:
-    case AOP_R1:
-        while (offset > aop->coff) {
-            aop->coff++;
-            pic14_emitcode("inc","%s",aop->aopu.aop_ptr->name);
-        }
-        while (offset < aop->coff) {
-            aop->coff-- ;
-            pic14_emitcode ("dec","%s",aop->aopu.aop_ptr->name);
-        }
-        aop->coff = offset;
-
-        if (aop->paged) {
-            MOVA(s);
-            pic14_emitcode("movx","@%s,a",aop->aopu.aop_ptr->name);
-
-        } else
-            if (*s == '@') {
-                MOVA(s);
-                pic14_emitcode("mov","@%s,a ; %d",aop->aopu.aop_ptr->name,__LINE__);
-            } else
-                if (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 ) {
-                    char buffer[10];
-                    sprintf(buffer,"a%s",s);
-                    pic14_emitcode("mov","@%s,%s",
-                        aop->aopu.aop_ptr->name,buffer);
-                } else
-                    pic14_emitcode("mov","@%s,%s",aop->aopu.aop_ptr->name,s);
-
-                break;
-
     case AOP_STK:
         if (strcmp(s,"a") == 0)
             pic14_emitcode("push","acc");
@@ -1733,15 +1307,6 @@ void aopPut (asmop *aop, char *s, int offset)
             pic14_emitcode ("mov","%s,%s ; %d",aop->aopu.aop_str[offset],s,__LINE__);
         break;
 
-    case AOP_ACC:
-        aop->coff = offset;
-        if (!offset && (strcmp(s,"acc") == 0))
-            break;
-
-        if (strcmp(aop->aopu.aop_str[offset],s))
-            pic14_emitcode ("mov","%s,%s ; %d",aop->aopu.aop_str[offset],s, __LINE__);
-        break;
-
     default :
         werror(E_INTERNAL_ERROR,__FILE__,__LINE__,
             "aopPut got unsupported aop->type");
@@ -1851,66 +1416,6 @@ static void call_libraryfunc (char *name)
     sym->used++;
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* reAdjustPreg - points a register back to where it should        */
-/*-----------------------------------------------------------------*/
-static void reAdjustPreg (asmop *aop)
-{
-    int size ;
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    aop->coff = 0;
-    if ((size = aop->size) <= 1)
-        return ;
-    size-- ;
-    switch (aop->type) {
-    case AOP_R0 :
-    case AOP_R1 :
-        while (size--)
-            pic14_emitcode("dec","%s",aop->aopu.aop_ptr->name);
-        break;
-    case AOP_DPTR :
-    case AOP_DPTR2:
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(1);
-        }
-        while (size--)
-        {
-            pic14_emitcode("lcall","__decdptr");
-        }
-
-        if (aop->type == AOP_DPTR2)
-        {
-            genSetDPTR(0);
-        }
-        break;
-
-    }
-
-}
-#endif
-
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* opIsGptr: returns non-zero if the passed operand is             */
-/* a generic pointer type.                                         */
-/*-----------------------------------------------------------------*/
-static int opIsGptr(operand *op)
-{
-    sym_link *type = operandType(op);
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if ((AOP_SIZE(op) == GPTRSIZE) && IS_GENPTR(type))
-    {
-        return 1;
-    }
-    return 0;
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* pic14_getDataSize - get the operand data size                   */
 /*-----------------------------------------------------------------*/
@@ -1929,7 +1434,7 @@ int pic14_getDataSize(operand *op)
     // fails. ( in the 8051 port, the size was 4).
 #else
     size = AOP_SIZE(op);
-    if (IS_GENPTR(OP_SYM_TYPE(op)))
+    if (IS_SYMOP(op) && IS_GENPTR(OP_SYM_TYPE(op)))
     {
         sym_link *type = operandType(op);
         if (IS_GENPTR(type))
@@ -1970,7 +1475,7 @@ void pic14_outAcc(operand *result)
 /*-----------------------------------------------------------------*/
 /* pic14_outBitC - output a bit C                                  */
 /*-----------------------------------------------------------------*/
-void pic14_outBitC(operand *result)
+static void pic14_outBitC(operand *result)
 {
 
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
@@ -1987,7 +1492,7 @@ void pic14_outBitC(operand *result)
 /*-----------------------------------------------------------------*/
 /* pic14_toBoolean - emit code for orl a,operator(sizeop)          */
 /*-----------------------------------------------------------------*/
-void pic14_toBoolean(operand *oper)
+static void pic14_toBoolean(operand *oper)
 {
     int size = AOP_SIZE(oper);
     int offset = 0;
@@ -1998,18 +1503,11 @@ void pic14_toBoolean(operand *oper)
 
     if (size == 1) {
         /* MOVFW does not load the flags... */
-        if (AOP_TYPE(oper) == AOP_ACC) {
-            emitpcode(POC_IORLW, popGetLit(0));
-            offset = 1;
-        } else {
-            emitpcode(POC_MOVLW, popGetLit(0));
-            offset = 0;
-        }
+        emitpcode(POC_MOVLW, popGetLit(0));
+        offset = 0;
     } else {
-        if ( AOP_TYPE(oper) != AOP_ACC) {
-            emitpcode(POC_MOVFW,popGet(AOP(oper),0));
-            offset = 1;
-        }
+        emitpcode(POC_MOVFW,popGet(AOP(oper),0));
+        offset = 1;
     }
 
     while (offset < size) {
@@ -2103,12 +1601,7 @@ static void genCpl (iCode *ic)
     size = AOP_SIZE(result);
     if (AOP_SIZE(left) < size) size = AOP_SIZE(left);
     while (size--) {
-
-        if(AOP_TYPE(left) == AOP_ACC)
-            emitpcode(POC_XORLW, popGetLit(0xff));
-        else
-            emitpcode(POC_COMFW,popGet(AOP(left),offset));
-
+        emitpcode(POC_COMFW,popGet(AOP(left),offset));
         emitpcode(POC_MOVWF,popGet(AOP(result),offset));
         offset++;
     }
@@ -2124,30 +1617,27 @@ release:
 /*-----------------------------------------------------------------*/
 /* genUminusFloat - unary minus for floating points                */
 /*-----------------------------------------------------------------*/
-static void genUminusFloat(operand *op,operand *result)
+static void
+genUminusFloat(operand *op, operand *result)
 {
-    int size ,offset =0 ;
-    char *l;
-
-    FENTRY;
+  int size;
 
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* for this we just need to flip the
-    first it then copy the rest in place */
-    size = AOP_SIZE(op) - 1;
-    l = aopGet(AOP(op),3,FALSE,FALSE);
+  FENTRY;
 
-    MOVA(l);
+  DEBUGpic14_emitcode("; ***", "%s  %d", __FUNCTION__, __LINE__);
+  /* for this we just need to flip the
+     first it then copy the rest in place */
+  size = AOP_SIZE(op) - 1;
 
-    pic14_emitcode("cpl","acc.7");
-    aopPut(AOP(result),"a",3);
+  mov2w_op(op, size);
+  emitpcode(POC_XORLW, popGetLit(0x80));
+  movwf(AOP(result), size);
 
-    while(size--) {
-        aopPut(AOP(result),
-            aopGet(AOP(op),offset,FALSE,FALSE),
-            offset);
-        offset++;
-    }
+  while (size--)
+    {
+      mov2w_op(op, size);
+      movwf(AOP(result), size);
+    } // while
 }
 
 /*-----------------------------------------------------------------*/
@@ -2210,12 +1700,61 @@ release:
     freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
 }
 
+/*-----------------------------------------------------------------*/
+/* saverbank - saves an entire register bank on the stack          */
+/*-----------------------------------------------------------------*/
+static void saverbank (int bank, iCode *ic, bool pushPsw)
+{
+    FENTRY;
+
+    DEBUGpic14_emitcode ("; ***","%s  %d - WARNING no code generated",__FUNCTION__,__LINE__);
+#if 0
+    int i;
+    asmop *aop ;
+    regs *r = NULL;
+
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    if (options.useXstack) {
+
+        aop = newAsmop(0);
+        r = getFreePtr(ic,&aop,FALSE);
+        pic14_emitcode("mov","%s,_spx",r->name);
+
+    }
+
+    for (i = 0 ; i < pic14_nRegs ;i++) {
+        if (options.useXstack) {
+            pic14_emitcode("inc","%s",r->name);
+            //pic14_emitcode("mov","a,(%s+%d)",
+            //       regspic14[i].base,8*bank+regspic14[i].offset);
+            pic14_emitcode("movx","@%s,a",r->name);
+        } else
+            pic14_emitcode("push","");// "(%s+%d)",
+        //regspic14[i].base,8*bank+regspic14[i].offset);
+    }
+
+    if (pushPsw) {
+        if (options.useXstack) {
+            pic14_emitcode("mov","a,psw");
+            pic14_emitcode("movx","@%s,a",r->name);
+            pic14_emitcode("inc","%s",r->name);
+            pic14_emitcode("mov","_spx,%s",r->name);
+            freeAsmop (NULL,aop,ic,TRUE);
+
+        } else
+            pic14_emitcode("push","psw");
+
+        pic14_emitcode("mov","psw,#0x%02x",(bank << 3)&0x00ff);
+    }
+    ic->bankSaved = 1;
+#endif
+}
+
 /*-----------------------------------------------------------------*/
 /* saveRegisters - will look for a call and save the registers     */
 /*-----------------------------------------------------------------*/
 static void saveRegisters(iCode *lic)
 {
-    int i;
     iCode *ic;
     bitVect *rsave;
     sym_link *dtype;
@@ -2244,28 +1783,8 @@ static void saveRegisters(iCode *lic)
             ic->rUsed);
 
         ic->regsSaved = 1;
-        if (options.useXstack) {
-            if (bitVectBitValue(rsave,R0_IDX))
-                pic14_emitcode("mov","b,r0");
-            pic14_emitcode("mov","r0,%s",spname);
-            for (i = 0 ; i < pic14_nRegs ; i++) {
-                if (bitVectBitValue(rsave,i)) {
-                    if (i == R0_IDX)
-                        pic14_emitcode("mov","a,b");
-                    else
-                        pic14_emitcode("mov","a,%s",pic14_regWithIdx(i)->name);
-                    pic14_emitcode("movx","@r0,a");
-                    pic14_emitcode("inc","r0");
-                }
-            }
-            pic14_emitcode("mov","%s,r0",spname);
-            if (bitVectBitValue(rsave,R0_IDX))
-                pic14_emitcode("mov","r0,b");
-        }// else
-        //for (i = 0 ; i < pic14_nRegs ; i++) {
-        //    if (bitVectBitValue(rsave,i))
-        //  pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
-        //}
+
+        //fprintf(stderr, "ERROR: saveRegisters did not do anything to save registers, please report this as a bug.\n");
 
         dtype = operandType(IC_LEFT(ic));
         if (currFunc && dtype &&
@@ -2298,16 +1817,11 @@ static void unsaveRegisters (iCode *ic)
             if (bitVectBitValue(rsave,i)) {
                 pic14_emitcode("dec","r0");
                 pic14_emitcode("movx","a,@r0");
-                if (i == R0_IDX)
-                    pic14_emitcode("mov","b,a");
-                else
-                    pic14_emitcode("mov","%s,a",pic14_regWithIdx(i)->name);
+                pic14_emitcode("mov","%s,a",pic14_regWithIdx(i)->name);
             }
 
         }
         pic14_emitcode("mov","%s,r0",spname);
-        if (bitVectBitValue(rsave,R0_IDX))
-            pic14_emitcode("mov","r0,b");
     } //else
     //for (i =  pic14_nRegs ; i >= 0 ; i--) {
     //  if (bitVectBitValue(rsave,i))
@@ -2500,56 +2014,6 @@ static void unsaverbank (int bank,iCode *ic,bool popPsw)
 #endif
 }
 
-/*-----------------------------------------------------------------*/
-/* saverbank - saves an entire register bank on the stack          */
-/*-----------------------------------------------------------------*/
-static void saverbank (int bank, iCode *ic, bool pushPsw)
-{
-    FENTRY;
-
-    DEBUGpic14_emitcode ("; ***","%s  %d - WARNING no code generated",__FUNCTION__,__LINE__);
-#if 0
-    int i;
-    asmop *aop ;
-    regs *r = NULL;
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if (options.useXstack) {
-
-        aop = newAsmop(0);
-        r = getFreePtr(ic,&aop,FALSE);
-        pic14_emitcode("mov","%s,_spx",r->name);
-
-    }
-
-    for (i = 0 ; i < pic14_nRegs ;i++) {
-        if (options.useXstack) {
-            pic14_emitcode("inc","%s",r->name);
-            //pic14_emitcode("mov","a,(%s+%d)",
-            //       regspic14[i].base,8*bank+regspic14[i].offset);
-            pic14_emitcode("movx","@%s,a",r->name);
-        } else
-            pic14_emitcode("push","");// "(%s+%d)",
-        //regspic14[i].base,8*bank+regspic14[i].offset);
-    }
-
-    if (pushPsw) {
-        if (options.useXstack) {
-            pic14_emitcode("mov","a,psw");
-            pic14_emitcode("movx","@%s,a",r->name);
-            pic14_emitcode("inc","%s",r->name);
-            pic14_emitcode("mov","_spx,%s",r->name);
-            freeAsmop (NULL,aop,ic,TRUE);
-
-        } else
-            pic14_emitcode("push","psw");
-
-        pic14_emitcode("mov","psw,#0x%02x",(bank << 3)&0x00ff);
-    }
-    ic->bankSaved = 1;
-#endif
-}
-
 /*-----------------------------------------------------------------*/
 /* genCall - generates a call statement                            */
 /*-----------------------------------------------------------------*/
@@ -2805,29 +2269,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                 */
 /*-----------------------------------------------------------------*/
@@ -2922,8 +2363,7 @@ static void genFunction (iCode *ic)
             if (sym->regsUsed) {
                 /* save the registers used */
                 for ( i = 0 ; i < sym->regsUsed->size ; i++) {
-                    if (bitVectBitValue(sym->regsUsed,i) ||
-                        (pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) ) {
+                    if (bitVectBitValue(sym->regsUsed,i)) {
                         //pic14_emitcode("push","%s",pic14_regWithIdx(i)->dname);
                         _G.nRegsSaved++;
                     }
@@ -3043,16 +2483,16 @@ registers :-) */
                 if (sym->regsUsed) {
                     /* save the registers used */
                     for ( i = sym->regsUsed->size ; i >= 0 ; i--) {
-                        if (bitVectBitValue(sym->regsUsed,i) ||
-                            (pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) )
+                        if (bitVectBitValue(sym->regsUsed,i)) {
                             pic14_emitcode("pop","junk");//"%s",pic14_regWithIdx(i)->dname);
+                        }
                     }
                 }
 
             } else {
-            /* this function has    a function call cannot
-            determines register usage so we will have the
-                entire bank */
+                /* this function has a function call; cannot
+                   determines register usage so we will have the
+                   entire bank */
                 unsaverbank(0,ic,FALSE);
             }
         }
@@ -3087,12 +2527,11 @@ registers :-) */
             if (sym->regsUsed) {
                 /* save the registers used */
                 for ( i = sym->regsUsed->size ; i >= 0 ; i--) {
-                    if (bitVectBitValue(sym->regsUsed,i) ||
-                        (pic14_ptrRegReq && (i == R0_IDX || i == R1_IDX)) )
+                    if (bitVectBitValue(sym->regsUsed,i)) {
                         pic14_emitcode("pop","junk");//"%s",pic14_regWithIdx(i)->dname);
+                    }
                 }
             }
-
         }
 
         /* if debug then send end of function */
@@ -3623,59 +3062,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                                                        */
 /*-----------------------------------------------------------------*/
@@ -3695,104 +3081,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
@@ -3802,7 +3090,8 @@ static int genChkZeroes(operand *op, int lit,  int size)
 /*                  aop (if it's NOT a literal) or from lit (if    */
 /*                  aop is a literal)                              */
 /*-----------------------------------------------------------------*/
-void pic14_mov2w_regOrLit (asmop *aop, unsigned long lit, int offset) {
+static void pic14_mov2w_regOrLit (asmop *aop, unsigned long lit, int offset)
+{
   if (aop->type == AOP_LIT) {
     emitpcode (POC_MOVLW, popGetLit((lit >> (offset*8)) & 0x00FF));
   } else {
@@ -4023,4159 +3312,1651 @@ 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
-
-    /* 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
+    left = IC_LEFT(ic);
+    right= IC_RIGHT(ic);
+    result = IC_RESULT(ic);
 
-        lit = (lit - 1) & mask;
-        right = left;
-        left = tmp;
-        rFalseIfx.condition ^= 1;
-#endif
+    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);
 
-    } else if ((AOP_TYPE(left) == AOP_LIT)) {
-        lit = ulFromVal(AOP(left)->aopu.aop_lit);
-    }
+    genCmp(right, left, result, ifx, sign);
 
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-    //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 */
+/*-----------------------------------------------------------------*/
+/* genCmpLt - less than comparisons                                */
+/*-----------------------------------------------------------------*/
+static void genCmpLt (iCode *ic, iCode *ifx)
+{
+    operand *left, *right, *result;
+    sym_link *letype , *retype;
+    int sign ;
 
-        symbol *lbl  = newiTempLabel(NULL);
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    left = IC_LEFT(ic);
+    right= IC_RIGHT(ic);
+    result = IC_RESULT(ic);
 
-#ifndef _swapp
-        if(AOP_TYPE(right) == AOP_LIT) {
+    letype = getSpec(operandType(left));
+    retype =getSpec(operandType(right));
+    sign =  !(SPEC_USIGN(letype) | SPEC_USIGN(retype));
 
-            //lit = ulFromVal(AOP(right)->aopu.aop_lit);
+    /* assign the amsops */
+    aopOp (left,ic,FALSE);
+    aopOp (right,ic,FALSE);
+    aopOp (result,ic,TRUE);
 
-            DEBUGpic14_emitcode(";right lit","lit = 0x%x,sign=%d",lit,sign);
+    genCmp(left, right, result, ifx, sign);
 
-            /* special cases */
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-            if(lit == 0) {
+/*-----------------------------------------------------------------*/
+/* genCmpEq - generates code for equal to                          */
+/*-----------------------------------------------------------------*/
+static void genCmpEq (iCode *ic, iCode *ifx)
+{
+  operand *left, *right, *result;
+  int size;
+  symbol *false_label;
 
-                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));
+  FENTRY;
+  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-                if(ifx) ifx->generated = 1;
-                return;
+  if(ifx)
+    DEBUGpic14_emitcode ("; ifx is non-null","");
+  else
+    DEBUGpic14_emitcode ("; ifx is null","");
 
-            }
-            size--;
+  aopOp((left=IC_LEFT(ic)),ic,FALSE);
+  aopOp((right=IC_RIGHT(ic)),ic,FALSE);
+  aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
-            if(size == 0) {
-                //i = (lit >> (size*8)) & 0xff;
-                DEBUGpic14_emitcode(";right lit","line = %d",__LINE__);
+  DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                emitpcode(POC_MOVFW, popGet(AOP(left),size));
+  /* if literal, move literal to right */
+  if (op_isLitLike (IC_LEFT(ic))) {
+    operand *tmp = right ;
+    right = left;
+    left = tmp;
+  }
 
-                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" );
-                    }
+  false_label = NULL;
+  if (ifx && !IC_TRUE(ifx))
+  {
+    assert (IC_FALSE(ifx));
+    false_label = IC_FALSE(ifx);
+  }
 
-                } else {
-                    if(lit == 1) {
-                        genSkipz2(&rFalseIfx,1);
-                    } else {
-                        emitpcode(POC_ADDLW, popGetLit(i));
-                        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)));
 
-                if(ifx) ifx->generated = 1;
-                return;
-            }
+  /* assume left != right */
+  {
+    int i;
+    for (i=0; i < AOP_SIZE(result); i++)
+    {
+      emitpcode(POC_CLRF, popGet(AOP(result),i));
+    }
+  }
 
-            /* chars are out of the way. now do ints and longs */
+  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;
 
-            DEBUGpic14_emitcode(";right lit","line = %d",__LINE__);
+      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;
 
-            /* special cases */
+    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(sign) {
+  /* if we reach here, left == right */
 
-                if(lit == 0) {
-                    genSkipCond(&rFalseIfx,left,size,7);
-                    if(ifx) ifx->generated = 1;
-                    return;
-                }
+  if (AOP_SIZE(result) > 0)
+  {
+    emitpcode(POC_INCF, popGet(AOP(result),0));
+  }
 
-                if(lit <0x100) {
-                    DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+  if (ifx && IC_TRUE(ifx))
+  {
+    emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
+  }
 
-                    //rFalseIfx.condition ^= 1;
-                    //genSkipCond(&rFalseIfx,left,size,7);
-                    //rFalseIfx.condition ^= 1;
+  if (false_label && (!ifx || IC_TRUE(ifx)))
+    emitpLabel(false_label->key);
 
-                    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 (ifx) ifx->generated = 1;
 
-                    emitpcode(POC_MOVLW, popGetLit(0x100-lit));
-                    emitpcode(POC_ADDFW, popGet(AOP(left),0));
-                    emitpcode(POC_MOVFW, popGet(AOP(left),1));
+  freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+  freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+  freeAsmop(result,NULL,ic,TRUE);
+}
 
-                    while(size > 1)
-                        emitpcode(POC_IORFW, popGet(AOP(left),size--));
+/*-----------------------------------------------------------------*/
+/* 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(rFalseIfx.condition) {
-                        emitSKPZ;
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
+    /* 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;
 
-                    } else {
-                        emitSKPNZ;
-                    }
+    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;
+    }
 
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-                    emitpLabel(truelbl->key);
-                    if(ifx) ifx->generated = 1;
-                    return;
+    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);
+    }
 
-                if(size == 1) {
 
-                    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" );
+    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);
 
-                        if(ifx) ifx->generated = 1;
-                        return;
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                    }
-                } 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" );
+    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(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);
+}
 
-                    }
 
-                }
-
-
-                if(lit & (0x80 << (size*8))) {
-                    /* lit is negative */
-                    DEBUGpic14_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+/*-----------------------------------------------------------------*/
+/* genOrOp - for || operation                                      */
+/*-----------------------------------------------------------------*/
+/*
+tsd pic port -
+modified this code, but it doesn't appear to ever get called
+*/
 
-                    //genSkipCond(&rFalseIfx,left,size,7);
+static void genOrOp (iCode *ic)
+{
+    operand *left,*right, *result;
+    symbol *tlbl;
+    int i;
 
-                    emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(left),size,FALSE,FALSE),7,0));
+    /* 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);
 
-                    if(rFalseIfx.condition)
-                        emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-                    else
-                        emitpcode(POC_GOTO,  popGetLabel(rFalseIfx.lbl->key));
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
+    for (i=0; i < AOP_SIZE(result); i++)
+    {
+        emitpcode(POC_CLRF, popGet(AOP(result), i));
+    } // for i
 
-                } 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));
+    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);
+}
 
-                /* There are no more special cases, so perform a general compare */
+/*-----------------------------------------------------------------*/
+/* 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));
-                emitpcode(POC_SUBFW, popGet(AOP(left),size));
+    FENTRY;
+    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    for(idx = 0; idx < 32; idx++)
+        if(lit == pw[idx])
+            return idx+1;
+        return 0;
+}
 
-                while(size--) {
+/*-----------------------------------------------------------------*/
+/* 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;
+}
 
-                    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" );
+/*-----------------------------------------------------------------*/
+/* 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;
+}
 
-                emitpLabel(truelbl->key);
+/*-----------------------------------------------------------------*/
+/* 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;
+}
 
-                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;
 
+    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;
+    }
 
-            /* 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);
+    /* 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);
 
-            /* General case - compare to an unsigned literal on the right.*/
+    size = AOP_SIZE(result);
 
-            i = (lit >> (size*8)) & 0xff;
-            emitpcode(POC_MOVLW, popGetLit(i));
-            emitpcode(POC_SUBFW, popGet(AOP(left),size));
-            while(size--) {
-                i = (lit >> (size*8)) & 0xff;
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-                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));
+    // 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");
             }
-
-
-        emitpLabel(lbl->key);
-        //if(emitFinalCheck)
-        genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-        if(sign)
-            emitpLabel(truelbl->key);
-
-        if(ifx) ifx->generated = 1;
-        return;
-
-
-        }
-#endif  // _swapp
-
-        if(AOP_TYPE(left) == AOP_LIT) {
-            //symbol *lbl = newiTempLabel(NULL);
-
-            //EXPERIMENTAL lit = ulFromVal(AOP(left)->aopu.aop_lit);
-
-
-            DEBUGpic14_emitcode(";left lit","lit = 0x%x,sign=%d",lit,sign);
-
-            /* Special cases */
-            if((lit == 0) && (sign == 0)){
-
-                size--;
-                emitpcode(POC_MOVFW, popGet(AOP(right),size));
-                while(size)
-                    emitpcode(POC_IORFW, popGet(AOP(right),--size));
-
-                genSkipz2(&rFalseIfx,0);
-                if(ifx) ifx->generated = 1;
-                return;
+        } 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(ifx) ifx->generated = 1;
-                    return;
-                }
-
-                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;
+    // 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++;
                     }
-                    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;
+                    emitpcode(((rIfx.condition) ? POC_BTFSC : POC_BTFSS),
+                        newpCodeOpBit(aopGet(AOP(left),offset,FALSE,FALSE),posbit,0));
+                    emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
 
-                    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));
-                        }
-                        break;
-                    }
+                    ifx->generated = 1;
                 }
-
-                //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;
-                    }
-
-                    if(lit == 0) {
-                        int s = size;
-
-                        if(rFalseIfx.condition) {
-                            emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
-                            emitpcode(POC_GOTO,  popGetLabel(truelbl->key));
-                        }
-
-                        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));
-                            emitpLabel(truelbl->key);
-                        }else {
-                            rFalseIfx.condition ^= 1;
-                            genSkipCond(&rFalseIfx,right,s,7);
-                        }
-
-                        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;
-                    }
-
-                    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));
+                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);
                     }
-                    rFalseIfx.condition ^= 1;
-                    //rFalseIfx.condition = 1;
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
-
-                    emitpLabel(truelbl->key);
-
-                    if(ifx) ifx->generated = 1;
-                    return;
-                    // end of if (sign)
-                } else {
+                    else{
+                        emitpcode(POC_ANDLW, newpCodeOpLit(bytelit & 0x0ff));
+                        if (rIfx.condition) emitSKPZ;
+                        else emitSKPNZ;
 
-                    /* 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" );
+                        if(bytelit != 0x0FFL)
+                        {
+                            pic14_emitcode("anl","a,%s",
+                            aopGet(AOP(right),offset,FALSE,TRUE));
                         }
-
-                        emitpLabel(truelbl->key);
-
-                        if(ifx) ifx->generated = 1;
-                        return;
+                        pic14_emitcode("jnz","%05d_DS_",tlbl->key+100);
                     }
 
+                    emitpcode(POC_GOTO, popGetLabel(rIfx.lbl->key));
+                    ifx->generated = 1;
 
-                    lit++;
-                    DEBUGpic14_emitcode ("; ***","%s  %d lit =0x%x",__FUNCTION__,__LINE__,lit);
-                    i = (lit >> (size*8)) & 0xff;
+                }
+                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_MOVLW, popGetLit(i));
-                    emitpcode(POC_SUBFW, 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;
 
-                    while(size--) {
-                        i = (lit >> (size*8)) & 0xff;
+                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));
 
-                        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));
+                            if(know_W != (int)(lit&0xff))
+                                emitpcode(POC_MOVLW, popGetLit(lit & 0xff));
+                            know_W = lit &0xff;
+                            emitpcode(POC_ANDWF,popGet(AOP(left),offset));
                         }
                     }
-
-
-                    emitpLabel(lbl->key);
-
-                    rFalseIfx.condition ^= 1;
-                    genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
                 }
-
-                if(sign)
-                    emitpLabel(truelbl->key);
-                if(ifx) ifx->generated = 1;
-                return;
+            } else {
+                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+                emitpcode(POC_ANDWF,popGet(AOP(left),offset));
             }
         }
-        /* 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;
+    } 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),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--;
-
-            emitpcode(POC_MOVFW, popGet(AOP(right),size));
-            emitpcode(POC_SUBFW, popGet(AOP(left),size));
-
-
-        }
-
-        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));
-        } else {
-            genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
+                emitpcode(POC_ANDFW,popGet(AOP(left),offset));
+                emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+            }
         }
-        //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 */
     }
 
-}
-#endif
-
-/*-----------------------------------------------------------------*/
-/* genCmpGt :- greater than comparison                             */
-/*-----------------------------------------------------------------*/
-static void genCmpGt (iCode *ic, iCode *ifx)
-{
-    operand *left, *right, *result;
-    sym_link *letype , *retype;
-    int sign ;
-
-    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(right, left, result, ifx, sign);
-
+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                                */
+/* genOr  - code for or                                            */
 /*-----------------------------------------------------------------*/
-static void genCmpLt (iCode *ic, iCode *ifx)
+static void genOr (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));
+    aopOp((left = IC_LEFT(ic)),ic,FALSE);
+    aopOp((right= IC_RIGHT(ic)),ic,FALSE);
+    aopOp((result=IC_RESULT(ic)),ic,TRUE);
 
-    /* assign the amsops */
-    aopOp (left,ic,FALSE);
-    aopOp (right,ic,FALSE);
-    aopOp (result,ic,TRUE);
+    DEBUGpic14_AopType(__LINE__,left,right,result);
 
-    genCmp(left, right, result, ifx, sign);
+    /* 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;
+    }
 
-    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
-    freeAsmop(result,NULL,ic,TRUE);
-}
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genc16bit2lit - compare a 16 bit value to a literal             */
-/*-----------------------------------------------------------------*/
-static void genc16bit2lit(operand *op, int lit, int offset)
-{
-    int i;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d, lit = %d",__FUNCTION__,__LINE__,lit);
-    if( (lit&0xff) == 0)
-        i=1;
-    else
-        i=0;
-
-    switch( BYTEofLONG(lit,i)) {
-    case 0:
-        emitpcode(POC_MOVFW,popGet(AOP(op),offset+i));
-        break;
-    case 1:
-        emitpcode(POC_DECFW,popGet(AOP(op),offset+i));
-        break;
-    case 0xff:
-        emitpcode(POC_INCFW,popGet(AOP(op),offset+i));
-        break;
-    default:
-        emitpcode(POC_MOVFW,popGet(AOP(op),offset+i));
-        emitpcode(POC_XORLW,popGetLit(BYTEofLONG(lit,i)));
+    /* if result = right then exchange them */
+    if(pic14_sameRegs(AOP(result),AOP(right))){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
     }
 
-    i ^= 1;
-
-    switch( BYTEofLONG(lit,i)) {
-    case 0:
-        emitpcode(POC_IORFW,popGet(AOP(op),offset+i));
-        break;
-    case 1:
-        emitSKPNZ;
-        emitpcode(POC_DECFW,popGet(AOP(op),offset+i));
-        break;
-    case 0xff:
-        emitSKPNZ;
-        emitpcode(POC_INCFW,popGet(AOP(op),offset+i));
-        break;
-    default:
-        emitpcode(POC_MOVLW,popGetLit(BYTEofLONG(lit,i)));
-        emitSKPNZ;
-        emitpcode(POC_XORFW,popGet(AOP(op),offset+i));
-
+    /* 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;
     }
 
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* gencjneshort - compare and jump if not equal                    */
-/*-----------------------------------------------------------------*/
-static void gencjne(operand *left, operand *right, operand *result, iCode *ifx)
-{
-    int size = min(AOP_SIZE(left),AOP_SIZE(right));
-    int offset = 0;
-    //resolvedIfx rIfx;
-    symbol *lbl;
-
-    //unsigned long lit = 0L;
-    FENTRY;
-    if (!ifx && (!result || AOP_TYPE(result) == AOP_CRY)) {
-      emitpComment ("gencjne: no ifx, no (real) result -- comparison ignored");
-      return;
-    }
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
     DEBUGpic14_AopType(__LINE__,left,right,result);
 
-    assert (!pic14_sameRegs (AOP(left), AOP(result)));
-    assert (!pic14_sameRegs (AOP(right), AOP(result)));
-    if (AOP_SIZE(result)) {
-      for (offset = 0; offset < AOP_SIZE(result); offset++)
-        emitpcode (POC_CLRF, popGet (AOP(result), offset));
-    }
-
-    assert (AOP_SIZE(left) == AOP_SIZE(right));
-    //resolveIfx(&rIfx,ifx);
-    lbl = newiTempLabel (NULL);
-    while (size--)
-    {
-      mov2w (AOP(right),size);
-      emitpcode (POC_XORFW, popGet (AOP(left), size));
-      if (size)
-      {
-        emitSKPZ;
-        emitpcode (POC_GOTO, popGetLabel (lbl->key));
-      }
-    } // while
-    emitpLabel (lbl->key);
-    if (AOP_SIZE(result)) {
-      emitSKPNZ;
-      emitpcode (POC_INCF, popGet (AOP(result), 0));
-    } else {
-      assert (ifx);
-      genSkipz (ifx, NULL != IC_TRUE(ifx));
-      ifx->generated = 1;
-    }
-    return;
-#if 0
-    if(result)
-    {
-        DEBUGpic14_emitcode ("; ***","%s  %d result is not null",__FUNCTION__,__LINE__);
-        assert (!pic14_sameRegs (AOP(result), AOP(left)));
-        assert (!pic14_sameRegs (AOP(result), AOP(right)));
-        for (offset=0; offset < AOP_SIZE(result); offset++)
-        {
-            emitpcode (POC_CLRF, popGet (AOP(result), offset));
-        } // for offset
-    }
+    if(AOP_TYPE(right) == AOP_LIT)
+        lit = ulFromVal (AOP(right)->aopu.aop_lit);
 
+    size = AOP_SIZE(result);
 
-    /* if the left side is a literal or
-    if the right is in a pointer register and left
-    is not */
-    if ((AOP_TYPE(left) == AOP_LIT) ||
-        (IS_AOP_PREG(right) && !IS_AOP_PREG(left))) {
-        operand *t = right;
-        right = left;
-        left = t;
-    }
-    if(AOP_TYPE(right) == AOP_LIT)
-        lit = ulFromVal(AOP(right)->aopu.aop_lit);
-
-    /* if the right side is a literal then anything goes */
-    if (AOP_TYPE(right) == AOP_LIT &&
-        AOP_TYPE(left) != AOP_DIR ) {
-        switch(size) {
-        case 2:
-            genc16bit2lit(left, lit, 0);
-            emitSKPNZ;
-            emitpcode(POC_GOTO,popGetLabel(lbl->key));
-            break;
-        default:
-            offset = 0;
-            while (size--) {
-                if(lit & 0xff) {
-                    emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                    emitpcode(POC_XORLW,popGetLit(lit & 0xff));
-                } else {
-                    emitpcode(POC_MOVF,popGet(AOP(left),offset));
+    // 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;
                 }
-
-                emitSKPNZ;
-                emitpcode(POC_GOTO,popGetLabel(lbl->key));
-                offset++;
-                lit >>= 8;
+            } 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__);
             }
-            break;
-        }
-    }
-
-    /* if the right side is in a register or in direct space or
-    if the left is a pointer register & right is not */
-    else if (AOP_TYPE(right) == AOP_REG ||
-        AOP_TYPE(right) == AOP_DIR ||
-        (AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) ||
-        (IS_AOP_PREG(left) && !IS_AOP_PREG(right))) {
-        //int lbl_key = (rIfx.condition) ? rIfx.lbl->key : lbl->key;
-        int lbl_key = lbl->key;
-
-        if(!result) {
-            DEBUGpic14_emitcode ("; ***","%s  %d -- ERROR",__FUNCTION__,__LINE__);
-            fprintf(stderr, "%s  %d error - expecting result to be non_null\n",
-                __FUNCTION__,__LINE__);
-            return;
-        }
-
-        /*     switch(size) { */
-        /*     case 2: */
-        /*       genc16bit2lit(left, lit, 0); */
-        /*       emitSKPNZ; */
-        /*       emitpcode(POC_GOTO,popGetLabel(lbl->key)); */
-        /*       break; */
-        /*     default: */
-        offset = 0;
-        while (size--) {
-            int emit_skip=1;
-            if((AOP_TYPE(left) == AOP_DIR) &&
-                ((AOP_TYPE(right) == AOP_REG) || (AOP_TYPE(right) == AOP_DIR))) {
+        } 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(left),offset));
-                emitpcode(POC_XORFW,popGet(AOP(right),offset));
+                    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__);
 
-            } else if((AOP_TYPE(left) == AOP_DIR) && (AOP_TYPE(right) == AOP_LIT)){
 
-                switch (lit & 0xff) {
-                case 0:
-                    emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                    break;
-                case 1:
-                    emitpcode(POC_DECFSZW,popGet(AOP(left),offset));
-                    //emitpcode(POC_INCF,popGet(AOP(result),res_offset));
-                    emitpcode(POC_GOTO,popGetLabel(lbl->key));
-                    emit_skip=0;
-                    break;
-                case 0xff:
-                    emitpcode(POC_INCFSZW,popGet(AOP(left),offset));
-                    //emitpcode(POC_INCF,popGet(AOP(result),res_offset));
-                    //emitpcode(POC_INCFSZW,popGet(AOP(left),offset));
-                    emitpcode(POC_GOTO,popGetLabel(lbl_key));
-                    emit_skip=0;
-                    break;
-                default:
-                    emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                    emitpcode(POC_XORLW,popGetLit(lit & 0xff));
-                }
-                lit >>= 8;
+                emitpcode(POC_BCF,   popGet(AOP(result),0));
 
-            } else {
-                emitpcode(POC_MOVF,popGet(AOP(left),offset));
-            }
-            if(emit_skip) {
-                if(AOP_TYPE(result) == AOP_CRY) {
-                    pic14_emitcode(";***","%s  %d",__FUNCTION__,__LINE__);
-                    if(rIfx.condition)
-                        emitSKPNZ;
-                    else
-                        emitSKPZ;
-                    emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
+                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 {
-                    /* fix me. probably need to check result size too */
-                    //emitpcode(POC_CLRF,popGet(AOP(result),0));
-                    if(rIfx.condition)
-                        emitSKPZ;
-                    else
-                        emitSKPNZ;
-                    emitpcode(POC_GOTO,popGetLabel(lbl_key));
+                    CLRC;
+                    pic14_emitcode("","%05d_DS_:",tlbl->key+100);
                 }
-                if(ifx)
-                    ifx->generated=1;
             }
-            emit_skip++;
-            offset++;
         }
-        /*       break; */
-        /*     } */
-    } else if(AOP_TYPE(right) == AOP_REG &&
-        AOP_TYPE(left) != 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 ;
+    }
 
-        offset = 0;
-        while(size--) {
-            emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-            emitpcode(POC_XORFW,popGet(AOP(right),offset));
-            pic14_emitcode(";***","%s  %d",__FUNCTION__,__LINE__);
-            if(rIfx.condition)
-                emitSKPNZ;
+    // 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
-                emitSKPZ;
-            emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
-            offset++;
-        }
-
-    }else{
-        /* right is a pointer reg need both a & b */
-        offset = 0;
-        while(size--) {
-            char *l = aopGet(AOP(left),offset,FALSE,FALSE);
-            if(strcmp(l,"b"))
-                pic14_emitcode("mov","b,%s",l);
-            MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
-            pic14_emitcode("cjne","a,b,%05d_DS_",lbl->key+100);
-            offset++;
+                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 ;
     }
 
-    emitpcode(POC_INCF,popGet(AOP(result),0));
-    if(!rIfx.condition)
-        emitpcode(POC_GOTO,popGetLabel(rIfx.lbl->key));
-
-    emitpLabel(lbl->key);
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    if(ifx)
-        ifx->generated = 1;
-#endif
-}
-#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));
+                    }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* gencjne - compare and jump if not equal                         */
-/*-----------------------------------------------------------------*/
-static void gencjne(operand *left, operand *right, iCode *ifx)
-{
-    symbol *tlbl  = newiTempLabel(NULL);
+                }
+            } 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__);
 
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    gencjneshort(left, right, lbl);
 
-    pic14_emitcode("mov","a,%s",one);
-    pic14_emitcode("sjmp","%05d_DS_",tlbl->key+100);
-    pic14_emitcode("","%05d_DS_:",lbl->key+100);
-    pic14_emitcode("clr","a");
-    pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-
-    emitpLabel(lbl->key);
-    emitpLabel(tlbl->key);
-
-}
-#endif
-
-/*-----------------------------------------------------------------*/
-/* 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);
-
-  DEBUGpic14_AopType(__LINE__,left,right,result);
-
-  /* if literal, move literal to right */
-  if (op_isLitLike (IC_LEFT(ic))) {
-    operand *tmp = right ;
-    right = left;
-    left = tmp;
-  }
-
-  false_label = NULL;
-  if (ifx && !IC_TRUE(ifx))
-  {
-    assert (IC_FALSE(ifx));
-    false_label = IC_FALSE(ifx);
-  }
-
-  size = min(AOP_SIZE(left),AOP_SIZE(right));
-  assert(!pic14_sameRegs(AOP(result),AOP(left)));
-  assert(!pic14_sameRegs(AOP(result),AOP(right)));
-
-  /* assume left != right */
-  {
-    int i;
-    for (i=0; i < AOP_SIZE(result); i++)
-    {
-      emitpcode(POC_CLRF, popGet(AOP(result),i));
-    }
-  }
-
-  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 {
-                if (AOP_TYPE(left) == AOP_ACC) {
-                    emitpcode(POC_ANDFW,popGet(AOP(right),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:
-                        if(AOP_TYPE(left) != AOP_ACC) {
-                            emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                        }
-                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                        break;
-                    default:
-                        if(AOP_TYPE(left) == AOP_ACC) {
-                            emitpcode(POC_ANDLW, popGetLit(t));
-                        } else {
-                            emitpcode(POC_MOVLW, popGetLit(t));
-                            emitpcode(POC_ANDFW,popGet(AOP(left),offset));
-                        }
-                        emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    }
-                    continue;
-                }
-
-                if (AOP_TYPE(left) == AOP_ACC) {
-                    emitpcode(POC_ANDFW,popGet(AOP(right),offset));
-                } else {
-                    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 {
-                    if( AOP_TYPE(result) == AOP_ACC) {
-                        emitpcode(POC_MOVLW, popGetLit(0));
-                        emitpcode(POC_BTFSS, popGet(AOP(right),0));
-                        emitpcode(POC_BTFSC, popGet(AOP(left),0));
-                        emitpcode(POC_MOVLW, popGetLit(1));
-
-                    } 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));
-
-                        pic14_emitcode("bcf","(%s >> 3), (%s & 7)",
-                            AOP(result)->aopu.aop_dir,
-                            AOP(result)->aopu.aop_dir);
-                        pic14_emitcode("btfss","(%s >> 3), (%s & 7)",
-                            AOP(right)->aopu.aop_dir,
-                            AOP(right)->aopu.aop_dir);
-                        pic14_emitcode("btfsc","(%s >> 3), (%s & 7)",
-                            AOP(left)->aopu.aop_dir,
-                            AOP(left)->aopu.aop_dir);
-                        pic14_emitcode("bsf","(%s >> 3), (%s & 7)",
-                            AOP(result)->aopu.aop_dir,
-                            AOP(result)->aopu.aop_dir);
-                    }
-                }
-            } 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(right) == AOP_ACC) {
-                    emitpcode(POC_IORLW, popGetLit(0));
-                    emitSKPNZ;
-                    emitpcode(POC_BTFSC, popGet(AOP(left),0));
-                    emitpcode(POC_BSF,   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 {
-                if (AOP_TYPE(left) == AOP_ACC) {
-                    emitpcode(POC_IORFW,  popGet(AOP(right),offset));
-                    pic14_emitcode("iorwf","%s,w",aopGet(AOP(right),offset,FALSE,FALSE));
-                } else {
-                    emitpcode(POC_MOVFW,  popGet(AOP(right),offset));
-                    emitpcode(POC_IORWF,  popGet(AOP(left),offset));
-
-                    pic14_emitcode("movf","%s,w",aopGet(AOP(right),offset,FALSE,FALSE));
-                    pic14_emitcode("iorwf","%s,f",aopGet(AOP(left),offset,FALSE,FALSE));
-
-                }
-            }
-        }
-    } 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:
-                    if (AOP_TYPE(left) != AOP_ACC) {
-                        emitpcode(POC_MOVFW,  popGet(AOP(left),offset));
-                    }
-                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-
-                    break;
-                default:
-                    if (AOP_TYPE(left) == AOP_ACC) {
-                        emitpcode(POC_IORLW,  popGetLit(t));
-                    } else {
-                        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
-            if (AOP_TYPE(left) == AOP_ACC) {
-                emitpcode(POC_IORFW,popGet(AOP(right),offset));
-            } else {
-                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
-                    if (IS_AOP_PREG(left)) {
-                        MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
-                        pic14_emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
-                        aopPut(AOP(result),"a",offset);
-                    } else {
-                        emitpcode(POC_MOVLW, popGetLit(t));
-                        emitpcode(POC_XORWF,popGet(AOP(left),offset));
-                        pic14_emitcode("xrl","%s,%s",
-                            aopGet(AOP(left),offset,FALSE,TRUE),
-                            aopGet(AOP(right),offset,FALSE,FALSE));
-                    }
-            } else {
-                if (AOP_TYPE(left) == AOP_ACC)
-                    pic14_emitcode("xrl","a,%s",aopGet(AOP(right),offset,FALSE,FALSE));
-                else {
-                    emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-                    emitpcode(POC_XORWF,popGet(AOP(left),offset));
-                    /*
-                    if (IS_AOP_PREG(left)) {
-                    pic14_emitcode("xrl","a,%s",aopGet(AOP(left),offset,FALSE,TRUE));
-                    aopPut(AOP(result),"a",offset);
-                    } else
-                    pic14_emitcode("xrl","%s,a",
-                    aopGet(AOP(left),offset,FALSE,TRUE));
-                    */
-                }
-            }
-        }
-    } 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:
-                    if (AOP_TYPE(left) != AOP_ACC) {
-                        emitpcode(POC_MOVFW,popGet(AOP(left),offset));
-                    }
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    pic14_emitcode("movf","%s,w",
-                        aopGet(AOP(left),offset,FALSE,FALSE));
-                    pic14_emitcode("movwf","%s",
-                        aopGet(AOP(result),offset,FALSE,FALSE));
-                    break;
-                case 0xff:
-                    if (AOP_TYPE(left) == AOP_ACC) {
-                        emitpcode(POC_XORLW, popGetLit(t));
-                    } else {
-                        emitpcode(POC_COMFW,popGet(AOP(left),offset));
-                    }
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    break;
-                default:
-                    if (AOP_TYPE(left) == AOP_ACC) {
-                        emitpcode(POC_XORLW, popGetLit(t));
-                    } else {
-                        emitpcode(POC_MOVLW, popGetLit(t));
-                        emitpcode(POC_XORFW,popGet(AOP(left),offset));
-                    }
-                    emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-                    pic14_emitcode("movlw","0x%x",t);
-                    pic14_emitcode("xorwf","%s,w",
-                        aopGet(AOP(left),offset,FALSE,FALSE));
-                    pic14_emitcode("movwf","%s",
-                        aopGet(AOP(result),offset,FALSE,FALSE));
-
-                }
-                continue;
-            }
-
-            // faster than result <- left, anl result,right
-            // and better if result is SFR
-            if (AOP_TYPE(left) == AOP_ACC) {
-                emitpcode(POC_XORFW,popGet(AOP(right),offset));
-            } else {
-                emitpcode(POC_MOVFW,popGet(AOP(right),offset));
-                emitpcode(POC_XORFW,popGet(AOP(left),offset));
-            }
-            if ( AOP_TYPE(result) != AOP_ACC){
-                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)
-{
-    char *l;
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    if(!pic14_sameRegs(AOP(left),AOP(result)) || (offl != offr)){
-        l = aopGet(AOP(left),offl,FALSE,FALSE);
-
-        if (*l == '@' && (IS_AOP_PREG(result))) {
-            pic14_emitcode("mov","a,%s",l);
-            aopPut(AOP(result),"a",offr);
-        } else {
-            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;
-
-    default:
-        shiftLeft_Left2ResultLit (left, result, offr * 8 + shCount-1);
-        shiftLeft_Left2ResultLit (result, result, 1);
-        return; /* prevent clearing result again */
-        break;
-    } // switch
-
-    while (0 < offr--)
-    {
-        emitpcode (POC_CLRF, popGet (AOP(result), offr));
-    } // while
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftRight_Left2ResultLit - shift right by known count          */
-/*-----------------------------------------------------------------*/
-
-static void shiftRight_Left2ResultLit (operand *left, operand *result, int shCount, int sign)
-{
-    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;
-
-    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;
-
-        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));
-
-            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
-
-            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;
-
-        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;
-
-        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
-
-    addSign (result, size, sign);
-}
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* shiftL2Left2Result - shift left two bytes from left to result   */
-/*-----------------------------------------------------------------*/
-static void shiftL2Left2Result (operand *left, int offl,
-                                operand *result, int offr, int shCount)
-{
-    FENTRY;
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    if(pic14_sameRegs(AOP(result), AOP(left))) {
-        switch(shCount) {
-        case 0:
-            break;
-        case 1:
-        case 2:
-        case 3:
-
-            emitpcode(POC_MOVFW,popGet(AOP(result),offr));
-            emitpcode(POC_ADDWF,popGet(AOP(result),offr));
-            emitpcode(POC_RLF,  popGet(AOP(result),offr+MSB16));
-
-            while(--shCount) {
-                emitCLRC;
-                emitpcode(POC_RLF, popGet(AOP(result),offr));
-                emitpcode(POC_RLF, popGet(AOP(result),offr+MSB16));
-            }
-
-            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));
+            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++;
             }
-            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));
-        }
+            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));
 
-    } 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;
+                default:
+                    emitpcode(POC_MOVLW,  popGetLit(t));
+                    emitpcode(POC_IORFW,  popGet(AOP(left),offset));
+                    emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
+                }
+                continue;
             }
-            break;
 
-        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));
+            // 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);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftR2Left2Result - shift right two bytes from left to result  */
+/* genXor - code for xclusive or                                   */
 /*-----------------------------------------------------------------*/
-static void shiftR2Left2Result (operand *left, int offl,
-                                operand *result, int offr,
-                                int shCount, int sign)
+static void genXor (iCode *ic, iCode *ifx)
 {
-    int same=0;
+    operand *left, *right, *result;
+    int size, offset=0;
+    unsigned long lit = 0L;
 
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    same = pic14_sameRegs(AOP(result), AOP(left));
 
-    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));
+    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;
     }
-    /* else {
-    movLeft2Result(left,offl, result, offr);
-    MOVA(aopGet(AOP(left),offl+MSB16,FALSE,FALSE));
+
+    /* if result = right then exchange them */
+    if(pic14_sameRegs(AOP(result),AOP(right))){
+        operand *tmp = right ;
+        right = left;
+        left = tmp;
     }
-    */
-    /* a:x >> shCount (x = lsb(result))*/
-    /*
-    if(sign)
-    AccAXRshS( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
-    else {
-    AccAXRsh( aopGet(AOP(result),offr,FALSE,FALSE) , shCount);
-    */
-    switch(shCount) {
-    case 0:
-        break;
-    case 1:
-    case 2:
-    case 3:
-        if(sign)
-            emitpcode(POC_RLFW,popGet(AOP(left),offl+MSB16));
-        else
-            emitCLRC;
 
-        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));
-        }
+    /* 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);
 
-        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) {
+    size = AOP_SIZE(result);
 
-            emitpcode(POC_MOVLW, popGetLit(0xf0));
-            emitpcode(POC_ANDWF, popGet(AOP(result),offr));
-            emitpcode(POC_SWAPF, popGet(AOP(result),offr));
+    // 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");
+                    }
+                }
+            }
 
-            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));
-        }
-
-        if(shCount >=5) {
-            emitpcode(POC_RRF, popGet(AOP(result),offr+MSB16));
-            emitpcode(POC_RRF, popGet(AOP(result),offr));
+            // 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(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(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));
+            }
         }
-
-        break;
-
-    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));
+    } 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++;
             }
-            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));
+            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;
             }
-            emitpcode(POC_MOVWF,popGet(AOP(result),offr+MSB16));
-            //emitpcode(POC_RLF,  popGet(AOP(result),offr));
-
-
-        }
-
-        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));
-  }
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftLLeftOrResult - shift left one byte from left, or to result*/
-/*-----------------------------------------------------------------*/
-static void shiftLLeftOrResult (operand *left, int offl,
-                                operand *result, int offr, 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))" );
-}
-
-/*-----------------------------------------------------------------*/
-/* shiftRLeftOrResult - shift right one byte from left,or to result*/
-/*-----------------------------------------------------------------*/
-static void shiftRLeftOrResult (operand *left, int offl,
-                                operand *result, int offr, int shCount)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    /* 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))" );
-}
-
-/*-----------------------------------------------------------------*/
-/* genlshOne - left shift a one byte quantity by known count       */
-/*-----------------------------------------------------------------*/
-static void genlshOne (operand *result, operand *left, int shCount)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    shiftL1Left2Result(left, LSB, result, LSB, shCount);
-}
-
-/*-----------------------------------------------------------------*/
-/* genlshTwo - left shift two bytes by known amount != 0           */
-/*-----------------------------------------------------------------*/
-static void genlshTwo (operand *result,operand *left, int shCount)
-{
-    int size;
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    size = pic14_getDataSize(result);
-
-    /* if shCount >= 8 */
-    if (shCount >= 8) {
-        shCount -= 8 ;
-
-        if (size > 1){
-            if (shCount)
-                shiftL1Left2Result(left, LSB, result, MSB16, shCount);
-            else
-                movLeft2Result(left, LSB, result, MSB16);
+            // 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));
         }
-        emitpcode(POC_CLRF,popGet(AOP(result),LSB));
     }
 
-    /*  1 <= shCount <= 7 */
-    else {
-        if(size == 1)
-            shiftL1Left2Result(left, LSB, result, LSB, shCount);
-        else
-            shiftL2Left2Result(left, LSB, result, LSB, shCount);
-    }
+release :
+    freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
+    freeAsmop(result,NULL,ic,TRUE);
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftLLong - shift left one long from left to result            */
-/* offl = LSB or MSB16                                             */
+/* genInline - write the inline code out                           */
 /*-----------------------------------------------------------------*/
-static void shiftLLong (operand *left, operand *result, int offr )
+static void genInline (iCode *ic)
 {
-    char *l;
-    int size = AOP_SIZE(result);
-
-    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);
-    }
-
-    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);
-    }
-
-    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);
-    }
+  char *buffer, *bp, *bp1;
+  bool inComment = FALSE;
 
-    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);
-}
+  FENTRY;
+  DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-/*-----------------------------------------------------------------*/
-/* genlshFour - shift four byte by a known amount != 0             */
-/*-----------------------------------------------------------------*/
-static void genlshFour (operand *result, operand *left, int shCount)
-{
-    int size;
+  _G.inLine += (!options.asmpeep);
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    size = AOP_SIZE(result);
+  buffer = bp = bp1 = Safe_strdup (IC_INLINE (ic));
 
-    /* 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;
-    }
+  while (*bp)
+    {
+      switch (*bp)
+        {
+        case ';':
+          inComment = TRUE;
+          ++bp;
+          break;
 
-    /* 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;
-    }
+        case '\n':
+          inComment = FALSE;
+          *bp++ = '\0';
+          if (*bp1)
+            addpCode2pBlock(pb, newpCodeAsmDir(bp1, NULL)); // inline directly, no process
+          bp1 = bp;
+          break;
 
-    /* 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);
+        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
 
-    /* 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);
-    }
+  Safe_free (buffer);
+
+  _G.inLine -= (!options.asmpeep);
 }
-#endif
 
-#if 0
 /*-----------------------------------------------------------------*/
-/* genLeftShiftLiteral - left shifting by known count              */
+/* genRRC - rotate right with carry                                */
 /*-----------------------------------------------------------------*/
-static void genLeftShiftLiteral (operand *left,
-                                 operand *right,
-                                 operand *result,
-                                 iCode *ic)
+static void genRRC (iCode *ic)
 {
-    int shCount = (int) ulFromVal (AOP(right)->aopu.aop_lit);
-    //int size;
+    operand *left , *result ;
+    int size, offset = 0, same;
 
     FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    freeAsmop(right,NULL,ic,TRUE);
-
-    aopOp(left,ic,FALSE);
-    aopOp(result,ic,FALSE);
-
-    size = getSize(operandType(result));
-
-#if VIEW_SIZE
-    pic14_emitcode("; shift left ","result %d, left %d",size,
-        AOP_SIZE(left));
-#endif
+    /* rotate right with carry */
+    left = IC_LEFT(ic);
+    result=IC_RESULT(ic);
+    aopOp (left,ic,FALSE);
+    aopOp (result,ic,FALSE);
 
-    /* I suppose that the left size >= result size */
-    if(shCount == 0){
-        while(size--){
-            movLeft2Result(left, size, result, size);
-        }
-    }
+    DEBUGpic14_AopType(__LINE__,left,NULL,result);
 
-    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);
-}
-#endif
+    same = pic14_sameRegs(AOP(result),AOP(left));
 
-/*-----------------------------------------------------------------*
-* genMultiAsm - repeat assembly instruction for size of register.
-* if endian == 1, then the high byte (i.e base address + size of
-* register) is used first else the low byte is used first;
-*-----------------------------------------------------------------*/
-static void genMultiAsm( PIC_OPCODE poc, operand *reg, int size, int endian)
-{
+    size = AOP_SIZE(result);
 
-    int offset = 0;
+    /* get the lsb and put it into the carry */
+    emitpcode(POC_RRFW, popGet(AOP(left),size-1));
 
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
+    offset = 0 ;
 
-    if(!reg)
-        return;
+    while(size--) {
 
-    if(!endian) {
-        endian = 1;
-    } else {
-        endian = -1;
-        offset = size-1;
-    }
+        if(same) {
+            emitpcode(POC_RRF, popGet(AOP(left),offset));
+        } else {
+            emitpcode(POC_RRFW, popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
+        }
 
-    while(size--) {
-        emitpcode(poc,    popGet(AOP(reg),offset));
-        offset += endian;
+        offset++;
     }
 
+    freeAsmop(left,NULL,ic,TRUE);
+    freeAsmop(result,NULL,ic,TRUE);
 }
 
-#if 0
 /*-----------------------------------------------------------------*/
-/* genLeftShift - generates code for left shifting                 */
+/* genRLC - generate code for rotate left with carry               */
 /*-----------------------------------------------------------------*/
-static void genLeftShift (iCode *ic)
+static void genRLC (iCode *ic)
 {
-    operand *left,*right, *result;
-    int size, offset;
-    unsigned long lit = 0L;
-    char *l;
-    symbol *tlbl , *tlbl1;
-    pCodeOp *pctemp;
+    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);
 
-    right = IC_RIGHT(ic);
-    left  = IC_LEFT(ic);
-    result = IC_RESULT(ic);
-
-    aopOp(right,ic,FALSE);
-    aopOp(left,ic,FALSE);
-    aopOp(result,ic,FALSE);
-
-
-    /* if the shift count is known then do it
-    as efficiently as possible */
-    if (AOP_TYPE(right) == AOP_LIT) {
-        shiftLeft_Left2ResultLit (left, result, (int) ulFromVal (AOP(right)->aopu.aop_lit));
-        return ;
-    }
-
-    /* shift count is unknown then we have to form
-    a loop get the loop count in B : Note: we take
-    only the lower order byte since shifting
-    more that 32 bits make no sense anyway, ( the
-    largest size of an object can be only 32 bits ) */
-
-    /* this code fails for RIGHT == RESULT */
-    assert (!pic14_sameRegs (AOP(right), AOP(result)));
+    DEBUGpic14_AopType(__LINE__,left,NULL,result);
 
-    /* now move the left to the result if they are not the
-    same */
-    if (!pic14_sameRegs(AOP(left),AOP(result)) &&
-        AOP_SIZE(result) > 1) {
+    same = pic14_sameRegs(AOP(result),AOP(left));
 
-        size = AOP_SIZE(result);
-        offset=0;
-        while (size--) {
-            l = aopGet(AOP(left),offset,FALSE,TRUE);
-            if (*l == '@' && (IS_AOP_PREG(result))) {
+    /* move it to the result */
+    size = AOP_SIZE(result);
 
-                pic14_emitcode("mov","a,%s",l);
-                aopPut(AOP(result),"a",offset);
-            } else {
-                emitpcode(POC_MOVFW,  popGet(AOP(left),offset));
-                emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-                //aopPut(AOP(result),l,offset);
-            }
-            offset++;
-        }
-    }
+    /* get the msb and put it into the carry */
+    emitpcode(POC_RLFW, popGet(AOP(left),size-1));
 
-    if(AOP_TYPE(left) == AOP_LIT)
-        lit = ulFromVal (AOP(left)->aopu.aop_lit);
+    offset = 0 ;
 
-    size = AOP_SIZE(result);
+    while(size--) {
 
-    /* if it is only one byte then */
-    if (size == 1) {
-        if(optimized_for_speed && AOP_TYPE(left)!=AOP_LIT) {
-            emitpcode(POC_SWAPFW, popGet(AOP(left),0));
-            emitpcode(POC_ANDLW,  popGetLit(0xf0));
-            emitpcode(POC_BTFSS,  newpCodeOpBit(aopGet(AOP(right),0,FALSE,FALSE),2,0));
-            emitpcode(POC_MOVFW,  popGet(AOP(left),0));
-            emitpcode(POC_MOVWF,  popGet(AOP(result),0));
-            emitpcode(POC_BTFSS,  newpCodeOpBit(aopGet(AOP(right),0,FALSE,FALSE),0,0));
-            emitpcode(POC_ADDWF,  popGet(AOP(result),0));
-            emitpcode(POC_RLFW,   popGet(AOP(result),0));
-            emitpcode(POC_ANDLW,  popGetLit(0xfe));
-            emitpcode(POC_ADDFW,  popGet(AOP(result),0));
-            emitpcode(POC_BTFSC,  newpCodeOpBit(aopGet(AOP(right),0,FALSE,FALSE),1,0));
-            emitpcode(POC_ADDWF,  popGet(AOP(result),0));
+        if(same) {
+            emitpcode(POC_RLF, popGet(AOP(left),offset));
         } else {
-
-            tlbl = newiTempLabel(NULL);
-            if (!pic14_sameRegs(AOP(left),AOP(result))) {
-                mov2w (AOP(left), 0);
-                emitpcode(POC_MOVWF,  popGet(AOP(result),0));
-            }
-
-            emitpcode(POC_COMFW,  popGet(AOP(right),0));
-            emitpcode(POC_RRF,    popGet(AOP(result),0));
-            emitpLabel(tlbl->key);
-            emitpcode(POC_RLF,    popGet(AOP(result),0));
-            emitpcode(POC_ADDLW,  popGetLit(1));
-            emitSKPC;
-            emitpcode(POC_GOTO,popGetLabel(tlbl->key));
+            emitpcode(POC_RLFW, popGet(AOP(left),offset));
+            emitpcode(POC_MOVWF, popGet(AOP(result),offset));
         }
-        goto release ;
-    }
-
-    if (pic14_sameRegs(AOP(left),AOP(result))) {
 
-        tlbl = newiTempLabel(NULL);
-        emitpcode(POC_COMFW,  popGet(AOP(right),0));
-        genMultiAsm(POC_RRF, result, size,1);
-        emitpLabel(tlbl->key);
-        genMultiAsm(POC_RLF, result, size,0);
-        emitpcode(POC_ADDLW,  popGetLit(1));
-        emitSKPC;
-        emitpcode(POC_GOTO,popGetLabel(tlbl->key));
-        goto release;
+        offset++;
     }
 
-    //tlbl = newiTempLabel(NULL);
-    //offset = 0 ;
-    //tlbl1 = newiTempLabel(NULL);
-
-    //reAdjustPreg(AOP(result));
 
-    //pic14_emitcode("sjmp","%05d_DS_",tlbl1->key+100);
-    //pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-    //l = aopGet(AOP(result),offset,FALSE,FALSE);
-    //MOVA(l);
-    //pic14_emitcode("add","a,acc");
-    //aopPut(AOP(result),"a",offset++);
-    //while (--size) {
-    //  l = aopGet(AOP(result),offset,FALSE,FALSE);
-    //  MOVA(l);
-    //  pic14_emitcode("rlc","a");
-    //  aopPut(AOP(result),"a",offset++);
-    //}
-    //reAdjustPreg(AOP(result));
-
-    //pic14_emitcode("","%05d_DS_:",tlbl1->key+100);
-    //pic14_emitcode("djnz","b,%05d_DS_",tlbl->key+100);
-
-
-    tlbl = newiTempLabel(NULL);
-    tlbl1= newiTempLabel(NULL);
-
-    size = AOP_SIZE(result);
-    offset = 1;
-
-    pctemp = popGetTempReg();  /* grab a temporary working register. */
-
-    emitpcode(POC_MOVFW, popGet(AOP(right),0));
-
-    /* offset should be 0, 1 or 3 */
-    emitpcode(POC_ANDLW, popGetLit(0x07 + ((offset&3) << 3)));
-    emitSKPNZ;
-    emitpcode(POC_GOTO,  popGetLabel(tlbl1->key));
-
-    emitpcode(POC_MOVWF, pctemp);
-
-
-    emitpLabel(tlbl->key);
-
-    emitCLRC;
-    emitpcode(POC_RLF,  popGet(AOP(result),0));
-    while(--size)
-        emitpcode(POC_RLF,   popGet(AOP(result),offset++));
+    freeAsmop(left,NULL,ic,TRUE);
+    freeAsmop(result,NULL,ic,TRUE);
+}
 
-    emitpcode(POC_DECFSZ,  pctemp);
-    emitpcode(POC_GOTO,popGetLabel(tlbl->key));
-    emitpLabel(tlbl1->key);
+/*-----------------------------------------------------------------*/
+/* 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);
 
-    popReleaseTempReg(pctemp);
+    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);
+    }
 
 
-release:
-    freeAsmop (right,NULL,ic,TRUE);
     freeAsmop(left,NULL,ic,TRUE);
     freeAsmop(result,NULL,ic,TRUE);
 }
-#endif
 
-#if 0
 /*-----------------------------------------------------------------*/
-/* genrshOne - right shift a one byte quantity by known count      */
+/* AccLsh - shift left accumulator by known count                  */
+/* MARK: pic14 always rotates through CARRY!                       */
 /*-----------------------------------------------------------------*/
-static void genrshOne (operand *result, operand *left,
-                       int shCount, int sign)
+static void AccLsh (pCodeOp *pcop,int shCount)
 {
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    shiftR1Left2Result(left, LSB, result, LSB, shCount, sign);
+    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);
 }
 
 /*-----------------------------------------------------------------*/
-/* genrshTwo - right shift two bytes by known amount != 0          */
+/* 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 genrshTwo (operand *result,operand *left,
-                       int shCount, int sign)
+static void AccRsh (pCodeOp *pcop,int shCount, int mask_mode)
 {
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* if shCount >= 8 */
-    if (shCount >= 8) {
-        shCount -= 8 ;
-        if (shCount)
-            shiftR1Left2Result(left, MSB16, result, LSB,
-            shCount, sign);
-        else
-            movLeft2Result(left, MSB16, result, LSB);
-
-        emitpcode(POC_CLRF,popGet(AOP(result),MSB16));
-
-        if(sign) {
-            emitpcode(POC_BTFSC,newpCodeOpBit(aopGet(AOP(left),LSB,FALSE,FALSE),7,0));
-            emitpcode(POC_DECF, popGet(AOP(result),MSB16));
+    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;
     }
 
-    /*  1 <= shCount <= 7 */
-    else
-        shiftR2Left2Result(left, LSB, result, LSB, shCount, sign);
+    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);
+    }
 }
 
 /*-----------------------------------------------------------------*/
-/* shiftRLong - shift right one long from left to result           */
-/* offl = LSB or MSB16                                             */
+/* movLeft2Result - move byte from left to result                  */
 /*-----------------------------------------------------------------*/
-static void shiftRLong (operand *left, int offl,
-                        operand *result, int sign)
+static void movLeft2Result (operand *left, int offl,
+                            operand *result, int offr)
 {
-    int size, same;
-
     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);
 
-    if (sign)
-        emitpcode (POC_RLFW, popGet (AOP(left), AOP_SIZE(left)-1));
-    else
-        emitCLRC;
+    same = pic14_sameRegs (AOP(left), AOP(result));
 
-    assert (offl >= 0 && offl < size);
+    offr = shCount / 8;
+    shCount = shCount & 0x07;
 
-    same = pic14_sameRegs (AOP(left), AOP(result));
+    size -= offr;
 
-    /* perform the shift */
-    while (size--)
+    switch (shCount)
     {
-        if (same && !offl) {
-            emitpcode (POC_RRF, popGet (AOP(result), size));
+    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 {
-            emitpcode (POC_RRFW, popGet (AOP(left), size));
-            emitpcode (POC_MOVWF, popGet (AOP(result), size-offl));
-        }
-    } // while
+            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;
 
-    addSign (result, AOP_SIZE(left) - offl, sign);
-}
+    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));
 
-/*-----------------------------------------------------------------*/
-/* genrshFour - shift four byte by a known amount != 0             */
-/*-----------------------------------------------------------------*/
-static void genrshFour (operand *result, operand *left,
-                        int shCount, int sign)
-{
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    /* if shifting more that 3 bytes */
-    if(shCount >= 24 ) {
-        shCount -= 24;
-        if(shCount)
-            shiftR1Left2Result(left, MSB32, result, LSB, shCount, sign);
-        else
-            movLeft2Result(left, MSB32, result, LSB);
+        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;
 
-        addSign(result, MSB16, sign);
-    }
-    else if(shCount >= 16){
-        shCount -= 16;
-        if(shCount)
-            shiftR2Left2Result(left, MSB24, result, LSB, shCount, sign);
-        else{
-            movLeft2Result(left, MSB24, result, LSB);
-            movLeft2Result(left, MSB32, result, MSB16);
-        }
-        addSign(result, MSB24, sign);
-    }
-    else if(shCount >= 8){
-        shCount -= 8;
-        if(shCount == 1)
-            shiftRLong(left, MSB16, result, sign);
-        else if(shCount == 0){
-            movLeft2Result(left, MSB16, result, LSB);
-            movLeft2Result(left, MSB24, result, MSB16);
-            movLeft2Result(left, MSB32, result, MSB24);
-            addSign(result, MSB32, sign);
-        }
-        else{
-            shiftR2Left2Result(left, MSB16, result, LSB, shCount, 0);
-            shiftLLeftOrResult(left, MSB32, result, MSB16, 8 - shCount);
-            /* the last shift is signed */
-            shiftR1Left2Result(left, MSB32, result, MSB24, shCount, sign);
-            addSign(result, MSB32, sign);
-        }
-    }
-    else{   /* 1 <= shCount <= 7 */
-        if(shCount <= 2){
-            shiftRLong(left, LSB, result, sign);
-            if(shCount == 2)
-                shiftRLong(result, LSB, result, sign);
-        }
-        else{
-            shiftR2Left2Result(left, LSB, result, LSB, shCount, 0);
-            shiftLLeftOrResult(left, MSB24, result, MSB16, 8 - shCount);
-            shiftR2Left2Result(left, MSB24, result, MSB24, shCount, sign);
-        }
-    }
+    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;
+
+    default:
+        shiftLeft_Left2ResultLit (left, result, offr * 8 + shCount-1);
+        shiftLeft_Left2ResultLit (result, result, 1);
+        return; /* prevent clearing result again */
+        break;
+    } // switch
+
+    while (0 < offr--)
+    {
+        emitpcode (POC_CLRF, popGet (AOP(result), offr));
+    } // while
 }
 
 /*-----------------------------------------------------------------*/
-/* genRightShiftLiteral - right shifting by known count            */
+/* shiftRight_Left2ResultLit - shift right by known count          */
 /*-----------------------------------------------------------------*/
-static void genRightShiftLiteral (operand *left,
-                                  operand *right,
-                                  operand *result,
-                                  iCode *ic,
-                                  int sign)
-{
-    int shCount = (int) ulFromVal (AOP(right)->aopu.aop_lit);
-    int lsize,res_size;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    freeAsmop(right,NULL,ic,TRUE);
-
-    aopOp(left,ic,FALSE);
-    aopOp(result,ic,FALSE);
 
-#if VIEW_SIZE
-    pic14_emitcode("; shift right ","result %d, left %d",AOP_SIZE(result),
-        AOP_SIZE(left));
-#endif
+static void shiftRight_Left2ResultLit (operand *left, operand *result, int shCount, int sign)
+{
+    int size, same, offr, i;
 
-    lsize = pic14_getDataSize(left);
-    res_size = pic14_getDataSize(result);
-    /* test the LEFT size !!! */
+    size = AOP_SIZE(left);
+    if (AOP_SIZE(result) < size) size = AOP_SIZE(result);
 
-    /* I suppose that the left size >= result size */
-    if(shCount == 0){
-        while(res_size--)
-            movLeft2Result(left, res_size, result, res_size);
-    }
+    same = pic14_sameRegs (AOP(left), AOP(result));
 
-    else if(shCount >= (lsize * 8)){
+    offr = shCount / 8;
+    shCount = shCount & 0x07;
 
-        if(res_size == 1) {
-            emitpcode(POC_CLRF, popGet(AOP(result),LSB));
-            if(sign) {
-                emitpcode(POC_BTFSC,newpCodeOpBit(aopGet(AOP(left),lsize-1,FALSE,FALSE),7,0));
-                emitpcode(POC_DECF, popGet(AOP(result),LSB));
-            }
-        } else {
+    size -= offr;
 
-            if(sign) {
-                emitpcode(POC_MOVLW, popGetLit(0));
-                emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(left),lsize-1,FALSE,FALSE),7,0));
-                emitpcode(POC_MOVLW, popGetLit(0xff));
-                while(res_size--)
-                    emitpcode(POC_MOVWF, popGet(AOP(result),res_size));
+    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;
 
+        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;
 
-                while(res_size--)
-                    emitpcode(POC_CLRF, popGet(AOP(result),res_size));
-            }
-        }
-    } else {
+        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));
 
-        switch (res_size) {
-        case 1:
-            genrshOne (result,left,shCount,sign);
-            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 2:
-            genrshTwo (result,left,shCount,sign);
+            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;
 
-        case 4:
-            genrshFour (result,left,shCount,sign);
-            break;
-        default :
+        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;
-        }
 
-    }
+        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
 
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
+    addSign (result, size, sign);
 }
-#endif
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genSignedRightShift - right shift of signed number              */
-/*-----------------------------------------------------------------*/
-static void genSignedRightShift (iCode *ic)
+/*-----------------------------------------------------------------*
+* genMultiAsm - repeat assembly instruction for size of register.
+* if endian == 1, then the high byte (i.e base address + size of
+* register) is used first else the low byte is used first;
+*-----------------------------------------------------------------*/
+static void genMultiAsm( PIC_OPCODE poc, operand *reg, int size, int endian)
 {
-    operand *right, *left, *result;
-    int size, offset;
-    //  char *l;
-    symbol *tlbl, *tlbl1 ;
-    pCodeOp *pctemp;
 
-    //same = ((left == result) || (AOP(left) == AOP(result))) && (offl == offr);
+    int offset = 0;
 
-    /* we do it the hard way put the shift count in b
-    and loop thru preserving the sign */
     FENTRY;
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-    right = IC_RIGHT(ic);
-    left  = IC_LEFT(ic);
-    result = IC_RESULT(ic);
-
-    aopOp(right,ic,FALSE);
-    aopOp(left,ic,FALSE);
-    aopOp(result,ic,FALSE);
-
-
-    if ( AOP_TYPE(right) == AOP_LIT) {
-        shiftRight_Left2ResultLit (left, result, (int) ulFromVal (AOP(right)->aopu.aop_lit), 1);
-        //genRightShiftLiteral (left,right,result,ic,1);
-        return ;
-    }
-    /* shift count is unknown then we have to form
-    a loop get the loop count in B : Note: we take
-    only the lower order byte since shifting
-    more that 32 bits make no sense anyway, ( the
-    largest size of an object can be only 32 bits ) */
-
-    //pic14_emitcode("mov","b,%s",aopGet(AOP(right),0,FALSE,FALSE));
-    //pic14_emitcode("inc","b");
-    //freeAsmop (right,NULL,ic,TRUE);
-    //aopOp(left,ic,FALSE);
-    //aopOp(result,ic,FALSE);
-
-    /* now move the left to the result if they are not the
-    same */
-    if (!pic14_sameRegs(AOP(left),AOP(result)) &&
-        AOP_SIZE(result) > 1) {
-
-        size = AOP_SIZE(result);
-        offset=0;
-        while (size--) {
-            /*
-            l = aopGet(AOP(left),offset,FALSE,TRUE);
-            if (*l == '@' && IS_AOP_PREG(result)) {
-                pic14_emitcode("mov","a,%s",l);
-                aopPut(AOP(result),"a",offset);
-            } else
-            aopPut(AOP(result),l,offset);
-            */
-            emitpcode(POC_MOVFW,  popGet(AOP(left),offset));
-            emitpcode(POC_MOVWF,  popGet(AOP(result),offset));
-
-            offset++;
-        }
-    }
-
-    /* mov the highest order bit to OVR */
-    tlbl = newiTempLabel(NULL);
-    tlbl1= newiTempLabel(NULL);
-
-    size = AOP_SIZE(result);
-    offset = size - 1;
-
-    pctemp = popGetTempReg();  /* grab a temporary working register. */
-
-    emitpcode(POC_MOVFW, popGet(AOP(right),0));
-
-    /* offset should be 0, 1 or 3 */
-    emitpcode(POC_ANDLW, popGetLit(0x07 + ((offset&3) << 3)));
-    emitSKPNZ;
-    emitpcode(POC_GOTO,  popGetLabel(tlbl1->key));
-
-    emitpcode(POC_MOVWF, pctemp);
-
-
-    emitpLabel(tlbl->key);
-
-    emitpcode(POC_RLFW,  popGet(AOP(result),offset));
-    emitpcode(POC_RRF,   popGet(AOP(result),offset));
-
-    while(--size) {
-        emitpcode(POC_RRF,   popGet(AOP(result),--offset));
-    }
-
-    emitpcode(POC_DECFSZ,  pctemp);
-    emitpcode(POC_GOTO,popGetLabel(tlbl->key));
-    emitpLabel(tlbl1->key);
+    if(!reg)
+        return;
 
-    popReleaseTempReg(pctemp);
-#if 0
-    size = AOP_SIZE(result);
-    offset = size - 1;
-    pic14_emitcode("mov","a,%s",aopGet(AOP(left),offset,FALSE,FALSE));
-    pic14_emitcode("rlc","a");
-    pic14_emitcode("mov","ov,c");
-    /* if it is only one byte then */
-    if (size == 1) {
-        l = aopGet(AOP(left),0,FALSE,FALSE);
-        MOVA(l);
-        pic14_emitcode("sjmp","%05d_DS_",tlbl1->key+100);
-        pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-        pic14_emitcode("mov","c,ov");
-        pic14_emitcode("rrc","a");
-        pic14_emitcode("","%05d_DS_:",tlbl1->key+100);
-        pic14_emitcode("djnz","b,%05d_DS_",tlbl->key+100);
-        aopPut(AOP(result),"a",0);
-        goto release ;
+    if(!endian) {
+        endian = 1;
+    } else {
+        endian = -1;
+        offset = size-1;
     }
 
-    reAdjustPreg(AOP(result));
-    pic14_emitcode("sjmp","%05d_DS_",tlbl1->key+100);
-    pic14_emitcode("","%05d_DS_:",tlbl->key+100);
-    pic14_emitcode("mov","c,ov");
-    while (size--) {
-        l = aopGet(AOP(result),offset,FALSE,FALSE);
-        MOVA(l);
-        pic14_emitcode("rrc","a");
-        aopPut(AOP(result),"a",offset--);
+    while(size--) {
+        emitpcode(poc,    popGet(AOP(reg),offset));
+        offset += endian;
     }
-    reAdjustPreg(AOP(result));
-    pic14_emitcode("","%05d_DS_:",tlbl1->key+100);
-    pic14_emitcode("djnz","b,%05d_DS_",tlbl->key+100);
 
-release:
-#endif
-
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-    freeAsmop(right,NULL,ic,TRUE);
 }
-#endif
 
 /*-----------------------------------------------------------------*/
 /* loadSignToC - load the operand's sign bit into CARRY            */
@@ -8327,7 +5108,8 @@ static void genLeftShift (iCode *ic)
 /*-----------------------------------------------------------------*/
 /* SetIrp - Set IRP bit                                            */
 /*-----------------------------------------------------------------*/
-void SetIrp(operand *result) {
+static void SetIrp(operand *result)
+{
     FENTRY;
     if (AOP_TYPE(result) == AOP_LIT) {
         unsigned lit = (unsigned) double2ul (operandLitValue(result));
@@ -8336,8 +5118,10 @@ void SetIrp(operand *result) {
         else
             emitCLRIRP;
     } else {
-        if (PCOP(AOP(result))->type == PO_LITERAL) {
-            int addrs = PCOL(AOP(result))->lit;
+        if ((AOP_TYPE(result) == AOP_PCODE)
+            && (AOP(result)->aopu.pcop->type == PO_LITERAL))
+        {
+            int addrs = PCOL(AOP(result)->aopu.pcop)->lit;
             if (addrs & 0x100)
                 emitSETIRP;
             else
@@ -8628,8 +5412,9 @@ static void genNearPointerGet (operand *left,
     aopOp (result,ic,FALSE);
 
     /* Check if can access directly instead of via a pointer */
-    if ((PCOP(AOP(left))->type == PO_LITERAL || PCOP(AOP(left))->type == PO_IMMEDIATE)
-        && AOP_SIZE(result) == 1)
+    if ((AOP_TYPE(left) == AOP_PCODE)
+        && (AOP(left)->aopu.pcop->type == PO_IMMEDIATE)
+        && (AOP_SIZE(result) == 1))
     {
         direct = 1;
     }
@@ -8650,242 +5435,55 @@ static void genNearPointerGet (operand *left,
     {
         /* we have can just get the values */
         int size = AOP_SIZE(result);
-        int offset = 0 ;
-
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-        while(size--) {
-            if (direct)
-                emitpcode(POC_MOVWF,popGet(AOP(left),0));
-            else
-                emitpcode(POC_MOVFW,popCopyReg(&pc_indf));
-            if (AOP_TYPE(result) == AOP_LIT) {
-                emitpcode(POC_MOVLW,popGet(AOP(result),offset));
-            } else {
-                emitpcode(POC_MOVWF,popGet(AOP(result),offset));
-            }
-            if (size && !direct)
-                emitpcode(POC_INCF,popCopyReg(&pc_fsr));
-            offset++;
-        }
-    }
-
-    /* now some housekeeping stuff */
-    if (aop) {
-        /* we had to allocate for this iCode */
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-        freeAsmop(NULL,aop,ic,TRUE);
-    } else {
-        /* we did not allocate which means left
-        already in a pointer register, then
-        if size > 0 && this could be used again
-        we have to point it back to where it
-        belongs */
-        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-        if (AOP_SIZE(result) > 1 &&
-            !OP_SYMBOL(left)->remat &&
-            ( OP_SYMBOL(left)->liveTo > ic->seq ||
-            ic->depth )) {
-            int size = AOP_SIZE(result) - 1;
-            while (size--)
-                emitpcode(POC_DECF, popCopyReg(&pc_fsr));
-        }
-    }
-
-release:
-    /* done */
-    freeAsmop(left,NULL,ic,TRUE);
-    freeAsmop(result,NULL,ic,TRUE);
-
-}
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genPagedPointerGet - pic14_emitcode for paged pointer fetch           */
-/*-----------------------------------------------------------------*/
-static void genPagedPointerGet (operand *left,
-                                operand *result,
-                                iCode *ic)
-{
-    asmop *aop = NULL;
-    regs *preg = NULL ;
-    char *rname ;
-    sym_link *rtype, *retype;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    rtype = operandType(result);
-    retype= getSpec(rtype);
-
-    aopOp(left,ic,FALSE);
-
-    /* if the value is already in a pointer register
-    then don't need anything more */
-    if (!AOP_INPREG(AOP(left))) {
-        /* otherwise get a free pointer register */
-        aop = newAsmop(0);
-        preg = getFreePtr(ic,&aop,FALSE);
-        pic14_emitcode("mov","%s,%s",
-            preg->name,
-            aopGet(AOP(left),0,FALSE,TRUE));
-        rname = preg->name ;
-    } else
-        rname = aopGet(AOP(left),0,FALSE,FALSE);
-
-    freeAsmop(left,NULL,ic,TRUE);
-    aopOp (result,ic,FALSE);
-
-    /* if bitfield then unpack the bits */
-    if (IS_BITFIELD(retype))
-        genUnpackBits (result,left,rname,PPOINTER,0);
-    else {
-        /* we have can just get the values */
-        int size = AOP_SIZE(result);
-        int offset = 0 ;
-
-        while (size--) {
-
-            pic14_emitcode("movx","a,@%s",rname);
-            aopPut(AOP(result),"a",offset);
+        int offset = 0 ;
 
-            offset++ ;
+        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
-            if (size)
-                pic14_emitcode("inc","%s",rname);
+        while(size--) {
+            if (direct)
+                emitpcode(POC_MOVWF,popGet(AOP(left),0));
+            else
+                emitpcode(POC_MOVFW,popCopyReg(&pc_indf));
+            if (AOP_TYPE(result) == AOP_LIT) {
+                emitpcode(POC_MOVLW,popGet(AOP(result),offset));
+            } else {
+                emitpcode(POC_MOVWF,popGet(AOP(result),offset));
+            }
+            if (size && !direct)
+                emitpcode(POC_INCF,popCopyReg(&pc_fsr));
+            offset++;
         }
     }
 
     /* now some housekeeping stuff */
     if (aop) {
         /* we had to allocate for this iCode */
+        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
         freeAsmop(NULL,aop,ic,TRUE);
     } else {
-    /* we did not allocate which means left
-    already in a pointer register, then
-    if size > 0 && this could be used again
-    we have to point it back to where it
+        /* we did not allocate which means left
+        already in a pointer register, then
+        if size > 0 && this could be used again
+        we have to point it back to where it
         belongs */
+        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
         if (AOP_SIZE(result) > 1 &&
             !OP_SYMBOL(left)->remat &&
             ( OP_SYMBOL(left)->liveTo > ic->seq ||
             ic->depth )) {
             int size = AOP_SIZE(result) - 1;
             while (size--)
-                pic14_emitcode("dec","%s",rname);
+                emitpcode(POC_DECF, popCopyReg(&pc_fsr));
         }
     }
 
+release:
     /* done */
-    freeAsmop(result,NULL,ic,TRUE);
-
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genFarPointerGet - gget value from far space                    */
-/*-----------------------------------------------------------------*/
-static void genFarPointerGet (operand *left,
-                              operand *result, iCode *ic)
-{
-    int size, offset ;
-    sym_link *retype = getSpec(operandType(result));
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    aopOp(left,ic,FALSE);
-
-    /* if the operand is already in dptr
-    then we do nothing else we move the value to dptr */
-    if (AOP_TYPE(left) != AOP_STR) {
-        /* if this is remateriazable */
-        if (AOP_TYPE(left) == AOP_IMMD)
-            pic14_emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
-        else { /* we need to get it byte by byte */
-            pic14_emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
-            pic14_emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
-            if (options.model == MODEL_FLAT24)
-            {
-                pic14_emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
-            }
-        }
-    }
-    /* so dptr know contains the address */
     freeAsmop(left,NULL,ic,TRUE);
-    aopOp(result,ic,FALSE);
-
-    /* if bit then unpack */
-    if (IS_BITFIELD(retype))
-        genUnpackBits(result,left,"dptr",FPOINTER,0);
-    else {
-        size = AOP_SIZE(result);
-        offset = 0 ;
-
-        while (size--) {
-            pic14_emitcode("movx","a,@dptr");
-            aopPut(AOP(result),"a",offset++);
-            if (size)
-                pic14_emitcode("inc","dptr");
-        }
-    }
-
     freeAsmop(result,NULL,ic,TRUE);
-}
-#endif
-
-#if 0
-/*-----------------------------------------------------------------*/
-/* genCodePointerGet - get value from code space                  */
-/*-----------------------------------------------------------------*/
-static void genCodePointerGet (operand *left,
-                               operand *result, iCode *ic)
-{
-    int size, offset ;
-    sym_link *retype = getSpec(operandType(result));
-
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    aopOp(left,ic,FALSE);
-
-    /* if the operand is already in dptr
-    then we do nothing else we move the value to dptr */
-    if (AOP_TYPE(left) != AOP_STR) {
-        /* if this is remateriazable */
-        if (AOP_TYPE(left) == AOP_IMMD)
-            pic14_emitcode("mov","dptr,%s",aopGet(AOP(left),0,TRUE,FALSE));
-        else { /* we need to get it byte by byte */
-            pic14_emitcode("mov","dpl,%s",aopGet(AOP(left),0,FALSE,FALSE));
-            pic14_emitcode("mov","dph,%s",aopGet(AOP(left),1,FALSE,FALSE));
-            if (options.model == MODEL_FLAT24)
-            {
-                pic14_emitcode("mov", "dpx,%s",aopGet(AOP(left),2,FALSE,FALSE));
-            }
-        }
-    }
-    /* so dptr know contains the address */
-    freeAsmop(left,NULL,ic,TRUE);
-    aopOp(result,ic,FALSE);
-
-    /* if bit then unpack */
-    if (IS_BITFIELD(retype))
-        genUnpackBits(result,left,"dptr",CPOINTER,0);
-    else {
-        size = AOP_SIZE(result);
-        offset = 0 ;
-
-        while (size--) {
-            pic14_emitcode("clr","a");
-            pic14_emitcode("movc","a,@a+dptr");
-            aopPut(AOP(result),"a",offset++);
-            if (size)
-                pic14_emitcode("inc","dptr");
-        }
-    }
 
-    freeAsmop(result,NULL,ic,TRUE);
 }
-#endif
+
 /*-----------------------------------------------------------------*/
 /* genGenPointerGet - gget value from generic pointer space        */
 /*-----------------------------------------------------------------*/
@@ -9364,7 +5962,10 @@ static void genNearPointerSet (operand *right,
     DEBUGpic14_AopType(__LINE__,NULL,right,result);
 
     /* Check if can access directly instead of via a pointer */
-    if (PCOP(AOP(result))->type == PO_LITERAL && AOP_SIZE(right) == 1) {
+    if ((AOP_TYPE(result) == AOP_PCODE)
+        && (AOP(result)->aopu.pcop->type == PO_IMMEDIATE)
+        && (AOP_SIZE(right) == 1))
+    {
         direct = 1;
     }
 
@@ -9436,141 +6037,6 @@ static void genNearPointerSet (operand *right,
     freeAsmop(result,NULL,ic,TRUE);
 }
 
-#if 0
-/*-----------------------------------------------------------------*/
-/* genPagedPointerSet - pic14_emitcode for Paged pointer put             */
-/*-----------------------------------------------------------------*/
-static void genPagedPointerSet (operand *right,
-                                operand *result,
-                                iCode *ic)
-{
-    asmop *aop = NULL;
-    regs *preg = NULL ;
-    char *rname , *l;
-    sym_link *retype;
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-
-    retype= getSpec(operandType(right));
-
-    aopOp(result,ic,FALSE);
-
-    /* if the value is already in a pointer register
-    then don't need anything more */
-    if (!AOP_INPREG(AOP(result))) {
-        /* otherwise get a free pointer register */
-        aop = newAsmop(0);
-        preg = getFreePtr(ic,&aop,FALSE);
-        pic14_emitcode("mov","%s,%s",
-            preg->name,
-            aopGet(AOP(result),0,FALSE,TRUE));
-        rname = preg->name ;
-    } else
-        rname = aopGet(AOP(result),0,FALSE,FALSE);
-
-    freeAsmop(result,NULL,ic,TRUE);
-    aopOp (right,ic,FALSE);
-
-    /* if bitfield then unpack the bits */
-    if (IS_BITFIELD(retype))
-        genPackBits (retype,result,right,rname,PPOINTER);
-    else {
-        /* we have can just get the values */
-        int size = AOP_SIZE(right);
-        int offset = 0 ;
-
-        while (size--) {
-            l = aopGet(AOP(right),offset,FALSE,TRUE);
-
-            MOVA(l);
-            pic14_emitcode("movx","@%s,a",rname);
-
-            if (size)
-                pic14_emitcode("inc","%s",rname);
-
-            offset++;
-        }
-    }
-
-    /* now some housekeeping stuff */
-    if (aop) {
-        /* we had to allocate for this iCode */
-        freeAsmop(NULL,aop,ic,TRUE);
-    } else {
-    /* we did not allocate which means left
-    already in a pointer register, then
-    if size > 0 && this could be used again
-    we have to point it back to where it
-        belongs */
-        if (AOP_SIZE(right) > 1 &&
-            !OP_SYMBOL(result)->remat &&
-            ( OP_SYMBOL(result)->liveTo > ic->seq ||
-            ic->depth )) {
-            int size = AOP_SIZE(right) - 1;
-            while (size--)
-                pic14_emitcode("dec","%s",rname);
-        }
-    }
-
-    /* done */
-    freeAsmop(right,NULL,ic,TRUE);
-
-
-}
-
-/*-----------------------------------------------------------------*/
-/* genFarPointerSet - set value from far space                     */
-/*-----------------------------------------------------------------*/
-static void genFarPointerSet (operand *right,
-                              operand *result, iCode *ic)
-{
-    int size, offset ;
-    sym_link *retype = getSpec(operandType(right));
-
-    FENTRY;
-    DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
-    aopOp(result,ic,FALSE);
-
-    /* if the operand is already in dptr
-    then we do nothing else we move the value to dptr */
-    if (AOP_TYPE(result) != AOP_STR) {
-        /* if this is remateriazable */
-        if (AOP_TYPE(result) == AOP_IMMD)
-            pic14_emitcode("mov","dptr,%s",aopGet(AOP(result),0,TRUE,FALSE));
-        else { /* we need to get it byte by byte */
-            pic14_emitcode("mov","dpl,%s",aopGet(AOP(result),0,FALSE,FALSE));
-            pic14_emitcode("mov","dph,%s",aopGet(AOP(result),1,FALSE,FALSE));
-            if (options.model == MODEL_FLAT24)
-            {
-                pic14_emitcode("mov", "dpx,%s",aopGet(AOP(result),2,FALSE,FALSE));
-            }
-        }
-    }
-    /* so dptr know contains the address */
-    freeAsmop(result,NULL,ic,TRUE);
-    aopOp(right,ic,FALSE);
-
-    /* if bit then unpack */
-    if (IS_BITFIELD(retype))
-        genPackBits(retype,result,right,"dptr",FPOINTER);
-    else {
-        size = AOP_SIZE(right);
-        offset = 0 ;
-
-        while (size--) {
-            char *l = aopGet(AOP(right),offset++,FALSE,FALSE);
-            MOVA(l);
-            pic14_emitcode("movx","@dptr,a");
-            if (size)
-                pic14_emitcode("inc","dptr");
-        }
-    }
-
-    freeAsmop(right,NULL,ic,TRUE);
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genGenPointerSet - set value from generic pointer space         */
 /*-----------------------------------------------------------------*/
@@ -9806,18 +6272,18 @@ static void genAddrOf (iCode *ic)
     fprintf (stderr, "left->etype  : "); printTypeChain (OP_SYM_ETYPE(left), stderr); fprintf (stderr, ", codesp:%d, codeptr:%d, constptr:%d\n",IN_CODESPACE(SPEC_OCLS(getSpec (OP_SYM_ETYPE(left)))), IS_CODEPTR(OP_SYM_ETYPE(left)), IS_PTR_CONST(OP_SYM_ETYPE(left)));
 #endif
 
-    if (IS_CODEPTR(OP_SYM_TYPE(result)) && !IN_CODESPACE(SPEC_OCLS(getSpec (OP_SYM_TYPE(left))))) {
+    if (IS_SYMOP(result) && IS_CODEPTR(OP_SYM_TYPE(result)) && !IN_CODESPACE(SPEC_OCLS(getSpec (OP_SYM_TYPE(left))))) {
       fprintf (stderr, "trying to assign __code pointer (%s) an address in __data space (&%s) -- expect trouble\n",
         IS_SYMOP(result) ? OP_SYMBOL(result)->name : "unknown",
         OP_SYMBOL(left)->name);
-    } else if (!IS_CODEPTR (OP_SYM_TYPE(result)) && IN_CODESPACE(SPEC_OCLS(getSpec(OP_SYM_TYPE(left))))) {
+    } else if (IS_SYMOP(result) && !IS_CODEPTR (OP_SYM_TYPE(result)) && IN_CODESPACE(SPEC_OCLS(getSpec(OP_SYM_TYPE(left))))) {
       fprintf (stderr, "trying to assign __data pointer (%s) an address in __code space (&%s) -- expect trouble\n",
         IS_SYMOP(result) ? OP_SYMBOL(result)->name : "unknown",
         OP_SYMBOL(left)->name);
     }
 
     size = AOP_SIZE(IC_RESULT(ic));
-    if (IS_GENPTR(OP_SYM_TYPE(result))) {
+    if (IS_SYMOP(result) && IS_GENPTR(OP_SYM_TYPE(result))) {
         /* strip tag */
         if (size > GPTRSIZE-1) size = GPTRSIZE-1;
     }
@@ -9835,7 +6301,7 @@ static void genAddrOf (iCode *ic)
         offset++;
     }
 
-    if (IS_GENPTR(OP_SYM_TYPE(result)))
+    if (IS_SYMOP(result) && IS_GENPTR(OP_SYM_TYPE(result)))
     {
         /* provide correct tag */
         int isCode = IN_CODESPACE(SPEC_OCLS(getSpec(OP_SYM_TYPE(left))));
@@ -9848,35 +6314,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                        */
 /*-----------------------------------------------------------------*/
@@ -10067,138 +6504,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                                  */
 /*-----------------------------------------------------------------*/
@@ -10359,14 +6664,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);
@@ -10422,26 +6720,8 @@ static int genDjnz (iCode *ic, iCode *ifx)
 
     aopOp(IC_RESULT(ic),ic,FALSE);
 
-    if (IS_AOP_PREG(IC_RESULT(ic))) {
-        pic14_emitcode("dec","%s",
-            aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-        pic14_emitcode("mov","a,%s",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-        pic14_emitcode("jnz","%05d_DS_",lbl->key+100);
-    } else {
-
-
-        emitpcode(POC_DECFSZ,popGet(AOP(IC_RESULT(ic)),0));
-        emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-
-        pic14_emitcode("decfsz","%s,f",aopGet(AOP(IC_RESULT(ic)),0,FALSE,FALSE));
-        pic14_emitcode ("goto","_%05d_DS_",IC_TRUE(ifx)->key+100 + labelOffset);
-
-    }
-    /*     pic14_emitcode ("sjmp","%05d_DS_",lbl1->key+100); */
-    /*     pic14_emitcode ("","%05d_DS_:",lbl->key+100); */
-    /*     pic14_emitcode ("ljmp","%05d_DS_",IC_TRUE(ifx)->key+100); */
-    /*     pic14_emitcode ("","%05d_DS_:",lbl1->key+100); */
-
+    emitpcode(POC_DECFSZ,popGet(AOP(IC_RESULT(ic)),0));
+    emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
 
     freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
     ifx->generated = 1;
@@ -10546,7 +6826,7 @@ void genpic14Code (iCode *lic)
         }
 
         if (options.iCodeInAsm) {
-                  char *iLine = printILine(ic);
+          const char *iLine = printILine(ic);
           emitpComment ("[ICODE] %s:%d: %s", ic->filename, ic->lineno, printILine (ic));
                   dbuf_free(iLine);
         }
@@ -10771,12 +7051,12 @@ void genpic14Code (iCode *lic)
 /* This is not safe, as a AOP_PCODE/PO_IMMEDIATE might be used both as literal
  * (meaning: representing its own address) or not (referencing its contents).
  * This can only be decided based on the operand's type. */
-int
+static int
 aop_isLitLike (asmop *aop)
 {
   assert (aop);
   if (aop->type == AOP_LIT) return 1;
-if (aop->type == AOP_IMMD) return 1;
+  if (aop->type == AOP_IMMD) return 1;
   if ((aop->type == AOP_PCODE) &&
         ((aop->aopu.pcop->type == PO_LITERAL)))
   {
@@ -10792,8 +7072,13 @@ op_isLitLike (operand *op)
 {
   assert (op);
   if (aop_isLitLike (AOP(op))) return 1;
-  if (IS_FUNC(OP_SYM_TYPE(op))) return 1;
-  if (IS_PTR(OP_SYM_TYPE(op)) && AOP_TYPE(op) == AOP_PCODE && AOP(op)->aopu.pcop->type == PO_IMMEDIATE) return 1;
+  if (IS_SYMOP(op) && IS_FUNC(OP_SYM_TYPE(op))) return 1;
+  if (IS_SYMOP(op) && IS_PTR(OP_SYM_TYPE(op))
+        && (AOP_TYPE(op) == AOP_PCODE)
+        && (AOP(op)->aopu.pcop->type == PO_IMMEDIATE)) {
+    return 1;
+  }
+
   return 0;
 }