Unified the per port Makefiles
[fw/sdcc] / src / avr / gen.c
index d6cb5ff2bba5431eeaa0da08659bd9eabfec5542..0a9bd9a359390db66920aeb36e1f587de5795a45 100644 (file)
@@ -115,7 +115,7 @@ static void
 emitcode (char *inst, char *fmt, ...)
 {
        va_list ap;
-       char lb[MAX_INLINEASM];
+       char lb[INITIAL_INLINEASM];
        char *lbp = lb;
 
        va_start (ap, fmt);
@@ -142,6 +142,36 @@ emitcode (char *inst, char *fmt, ...)
        va_end (ap);
 }
 
+/*-----------------------------------------------------------------*/
+/* hasInc - operand is incremented before any other use            */
+/*-----------------------------------------------------------------*/
+static iCode *
+hasInc (operand *op, iCode *ic)
+{
+  sym_link *type = operandType(op);
+  sym_link *retype = getSpec (type);
+  iCode *lic = ic->next;
+  int isize ;
+  
+  if (IS_BITVAR(retype)||!IS_PTR(type)) return NULL;
+  isize = getSize(type->next);
+  while (lic) {
+    /* if operand of the form op = op + <sizeof *op> */
+    if (lic->op == '+' && isOperandEqual(IC_LEFT(lic),op) &&
+       isOperandEqual(IC_RESULT(lic),op) && 
+       isOperandLiteral(IC_RIGHT(lic)) &&
+       operandLitValue(IC_RIGHT(lic)) == isize) {
+      return lic;
+    }
+    /* if the operand used or deffed */
+    if (bitVectBitValue(ic->uses,op->key) || ((unsigned) ic->defKey == op->key)) {
+      return NULL;
+    }
+    lic = lic->next;
+  }
+  return NULL;
+}
+
 /*-----------------------------------------------------------------*/
 /* getFreePtr - returns X or Z whichever is free or can be pushed  */
 /*-----------------------------------------------------------------*/
@@ -228,7 +258,6 @@ getFreePtr (iCode * ic, asmop ** aopp, bool result, bool zonly)
                return NULL;
        }
 
-       piCode (ic, stdout);
        /* other wise this is true end of the world */
        werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
                "getFreePtr should never reach here");
@@ -508,7 +537,7 @@ sameRegs (asmop * aop1, asmop * aop2)
 static int
 isRegPair (asmop * aop)
 {
-       if (!aop || aop->size != 2)
+       if (!aop || aop->size < 2)
                return 0;
        if (aop->type == AOP_X || aop->type == AOP_Z)
                return 1;
@@ -570,7 +599,7 @@ aopOp (operand * op, iCode * ic, bool result)
 
 
        /* if the type is a conditional */
-       if (sym->regType == REG_CND) {
+       if (sym->regType & REG_CND) {
                aop = op->aop = sym->aop = newAsmop (AOP_CRY);
                aop->size = 0;
                return;
@@ -1787,7 +1816,7 @@ genLabel (iCode * ic)
 static void
 genGoto (iCode * ic)
 {
-       emitcode ("rjmp", "L%05d:", (IC_LABEL (ic)->key + 100));
+       emitcode ("rjmp", "L%05d", (IC_LABEL (ic)->key + 100));
 }
 
 /*-----------------------------------------------------------------*/
@@ -1847,7 +1876,7 @@ genPlusIncr (iCode * ic)
                        return TRUE;
                }
                emitcode ("subi", "%s,lo8(%d)",
-                         aopGet (AOP (IC_LEFT (ic)), 0), -icount);
+                         aopGet (AOP (IC_LEFT (ic)), 0), 0-icount);
                return TRUE;
        }
 
