This isn't needed anymore because of SDCCast.c:1.82
[fw/sdcc] / src / avr / gen.c
index 06258e4f018db076bbaa5f8819728dd17782b3f0..cd262f6eaed8ec4cfee13fccad5ad0b2a3346256 100644 (file)
@@ -293,28 +293,28 @@ emitcode (char *inst, char *fmt, ...)
 static iCode *
 hasInc (operand *op, iCode *ic)
 {
-  sym_link *type = operandType(op);
-  sym_link *retype = getSpec (type);
-  iCode *lic = ic->next;
-  int isize ;
+       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;
+       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(OP_USES(op),lic->key) || ((unsigned) lic->defKey == op->key)) {
+                       return NULL;
+               }
+               lic = lic->next;
+       }
+       return NULL;
 }
 
 /*-----------------------------------------------------------------*/
@@ -475,10 +475,10 @@ aopForSym (iCode * ic, symbol * sym, bool result)
                                                   _G.nRegsSaved));
                                }
                                else {
-                                       emitcode ("subi", "%s,lo8(%d)",
+                                       emitcode ("subi", "%s,<(%d)",
                                                  aop->aopu.aop_ptr->name,
                                                  sym->stack - _G.nRegsSaved);
-                                       emitcode ("sbci", "%s,hi8(%d)",
+                                       emitcode ("sbci", "%s,>(%d)",
                                                  aop->aop_ptr2->name,
                                                  sym->stack - _G.nRegsSaved);
                                }
@@ -490,10 +490,10 @@ aopForSym (iCode * ic, symbol * sym, bool result)
                                                  sym->stack);
                                }
                                else {
-                                       emitcode ("subi", "%s,lo8(-%d)",
+                                       emitcode ("subi", "%s,<(-%d)",
                                                  aop->aopu.aop_ptr->name,
                                                  sym->stack);
-                                       emitcode ("sbci", "%s,hi8(-%d)",
+                                       emitcode ("sbci", "%s,>(-%d)",
                                                  aop->aop_ptr2->name,
                                                  sym->stack);
                                }
@@ -536,8 +536,8 @@ aopForSym (iCode * ic, symbol * sym, bool result)
 
        aop->aopu.aop_ptr = getFreePtr (ic, &aop, result, aop->code);
        aop->size = getSize (sym->type);
-       emitcode ("ldi", "%s,lo8(%s)", aop->aopu.aop_ptr->name, sym->rname);
-       emitcode ("ldi", "%s,hi8(%s)", aop->aop_ptr2);
+       emitcode ("ldi", "%s,<(%s)", aop->aopu.aop_ptr->name, sym->rname);
+       emitcode ("ldi", "%s,>(%s)", aop->aop_ptr2);
 
        return aop;
 }
@@ -852,10 +852,10 @@ freeAsmop (operand * op, asmop * aaop, iCode * ic, bool pop)
                                                  stk + 1);
                                }
                                else {
-                                       emitcode ("subi", "%s,lo8(%d)",
+                                       emitcode ("subi", "%s,<(%d)",
                                                  aop->aopu.aop_ptr->name,
                                                  -(stk + 1));
-                                       emitcode ("sbci", "%s,hi8(%d)",
+                                       emitcode ("sbci", "%s,>(%d)",
                                                  aop->aop_ptr2->name,
                                                  -(stk + 1));
                                }
@@ -985,7 +985,7 @@ aopGet (asmop * aop, int offset)
 
        case AOP_LIT:
                s = aopLiteral (aop->aopu.aop_lit, offset);
-               emitcode ("ldi", "%s,lo8(%s)",
+               emitcode ("ldi", "%s,<(%s)",
                          (rs = ((offset & 1) ? "r24" : "r25")), s);
                return rs;
 
@@ -1225,10 +1225,15 @@ toBoolean (operand * oper, char *r, bool clr)
 {
        int size = AOP_SIZE (oper);
        int offset = 0;
-       if (clr)
+       if (clr) {
                emitcode ("clr", "%s", r);
-       while (size--)
-               emitcode ("or", "%s,%s", r, aopGet (AOP (oper), offset++));
+               while (size--)
+                       emitcode ("or", "%s,%s", r, aopGet (AOP (oper), offset++));
+       } else {
+               size--;
+               emitcode("mov","%s,%s",r,aopGet (AOP (oper), offset++));
+               if (size) while (size--) emitcode ("or", "%s,%s", r, aopGet (AOP (oper), offset++));
+       }
 }
 
 
@@ -1404,7 +1409,7 @@ genUminus (iCode * ic)
                size = AOP_SIZE (IC_LEFT (ic)) - 1;
                offset = 1;
                while (size--) {
-                       emitcode ("sbci", "%s,lo8(-1)",
+                       emitcode ("sbci", "%s,0xff",
                                  aopGet (AOP (IC_RESULT (ic)), offset++));
                }
        }
@@ -1577,9 +1582,9 @@ genCall (iCode * ic)
                        emitcode ("sbiw", "r28,%d", ic->parmBytes);
                }
                else {
-                       emitcode ("subi", "r28,lo8(%d)",
+                       emitcode ("subi", "r28,<(%d)",
                                  ic->parmBytes);
-                       emitcode ("sbci", "r29,hi8(%d)",
+                       emitcode ("sbci", "r29,>(%d)",
                                  ic->parmBytes);
                }
        }
@@ -1660,9 +1665,9 @@ genPcall (iCode * ic)
                        emitcode ("sbiw", "r28,%d", ic->parmBytes);
                }
                else {
-                       emitcode ("subi", "r28,lo8(%d)",
+                       emitcode ("subi", "r28,<(%d)",
                                  ic->parmBytes);
-                       emitcode ("sbci", "r29,hi8(%d)",
+                       emitcode ("sbci", "r29,>(%d)",
                                  ic->parmBytes);
                }
        }
@@ -1755,8 +1760,8 @@ genFunction (iCode * ic)
                        emitcode ("sbiw", "r28,%d", sym->stack);
                }
                else {
-                       emitcode ("subi", "r28,lo8(%d)", sym->stack);
-                       emitcode ("sbci", "r29,hi8(%d)", sym->stack);
+                       emitcode ("subi", "r28,<(%d)", sym->stack);
+                       emitcode ("sbci", "r29,>(%d)", sym->stack);
                }
                emitcode ("out", "__SP_L__,r28");
                emitcode ("out", "__SP_H__,r29");
@@ -1778,8 +1783,8 @@ genEndFunction (iCode * ic)
                        emitcode ("adiw", "r28,%d", sym->stack);
                }
                else {
-                       emitcode ("subi", "r28,lo8(-%d)", sym->stack);
-                       emitcode ("sbci", "r29,hi8(-%d)", sym->stack);
+                       emitcode ("subi", "r28,<(-%d)", sym->stack);
+                       emitcode ("sbci", "r29,>(-%d)", sym->stack);
                }
                emitcode ("out", "__SP_L__,r28");
                emitcode ("out", "__SP_H__,r29");
@@ -1890,7 +1895,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));
 }
 
 /*-----------------------------------------------------------------*/