@@ -1864,21 +1893,21 @@ genPlusIncr (iCode * ic)
 
                /* use subi */
                emitcode ("subi", "%s,lo8(%d)",
-                         aopGet (AOP (IC_RESULT (ic)), 0), -icount);
+                         aopGet (AOP (IC_RESULT (ic)), 0), 0-icount);
                emitcode ("sbci", "%s,hi8(%d)",
-                         aopGet (AOP (IC_RESULT (ic)), 1), -icount);
+                         aopGet (AOP (IC_RESULT (ic)), 1), 0-icount);
                return TRUE;
        }
 
        /* for 32 bit longs */
        emitcode ("subi", "%s,lo8(%d)", aopGet (AOP (IC_RESULT (ic)), 0),
-                 -icount);
+                 0-icount);
        emitcode ("sbci", "%s,hi8(%d)", aopGet (AOP (IC_RESULT (ic)), 1),
-                 -icount);
+                 0-icount);
        emitcode ("sbci", "%s,hlo8(%d)", aopGet (AOP (IC_RESULT (ic)), 2),
-                 -icount);
+                 0-icount);
        emitcode ("sbci", "%s,hhi8(%d)", aopGet (AOP (IC_RESULT (ic)), 3),
-                 -icount);
+                 0-icount);
        return TRUE;
 
 }