@@ -1900,6 +1905,7 @@ static bool
 genPlusIncr (iCode * ic)
 {
        unsigned int icount;
+       int offset = 0;
 
        /* will try to generate an increment */
        /* if the right side is not a literal
@@ -1907,8 +1913,7 @@ genPlusIncr (iCode * ic)
        if (AOP_TYPE (IC_RIGHT (ic)) != AOP_LIT)
                return FALSE;
 
-       icount =
-               (unsigned int) floatFromVal (AOP (IC_RIGHT (ic))->aopu.
+       icount = (unsigned int) floatFromVal (AOP (IC_RIGHT (ic))->aopu.
                                             aop_lit);
 
        /* if the sizes are greater than 2 or they are not the same regs
@@ -1925,34 +1930,41 @@ genPlusIncr (iCode * ic)
                                  aopGet (AOP (IC_LEFT (ic)), 0));
                        return TRUE;
                }
-               emitcode ("subi", "%s,lo8(%d)",
-                         aopGet (AOP (IC_LEFT (ic)), 0), 0-icount);
-               return TRUE;
+               if (AOP_ISHIGHREG( AOP (IC_LEFT (ic)),0)) {
+                       emitcode ("subi", "%s,<(%d)",
+                                 aopGet (AOP (IC_LEFT (ic)), 0), 0-icount);
+                       return TRUE;
+               }
+       }
+
+       for (offset = 0 ; offset < AOP_SIZE(IC_RESULT(ic)) ; offset++) {
+               if (!(AOP_ISHIGHREG(AOP(IC_RESULT(ic)),offset))) return FALSE;
        }
 
        if (AOP_SIZE (IC_RESULT (ic)) <= 3) {
                /* if register pair and starts with 26/30 then adiw */
                if (isRegPair (AOP (IC_RESULT (ic))) && icount > 0
                    && icount < 64
-                   && (IS_REGIDX (AOP (IC_RESULT (ic)), R26_IDX)
-                       || IS_REGIDX (AOP (IC_RESULT (ic)), R30_IDX))) {
+                   && (IS_REGIDX (AOP (IC_RESULT (ic)), R26_IDX) || 
+                       IS_REGIDX (AOP (IC_RESULT (ic)), R24_IDX) || 
+                       IS_REGIDX (AOP (IC_RESULT (ic)), R30_IDX))) {
                        emitcode ("adiw", "%s,%d",
                                  aopGet (AOP (IC_RESULT (ic)), 0), icount);
                        return TRUE;
                }
 
                /* use subi */
-               emitcode ("subi", "%s,lo8(%d)",
+               emitcode ("subi", "%s,<(%d)",
                          aopGet (AOP (IC_RESULT (ic)), 0), 0-icount);
-               emitcode ("sbci", "%s,hi8(%d)",
+               emitcode ("sbci", "%s,>(%d)",
                          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),
+       emitcode ("subi", "%s,<(%d)", aopGet (AOP (IC_RESULT (ic)), 0),
                  0-icount);
-       emitcode ("sbci", "%s,hi8(%d)", aopGet (AOP (IC_RESULT (ic)), 1),
+       emitcode ("sbci", "%s,>(%d)", aopGet (AOP (IC_RESULT (ic)), 1),
                  0-icount);
        emitcode ("sbci", "%s,hlo8(%d)", aopGet (AOP (IC_RESULT (ic)), 2),
                  0-icount);
@@ -2038,16 +2050,27 @@ genPlus (iCode * ic)
                                  aopGet (AOP (IC_RIGHT (ic)), offset));
                }
                else {
-                       if (offset == 0)
-                               l = "subi";
-                       else
-                               l = "sbci";
-
-                       emitcode (l, "%s,%s(-%d)",
-                                 aopGet (AOP (IC_RESULT (ic)), offset),
-                                 larray[offset],
-                                 (int) floatFromVal (AOP (IC_RIGHT (ic))->
-                                                     aopu.aop_lit));
+                       if (AOP_ISHIGHREG( AOP( IC_RESULT(ic)),offset)) {
+                               if (offset == 0)
+                                       l = "subi";
+                               else
+                                       l = "sbci";
+                               
+                               emitcode (l, "%s,%s(-%d)",
+                                         aopGet (AOP (IC_RESULT (ic)), offset),
+                                         larray[offset],
+                                         (int) floatFromVal (AOP (IC_RIGHT (ic))->
+                                                             aopu.aop_lit));
+                       } else {
+                               if (offset == 0)
+                                       l = "add";
+                               else
+                                       l = "adc";
+                               
+                               emitcode (l, "%s,%s",
+                                         aopGet (AOP (IC_RESULT (ic)), offset),
+                                         aopGet (AOP (IC_RIGHT (ic)), offset));
+                       }
                }
                offset++;
        }
@@ -2069,6 +2092,7 @@ static bool
 genMinusDec (iCode * ic)
 {
        unsigned int icount;
+       int offset ;
 
        /* will try to generate an increment */
        /* if the right side is not a literal
@@ -2094,33 +2118,40 @@ genMinusDec (iCode * ic)
                                  aopGet (AOP (IC_LEFT (ic)), 0));
                        return TRUE;
                }
-               emitcode ("subi", "%s,lo8(%d)",
-                         aopGet (AOP (IC_LEFT (ic)), 0), icount);
-               return TRUE;
+               if (AOP_ISHIGHREG( AOP ( IC_LEFT(ic)),0)) {
+                       emitcode ("subi", "%s,<(%d)",
+                                 aopGet (AOP (IC_LEFT (ic)), 0), icount);
+                       return TRUE;
+               }
+       }
+
+       for (offset = 0 ; offset < AOP_SIZE(IC_RESULT(ic)) ; offset++) {
+               if (!(AOP_ISHIGHREG(AOP(IC_RESULT(ic)),offset))) return FALSE;
        }
 
        if (AOP_SIZE (IC_RESULT (ic)) <= 3) {
                /* if register pair and starts with 26/30 then adiw */
                if (isRegPair (AOP (IC_RESULT (ic))) && icount > 0
                    && icount < 64
-                   && (IS_REGIDX (AOP (IC_RESULT (ic)), R26_IDX)
-                       || IS_REGIDX (AOP (IC_RESULT (ic)), R30_IDX))) {
+                   && (IS_REGIDX (AOP (IC_RESULT (ic)), R26_IDX) || 
+                       IS_REGIDX (AOP (IC_RESULT (ic)), R24_IDX) || 
+                       IS_REGIDX (AOP (IC_RESULT (ic)), R30_IDX))) {
                        emitcode ("sbiw", "%s,%d",
                                  aopGet (AOP (IC_RESULT (ic)), 0), icount);
                        return TRUE;
                }
 
                /* use subi */
-               emitcode ("subi", "%s,lo8(%d)",
+               emitcode ("subi", "%s,<(%d)",
                          aopGet (AOP (IC_RESULT (ic)), 0), icount);
-               emitcode ("sbci", "%s,hi8(%d)",
+               emitcode ("sbci", "%s,>(%d)",
                          aopGet (AOP (IC_RESULT (ic)), 1), icount);
                return TRUE;
        }
        /* for 32 bit longs */
-       emitcode ("subi", "%s,lo8(%d)", aopGet (AOP (IC_RESULT (ic)), 0),
+       emitcode ("subi", "%s,<(%d)", aopGet (AOP (IC_RESULT (ic)), 0),
                  icount);
-       emitcode ("sbci", "%s,hi8(%d)", aopGet (AOP (IC_RESULT (ic)), 1),
+       emitcode ("sbci", "%s,>(%d)", aopGet (AOP (IC_RESULT (ic)), 1),
                  icount);
        emitcode ("sbci", "%s,hlo8(%d)", aopGet (AOP (IC_RESULT (ic)), 2),
                  icount);
@@ -2167,16 +2198,27 @@ genMinus (iCode * ic)
                                  aopGet (AOP (IC_RIGHT (ic)), offset));
                }
                else {
-                       if (offset == 0)
-                               l = "subi";
-                       else
-                               l = "sbci";
-
-                       emitcode (l, "%s,%s(%d)",
-                                 aopGet (AOP (IC_RESULT (ic)), offset),
-                                 larray[offset],
-                                 (int) floatFromVal (AOP (IC_RIGHT (ic))->
-                                                     aopu.aop_lit));
+                       if (AOP_ISHIGHREG(AOP (IC_RESULT (ic)),offset)) {
+                               if (offset == 0)
+                                       l = "subi";
+                               else
+                                       l = "sbci";
+                               
+                               emitcode (l, "%s,%s(%d)",
+                                         aopGet (AOP (IC_RESULT (ic)), offset),
+                                         larray[offset],
+                                         (int) floatFromVal (AOP (IC_RIGHT (ic))->
+                                                             aopu.aop_lit));
+                       } else {
+                               if (offset == 0)
+                                       l = "sub";
+                               else
+                                       l = "sbc";
+                               
+                               emitcode (l, "%s,%s",
+                                         aopGet (AOP (IC_RESULT (ic)), offset),
+                                         aopGet (AOP (IC_RIGHT (ic)), offset));
+                       }
                }
                offset++;
        }
@@ -2234,7 +2276,7 @@ genMultOneByte (operand * left, operand * right, operand * result)
                                lbl = newiTempLabel (NULL);
                                emitcode ("ldi", "r24,0");
                                emitcode ("brcc", "L%05d", lbl->key);
-                               emitcode ("ldi", "r24,lo8(-1)");
+                               emitcode ("ldi", "r24,0xff)");
                                emitcode ("", "L%05d:", lbl->key);
                                while (size--)
                                        aopPut (AOP (result), "r24",
@@ -2380,7 +2422,7 @@ genCmp (iCode * ic, iCode * ifx, int br_type)
        if (ifx) {
                if (size == 1) {
                        if (AOP_TYPE (right) == AOP_LIT) {
-                               emitcode ("cpi", "%s,lo8(%d)",
+                               emitcode ("cpi", "%s,<(%d)",
                                          aopGet (AOP (left), 0),
                                          (int)
                                          floatFromVal (AOP (IC_RIGHT (ic))->
@@ -2646,12 +2688,12 @@ genBitWise (iCode * ic, iCode * ifx, int bitop)
                                if (size == 1) {
                                        if (eh && AOP_ISHIGHREG(AOP(IC_LEFT(ic)),0)) {
                                                emitcode (bopnames_lit[bitop],
-                                                         "%s,lo8(%d)",
+                                                         "%s,<(%d)",
                                                          aopGet (AOP (IC_LEFT (ic)), 0), lit);
                                        }
                                        else {
                                                MOVR24 (aopGet (AOP (IC_LEFT (ic)), 0));
-                                               emitcode (bopnames_lit[bitop], "r24,lo8(%d)", lit);
+                                               emitcode (bopnames_lit[bitop], "r24,<(%d)", lit);
                                        }
                                        lbl = newiTempLabel (NULL);
                                        if (IC_TRUE (ifx)) {
@@ -2667,8 +2709,8 @@ genBitWise (iCode * ic, iCode * ifx, int bitop)
                                else if (size == 2) {
                                        emitcode ("mov", "r24,%s", aopGet (AOP (IC_LEFT (ic)), 0));
                                        emitcode ("mov", "r25,%s", aopGet (AOP (IC_LEFT (ic)), 1));
-                                       emitcode (bopnames_lit[bitop], "r24,lo8(%d)", lit);
-                                       emitcode (bopnames_lit[bitop], "r25,hi8(%d)", lit);
+                                       emitcode (bopnames_lit[bitop], "r24,<(%d)", lit);
+                                       emitcode (bopnames_lit[bitop], "r25,>(%d)", lit);
                                        emitcode ("sbiw", "r24,0");
                                        lbl = newiTempLabel (NULL);
                                        if (IC_TRUE (ifx)) {
@@ -2686,14 +2728,14 @@ genBitWise (iCode * ic, iCode * ifx, int bitop)
                                        lbl1 = newiTempLabel (NULL);
                                        while (size--) {
                                                if (eh && AOP_ISHIGHREG(AOP(IC_LEFT(ic)),offset)) {
-                                                       emitcode (bopnames_lit [bitop], "%s,lo8(%d)",
+                                                       emitcode (bopnames_lit [bitop], "%s,<(%d)",
                                                                  aopGet (AOP (IC_LEFT (ic)), offset),
                                                                  lit);
                                                }
                                                else {
                                                        char *l = aopGet (AOP (IC_LEFT (ic)), offset);
                                                        MOVR24 (l);
-                                                       emitcode ("andi", "r24,lo8(%d)", lit);
+                                                       emitcode ("andi", "r24,<(%d)", lit);
                                                }
                                                emitcode ("brne", "L%05d", lbl->key);
                                                offset++;
@@ -3010,13 +3052,13 @@ genGetHbit (iCode * ic)
        if (!sameRegs (AOP (left), AOP (result))) {
                emitcode ("clr", "%s", aopGet (AOP (result), size - 1));
                emitcode ("sbrc", "%s,7", aopGet (AOP (left), size - 1));
-               emitcode ("subi", "%s,lo8(-1)",
+               emitcode ("subi", "%s,<(-1)",
                          aopGet (AOP (result), size - 1));
        }
        else {
                emitcode ("clr", "r0");
                emitcode ("sbrc", "%s,7", aopGet (AOP (left), size - 1));
-               emitcode ("subi", "r0,lo8(-1)");
+               emitcode ("subi", "r0,<(-1)");
                aopPut (AOP (result), "r0", 0);
        }
        offset = 1;
@@ -3321,34 +3363,34 @@ genShiftRightLit (iCode * ic)
                                        aopGet (AOP (left), offset), offset);
                                offset++;
                        }
-                       size = size = AOP_SIZE (result);
+                       size = AOP_SIZE (result);
                        offset = 0;
                }
                /* be as economical as possible */
                if (shCount <= 4) {
-                       offset = size - 1;
                        while (shCount--) {
-                               offset = size - 1;
                                size = AOP_SIZE (result);
+                               offset = size - 1;
                                while (size--) {
-                                       if (offset == (size - 1))
+                                       /* highest order byte */
+                                       if (offset == (AOP_SIZE(result)-1)) 
                                                emitcode ("asr", "%s", aopGet (AOP (result), offset));
                                        else
-                                               emitcode ("lsr", "%s", aopGet (AOP (result), offset));
-                                       offset--;
+                                               emitcode ("ror", "%s", aopGet (AOP (result), offset));
+                                       offset--;                                               
                                }
                        }
                }
                else {
-                       emitcode ("ldi", "r24,lo8(%d)", shCount);
+                       emitcode ("ldi", "r24,<(%d)", shCount);
                        tlbl = newiTempLabel (NULL);
                        emitcode ("", "L%05d:", tlbl->key);
                        offset = size - 1;
                        while (size--) {
-                               if (offset == (size - 1))
+                               if (offset == (AOP_SIZE(result) - 1))
                                        emitcode ("asr", "%s", aopGet (AOP (result), offset));
                                else
-                                       emitcode ("lsr", "%s", aopGet (AOP (result), offset));
+                                       emitcode ("ror", "%s", aopGet (AOP (result), offset));
                                offset--;
                        }
                        emitcode ("dec", "r24");
@@ -4547,6 +4589,7 @@ genIfx (iCode * ic, iCode * popIc)
        operand *cond = IC_COND (ic);
        char *cname ;
        symbol *lbl;
+       int tob = 0;
 
        aopOp (cond, ic, FALSE);
 
@@ -4554,24 +4597,32 @@ genIfx (iCode * ic, iCode * popIc)
        if (AOP_SIZE(cond) == 1 && AOP_ISHIGHREG(AOP(cond),0)) {
                cname = aopGet(AOP(cond),0);
        } else {
-               toBoolean (cond, "r24", 1);
+               toBoolean (cond, "r24", 0);
+               tob = 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)
+       if (popIc) {
                genIpop (popIc);
-       
-       emitcode("cpi","%s,0",cname);
+               emitcode("cpi","%s,0",cname);
+       } else if (!tob) emitcode("cpi","%s,0",cname);
+
        lbl = newiTempLabel(NULL);
        if (IC_TRUE(ic)) {
-               emitcode ("brne","L%05d",lbl->key);
+               if (tob)
+                       emitcode ("breq","L%05d",lbl->key);
+               else
+                       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);
+               if (tob)
+                       emitcode ("brne","L%05d",lbl->key);
+               else
+                       emitcode ("breq","L%05d",lbl->key);
                emitcode ("jmp","L%05d",IC_FALSE(ic)->key);
                emitcode ("","L%05d:",lbl->key);
        }
@@ -4588,16 +4639,17 @@ genAddrOf (iCode * ic)
        int size, offset;
 
        aopOp (IC_RESULT (ic), ic, FALSE);
-
+       assert(AOP_SIZE(IC_RESULT(ic)) >= 2);
        /* if the operand is on the stack then we
           need to get the stack offset of this
           variable */
        if (sym->onStack) {
                /* if it has an offset then we need to compute it */
                if (sym->stack) {
-                       emitcode ("mov", "a,_bp");
-                       emitcode ("add", "a,#0x%02x",
+#if 0
+                       if (AOP_ISHIGHREG(AOP(
                                  ((char) sym->stack & 0xff));
+#endif
                        aopPut (AOP (IC_RESULT (ic)), "a", 0);
                }
                else {
@@ -5041,7 +5093,7 @@ genAVRCode (iCode * lic)
        if (currFunc) {
                cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
                _G.debugLine = 1;
-               emitcode ("", ".type %s,@function", currFunc->name);
+/*             emitcode ("", ".type %s,@function", currFunc->name); */
                _G.debugLine = 0;
        }
        /* stack pointer name */