@@ -2857,11 +2886,11 @@ genXor (iCode * ic, iCode * ifx)
 static void
 genInline (iCode * ic)
 {
-       char buffer[MAX_INLINEASM];
-       char *bp = buffer;
-       char *bp1 = buffer;
+       char *buffer, *bp, *bp1;
 
        _G.inLine += (!options.asmpeep);
+
+       buffer = bp = bp1 = Safe_calloc(1, strlen(IC_INLINE(ic))+1);
        strcpy (buffer, IC_INLINE (ic));
 
        /* emit each line as a code */
@@ -3768,7 +3797,7 @@ genDataPointerGet (operand * left, operand * result, iCode * ic)
 /* genNearPointerGet - emitcode for near pointer fetch             */
 /*-----------------------------------------------------------------*/
 static void
-genMemPointerGet (operand * left, operand * result, iCode * ic)
+genMemPointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
 {
        asmop *aop = NULL;
        regs *preg = NULL;
@@ -3799,7 +3828,9 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
                aop = newAsmop (0);
                preg = getFreePtr (ic, &aop, FALSE, 0);
                if (isRegPair (AOP (left) )) {
-                   emitcode ("movw", "%s,%s",aop->aopu.aop_ptr->name);
+                       emitcode ("movw", "%s,%s",
+                                 aop->aopu.aop_ptr->name,
+                                 aopGet(AOP(left),0));
                } else {
                        emitcode ("mov", "%s,%s", aop->aopu.aop_ptr->name, 
                                  aopGet (AOP (left), 0));
@@ -3822,7 +3853,6 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
                exit (0);
        }
 
-       freeAsmop (left, NULL, ic, TRUE);
        aopOp (result, ic, FALSE);
 
        /* if bitfield then unpack the bits */
@@ -3834,7 +3864,7 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
                int offset = 0;
 
                while (size--) {
-                       if (size) {
+                       if (size || pi) {
                                emitcode ("ld","%s,%s+",aopGet(AOP(result),offset), rname);
                        } else {
                                emitcode ("ld","%s,%s",aopGet(AOP(result),offset), rname);
@@ -3845,6 +3875,20 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
        /* now some housekeeping stuff */
        if (gotFreePtr) {
                /* we had to allocate for this iCode */
+               if (pi) {
+                       if (isRegPair (AOP (left) )) {
+                               emitcode ("movw", "%s,%s",
+                                         aopGet (AOP(left),0),
+                                         aop->aopu.aop_ptr->name);
+                       } else {
+                               emitcode ("mov", "%s,%s", 
+                                         aopGet (AOP (left), 0),
+                                         aop->aopu.aop_ptr->name);
+                               emitcode ("mov", "%s,%s", 
+                                         aopGet (AOP (left), 1),
+                                         aop->aop_ptr2->name);
+                       }
+               }
                freeAsmop (NULL, aop, ic, TRUE);
        } else {
 
@@ -3853,15 +3897,17 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
                   if size > 0 && this could be used again
                   we have to point it back to where it
                   belongs */
-               if (AOP_SIZE (result) > 1 &&
-                   !OP_SYMBOL (left)->remat &&
-                   (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
+               if ((AOP_SIZE (result) > 1 &&
+                    !OP_SYMBOL (left)->remat &&
+                    (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) && !pi) {
                        int size = AOP_SIZE (result) - 1;
                        emitcode ("sbiw", "%s,%d",frname,size);
                }
        }
 
        /* done */
+       if (pi) pi->generated = 1;
+       freeAsmop (left, NULL, ic, TRUE);
        freeAsmop (result, NULL, ic, TRUE);
 
 }
@@ -3870,7 +3916,7 @@ genMemPointerGet (operand * left, operand * result, iCode * ic)
 /* genCodePointerGet - gget value from code space                  */
 /*-----------------------------------------------------------------*/
 static void
-genCodePointerGet (operand * left, operand * result, iCode * ic)
+genCodePointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
 {
        int size, offset;
        sym_link *retype = getSpec (operandType (result));      
@@ -3905,7 +3951,7 @@ genCodePointerGet (operand * left, operand * result, iCode * ic)
                offset = 0;
 
                while (size--) {
-                       if (size) {
+                       if (size || pi) {
                                emitcode ("lpm","%s,Z+",aopGet(AOP(result),offset++));
                        } else {
                                emitcode ("lpm","%s,Z",aopGet(AOP(result),offset++));
@@ -3913,10 +3959,17 @@ genCodePointerGet (operand * left, operand * result, iCode * ic)
                }
        }
 
-       freeAsmop (left, NULL, ic, TRUE);
        /* now some housekeeping stuff */
        if (gotFreePtr) {
                /* we had to allocate for this iCode */
+               if (pi) {
+                       if (isRegPair(AOP (left))) {
+                               emitcode ("movw","%s,r30",aopGet (AOP (left), 0));
+                       } else {                        
+                               emitcode ("mov", "%s,r30", aopGet (AOP (left), 0));
+                               emitcode ("mov", "%s,r31", aopGet (AOP (left), 1));
+                       }
+               }
                freeAsmop (NULL, aop, ic, TRUE);
        } else {
 
@@ -3925,15 +3978,18 @@ genCodePointerGet (operand * left, operand * result, iCode * ic)
                   if size > 0 && this could be used again
                   we have to point it back to where it
                   belongs */
-               if (AOP_SIZE (result) > 1 &&
-                   !OP_SYMBOL (left)->remat &&
-                   (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
+               if ((AOP_SIZE (result) > 1 &&
+                    !OP_SYMBOL (left)->remat &&
+                    (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) &&
+                   !pi) {
                        int size = AOP_SIZE (result) - 1;
                        emitcode ("sbiw", "r30,%d",size);
                }
        }
 
        /* done */
+       if (pi) pi->generated=1;
+       freeAsmop (left, NULL, ic, TRUE);
        freeAsmop (result, NULL, ic, TRUE);
 
 }
@@ -3942,7 +3998,7 @@ genCodePointerGet (operand * left, operand * result, iCode * ic)
 /* genGenPointerGet - gget value from generic pointer space        */
 /*-----------------------------------------------------------------*/
 static void
-genGenPointerGet (operand * left, operand * result, iCode * ic)
+genGenPointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
 {
        int size, offset;
        int gotFreePtr = 0;
@@ -3958,10 +4014,13 @@ genGenPointerGet (operand * left, operand * result, iCode * ic)
        } else {
                aop = newAsmop(0);
                getFreePtr(ic,&aop,FALSE,TRUE);
-
-               emitcode ("mov", "r30,%s", aopGet (AOP (left), 0));
-               emitcode ("mov", "r31,%s", aopGet (AOP (left), 1));
-               emitcode ("mov", "r0,%s", aopGet (AOP (left), 2));
+               if (isRegPair(AOP(left))) {
+                       emitcode ("movw", "r30,%s", aopGet (AOP (left), 0));
+               } else {
+                       emitcode ("mov", "r30,%s", aopGet (AOP (left), 0));
+                       emitcode ("mov", "r31,%s", aopGet (AOP (left), 1));
+               }
+               emitcode ("mov", "r24,%s", aopGet (AOP (left), 2));
                gotFreePtr=1;
        }
 
@@ -3977,7 +4036,7 @@ genGenPointerGet (operand * left, operand * result, iCode * ic)
                offset = 0;
 
                while (size--) {
-                       if (size) 
+                       if (size || pi
                                emitcode ("call", "__gptrget_pi");
                        else
                                emitcode ("call", "__gptrget");
@@ -3985,10 +4044,18 @@ genGenPointerGet (operand * left, operand * result, iCode * ic)
                }
        }
 
-       freeAsmop (left, NULL, ic, TRUE);
+
        /* now some housekeeping stuff */
        if (gotFreePtr) {
                /* we had to allocate for this iCode */
+               if (pi) {
+                       if (isRegPair(AOP (left))) {
+                               emitcode ("movw","%s,r30",aopGet (AOP (left), 0));
+                       } else {                        
+                               emitcode ("mov", "%s,r30", aopGet (AOP (left), 0));
+                               emitcode ("mov", "%s,r31", aopGet (AOP (left), 1));
+                       }
+               }
                freeAsmop (NULL, aop, ic, TRUE);
        } else {
 
@@ -3997,13 +4064,16 @@ genGenPointerGet (operand * left, operand * result, iCode * ic)
                   if size > 0 && this could be used again
                   we have to point it back to where it
                   belongs */
-               if (AOP_SIZE (result) > 1 &&
-                   !OP_SYMBOL (left)->remat &&
-                   (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) {
+               if ((AOP_SIZE (result) > 1 &&
+                    !OP_SYMBOL (left)->remat &&
+                    (OP_SYMBOL (left)->liveTo > ic->seq || ic->depth)) &&
+                   !pi) {
                        int size = AOP_SIZE (result) - 1;
                        emitcode ("sbiw", "r30,%d",size);
                }
        }
+       if (pi) pi->generated=1;
+       freeAsmop (left, NULL, ic, TRUE);
        freeAsmop (result, NULL, ic, TRUE);
 }
 
@@ -4011,7 +4081,7 @@ genGenPointerGet (operand * left, operand * result, iCode * ic)
 /* genPointerGet - generate code for pointer get                   */
 /*-----------------------------------------------------------------*/
 static void
-genPointerGet (iCode * ic)
+genPointerGet (iCode * ic, iCode *pi)
 {
        operand *left, *result;
        sym_link *type, *etype;
@@ -4042,15 +4112,15 @@ genPointerGet (iCode * ic)
        case IPOINTER:
        case PPOINTER:
        case FPOINTER:
-               genMemPointerGet (left, result, ic);
+               genMemPointerGet (left, result, ic, pi);
                break;
 
        case CPOINTER:
-               genCodePointerGet (left, result, ic);
+               genCodePointerGet (left, result, ic, pi);
                break;
 
        case GPOINTER:
-               genGenPointerGet (left, result, ic);
+               genGenPointerGet (left, result, ic, pi);
                break;
        }
 
@@ -4230,10 +4300,10 @@ genDataPointerSet (operand * right, operand * result, iCode * ic)
 /* genNearPointerSet - emitcode for near pointer put               */
 /*-----------------------------------------------------------------*/
 static void
-genMemPointerSet (operand * right, operand * result, iCode * ic)
+genMemPointerSet (operand * right, operand * result, iCode * ic, iCode *pi)
 {
        asmop *aop = NULL;
-       char *frname, *rname, *l;
+       char *frname = NULL, *rname, *l;
        int gotFreePtr = 0;
        sym_link *retype;
        sym_link *ptype = operandType (result);
@@ -4254,14 +4324,15 @@ genMemPointerSet (operand * right, operand * result, iCode * ic)
                aop = newAsmop (0);
                getFreePtr (ic, &aop, FALSE, 0);
                if (isRegPair (AOP (result) )) {
-                       emitcode ("movw", "%s,%s",aop->aopu.aop_ptr->name);
+                       emitcode ("movw", "%s,%s",aop->aopu.aop_ptr->name,
+                                 aopGet(AOP (result), 0));
                } else {
                        emitcode ("mov", "%s,%s", aop->aopu.aop_ptr->name, 
                                  aopGet (AOP (result), 0));
                        emitcode ("mov", "%s,%s", aop->aop_ptr2->name,
                                  aopGet (AOP (result), 1));
                }
-               gotFreePtr = 1;
+               gotFreePtr = 1;         
        } else {
                aop = AOP(result);
                frname = aopGet(aop,0);
@@ -4287,18 +4358,29 @@ genMemPointerSet (operand * right, operand * result, iCode * ic)
 
                while (size--) {
                        l = aopGet (AOP (right), offset);
-                       if (size)
-                               emitcode ("sts", "%s+,%s", rname,l);
+                       if (size || pi)
+                               emitcode ("st", "%s+,%s", rname,l);
                        else
-                               emitcode ("sts", "%s,%s", rname,l);                             
+                               emitcode ("st", "%s,%s", rname,l);                              
                        offset++;
                }
        }
        
        /* now some housekeeping stuff */
-       freeAsmop (result, NULL, ic, TRUE);
        if (gotFreePtr) {
                /* we had to allocate for this iCode */
+               if (pi) {
+                       if (isRegPair (AOP (result) )) {
+                               emitcode ("movw", "%s,%s",
+                                         aopGet(AOP(result),0),
+                                         aop->aopu.aop_ptr->name);
+                       } else {
+                               emitcode ("mov", "%s,%s", aop->aopu.aop_ptr->name, 
+                                         aopGet (AOP (result), 0));
+                               emitcode ("mov", "%s,%s", aop->aop_ptr2->name,
+                                         aopGet (AOP (result), 1));
+                       }
+               }
                freeAsmop (NULL, aop, ic, TRUE);
        } else {
 
@@ -4307,15 +4389,17 @@ genMemPointerSet (operand * right, operand * result, iCode * ic)
                   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 (right)->liveTo > ic->seq || ic->depth)) {
+               if ((AOP_SIZE (right) > 1 &&
+                    !OP_SYMBOL (result)->remat &&
+                    (OP_SYMBOL (right)->liveTo > ic->seq || ic->depth)) && !pi) {
                        int size = AOP_SIZE (right) - 1;
                        emitcode ("sbiw", "%s,%d",frname,size);
                }
        }
 
        /* done */
+       if (pi) pi->generated = 1;
+       freeAsmop (result, NULL, ic, TRUE);
        freeAsmop (right, NULL, ic, TRUE);
 }
 
@@ -4323,7 +4407,7 @@ genMemPointerSet (operand * right, operand * result, iCode * ic)
 /* genGenPointerSet - set value from generic pointer space         */
 /*-----------------------------------------------------------------*/
 static void
-genGenPointerSet (operand * right, operand * result, iCode * ic)
+genGenPointerSet (operand * right, operand * result, iCode * ic, iCode *pi)
 {
        int size, offset;
        int gotFreePtr = 0;
@@ -4339,10 +4423,13 @@ genGenPointerSet (operand * right, operand * result, iCode * ic)
        } else {
                aop = newAsmop(0);
                getFreePtr(ic,&aop,FALSE,TRUE);
-               
-               emitcode ("mov", "r30,%s", aopGet (AOP (result), 0));
-               emitcode ("mov", "r31,%s", aopGet (AOP (result), 1));
-               emitcode ("mov", "r0,%s",  aopGet (AOP (result), 2));
+               if (isRegPair(AOP(result))) {
+                       emitcode ("movw", "r30,%s", aopGet (AOP (result), 0));
+               } else {
+                       emitcode ("mov", "r30,%s", aopGet (AOP (result), 0));
+                       emitcode ("mov", "r31,%s", aopGet (AOP (result), 1));
+               }
+               emitcode ("mov", "r24,%s",  aopGet (AOP (result), 2));
                gotFreePtr=1;
        }
        
@@ -4360,17 +4447,24 @@ genGenPointerSet (operand * right, operand * result, iCode * ic)
                        char *l = aopGet(AOP (right), offset++);
                        MOVR0(l);
                        
-                       if (size) 
+                       if (size || pi
                                emitcode ("call", "__gptrput_pi");
                        else
                                emitcode ("call", "__gptrput");
                }
        }
 
-       freeAsmop (right, NULL, ic, TRUE);
        /* now some housekeeping stuff */
        if (gotFreePtr) {
                /* we had to allocate for this iCode */
+               if (pi) {
+                       if (isRegPair(AOP(result))) {
+                               emitcode ("movw", "%s,r30", aopGet (AOP (result), 0));
+                       } else {
+                               emitcode ("mov", "%s,r30", aopGet (AOP (result), 0));
+                               emitcode ("mov", "%s,r31", aopGet (AOP (result), 1));
+                       }
+               }
                freeAsmop (NULL, aop, ic, TRUE);
        } else {
 
@@ -4379,13 +4473,15 @@ genGenPointerSet (operand * right, operand * result, iCode * ic)
                   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)) {
+               if ((AOP_SIZE (right) > 1 &&
+                    !OP_SYMBOL (result)->remat &&
+                    (OP_SYMBOL (result)->liveTo > ic->seq || ic->depth)) && !pi) {
                        int size = AOP_SIZE (right) - 1;
                        emitcode ("sbiw", "r30,%d",size);
                }
        }
+       if (pi) pi->generated = 1;
+       freeAsmop (right, NULL, ic, TRUE);
        freeAsmop (result, NULL, ic, TRUE);
 }
 
@@ -4393,7 +4489,7 @@ genGenPointerSet (operand * right, operand * result, iCode * ic)
 /* genPointerSet - stores the value into a pointer location        */
 /*-----------------------------------------------------------------*/
 static void
-genPointerSet (iCode * ic)
+genPointerSet (iCode * ic, iCode *pi)
 {
        operand *right, *result;
        sym_link *type, *etype;
@@ -4424,11 +4520,11 @@ genPointerSet (iCode * ic)
        case IPOINTER:
        case PPOINTER:
        case FPOINTER:
-               genMemPointerSet (right, result, ic);
+               genMemPointerSet (right, result, ic, pi);
                break;
 
        case GPOINTER:
-               genGenPointerSet (right, result, ic);
+               genGenPointerSet (right, result, ic, pi);
                break;
        }
 
@@ -4441,35 +4537,39 @@ static void
 genIfx (iCode * ic, iCode * popIc)
 {
        operand *cond = IC_COND (ic);
-       int isbit = 0;
+       char *cname ;
+       symbol *lbl;
 
        aopOp (cond, ic, FALSE);
 
-       /* get the value into acc */
-       if (AOP_TYPE (cond) != AOP_CRY)
-               toBoolean (cond, "", 0);
-       else
-               isbit = 1;
+       /* get the value into acc */    
+       if (AOP_SIZE(cond) == 1 && AOP_ISHIGHREG(AOP(cond),0)) {
+               cname = aopGet(AOP(cond),0);
+       } else {
+               toBoolean (cond, "r24", 1);
+               cname = "r24";
+       }
        /* the result is now in the accumulator */
        freeAsmop (cond, NULL, ic, TRUE);
 
        /* if there was something to be popped then do it */
        if (popIc)
                genIpop (popIc);
-
-       /* if the condition is  a bit variable */
-       /*     if (isbit && IS_ITEMP(cond) && SPIL_LOC(cond)) { */
-       /*  //  genIfxJump(ic,SPIL_LOC(cond)->rname); */
-       /*     } */
-       /*     else */
-       /*  if (isbit && !IS_ITEMP(cond)) */
-       /*    //      genIfxJump(ic,OP_SYMBOL(cond)->rname); */
-       /*  else */
-       /*    // genIfxJump(ic,"a"); */
-
+       
+       emitcode("cpi","%s,0",cname);
+       lbl = newiTempLabel(NULL);
+       if (IC_TRUE(ic)) {
+               emitcode ("brne","L%05d",lbl->key);
+               emitcode ("jmp","L%05d",IC_TRUE(ic)->key);
+               emitcode ("","L%05d:",lbl->key);
+       } else {
+               emitcode ("breq","L%05d",lbl->key);
+               emitcode ("jmp","L%05d",IC_FALSE(ic)->key);
+               emitcode ("","L%05d:",lbl->key);
+       }
        ic->generated = 1;
 }
-
+/* here */
 /*-----------------------------------------------------------------*/
 /* genAddrOf - generates code for address of                       */
 /*-----------------------------------------------------------------*/
@@ -4485,8 +4585,7 @@ genAddrOf (iCode * ic)
           need to get the stack offset of this
           variable */
        if (sym->onStack) {
-               /* if it has an offset then we need to compute
-                  it */
+               /* if it has an offset then we need to compute it */
                if (sym->stack) {
                        emitcode ("mov", "a,_bp");
                        emitcode ("add", "a,#0x%02x",
@@ -4498,24 +4597,10 @@ genAddrOf (iCode * ic)
                        aopPut (AOP (IC_RESULT (ic)), "_bp", 0);
                }
                /* fill the result with zero */
-               size = AOP_SIZE (IC_RESULT (ic)) - 1;
-
-
-               if (options.stack10bit && size < (FPTRSIZE - 1)) {
-                       fprintf (stderr,
-                                "*** warning: pointer to stack var truncated.\n");
-               }
-
-               offset = 1;
+               size = AOP_SIZE (IC_RESULT (ic)) - 2;
+               offset = 2;
                while (size--) {
-                       /* Yuck! */
-                       if (options.stack10bit && offset == 2) {
-                               aopPut (AOP (IC_RESULT (ic)), "#0x40",
-                                       offset++);
-                       }
-                       else {
-                               aopPut (AOP (IC_RESULT (ic)), zero, offset++);
-                       }
+                       aopPut (AOP (IC_RESULT (ic)), zero, offset++);
                }
 
                goto release;
@@ -4528,9 +4613,9 @@ genAddrOf (iCode * ic)
        while (size--) {
                char s[SDCC_NAME_MAX];
                if (offset)
-                       sprintf (s, "#(%s >> %d)", sym->rname, offset * 8);
+                       sprintf (s, "(%s >> %d)", sym->rname, offset * 8);
                else
-                       sprintf (s, "#%s", sym->rname);
+                       sprintf (s, "%s", sym->rname);
                aopPut (AOP (IC_RESULT (ic)), s, offset++);
        }
 
@@ -4788,10 +4873,10 @@ genCast (iCode * ic)
                                l = one;
                                break;
                        case CPOINTER:
-                               l = "#0x02";
+                               l = "0x02";
                                break;
                        case PPOINTER:
-                               l = "#0x03";
+                               l = "0x03";
                                break;
 
                        default:
@@ -5122,12 +5207,12 @@ genAVRCode (iCode * lic)
                        break;
 
                case GET_VALUE_AT_ADDRESS:
-                       genPointerGet (ic);
+                       genPointerGet (ic, hasInc(IC_LEFT(ic),ic));
                        break;
 
                case '=':
                        if (POINTER_SET (ic))
-                               genPointerSet (ic);
+                               genPointerSet (ic, hasInc(IC_RESULT(ic),ic));
                        else
                                genAssign (ic);
                        break;
@@ -5158,8 +5243,6 @@ genAVRCode (iCode * lic)
 
                default:
                        ic = ic;
-                       /*      piCode(ic,stdout); */
-
                }
        }