Some more improvements on AVR
[fw/sdcc] / src / avr / gen.c
index a388da89887b003160663c00d631259dbcd5b1cd..df9f1bee99c707517a615fb1c9928d1eb45bd06a 100644 (file)
@@ -37,7 +37,7 @@
 #ifdef HAVE_ENDIAN_H
 #include <endian.h>
 #else
-#if !defined(__BORLANDC__) && !defined(_MSC_VER)
+#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__)
 #warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
 #warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
 #endif
@@ -64,9 +64,21 @@ static char *spname;
 char *fReturnAVR[] = { "r16", "r17", "r18", "r19" };
 unsigned fAVRReturnSize = 4;   /* shared with ralloc.c */
 char **fAVRReturn = fReturnAVR;
-static short rbank = -1;
 static char *larray[4] = { "lo8", "hi8", "hlo8", "hhi8" };
+
+#if 0
+// PENDING: Unused
+static short rbank = -1;
 static char *tscr[4] = { "r0", "r1", "r24", "r25" };
+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 struct {
        short xPushed;
        short zPushed;
@@ -80,7 +92,6 @@ static struct {
 extern int avr_ptrRegReq;
 extern int avr_nRegs;
 extern FILE *codeOutFile;
-static void saverbank (int, iCode *, bool);
 #define RESULTONSTACK(x) \
                          (IC_RESULT(x) && IC_RESULT(x)->aop && \
                          IC_RESULT(x)->aop->type == AOP_STK )
@@ -96,18 +107,152 @@ static void saverbank (int, iCode *, bool);
 static lineNode *lineHead = NULL;
 static lineNode *lineCurr = NULL;
 
-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
-};
-
 #define LSB     0
 #define MSB16   1
 #define MSB24   2
 #define MSB32   3
 
+#if 0
+// PENDING: Unused.
+/*-----------------------------------------------------------------*/
+/* reAdjustPreg - points a register back to where it should        */
+/*-----------------------------------------------------------------*/
+static void
+reAdjustPreg (asmop * aop)
+{
+       int size;
+
+       aop->coff = 0;
+       if ((size = aop->size) <= 1)
+               return;
+       size--;
+       switch (aop->type) {
+       case AOP_X:
+       case AOP_Z:
+               emitcode ("sbiw", "%s,%d", aop->aopu.aop_ptr->name, size);
+               break;
+       }
+
+}
+
+/*-----------------------------------------------------------------*/
+/* outBitC - output a bit C                                        */
+/*-----------------------------------------------------------------*/
+static void
+outBitC (operand * result)
+{
+       emitcode ("clr", "r0");
+       emitcode ("rol", "r0");
+       outAcc (result);
+}
+
+/*-----------------------------------------------------------------*/
+/* inExcludeList - return 1 if the string is in exclude Reg list   */
+/*-----------------------------------------------------------------*/
+static bool
+inExcludeList (char *s)
+{
+       int i = 0;
+
+       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;
+}
+
+/*-----------------------------------------------------------------*/
+/* findLabelBackwards: walks back through the iCode chain looking  */
+/* for the given label. Returns number of iCode instructions     */
+/* between that label and given ic.          */
+/* Returns zero if label not found.          */
+/*-----------------------------------------------------------------*/
+static int
+findLabelBackwards (iCode * ic, int key)
+{
+       int count = 0;
+
+       while (ic->prev) {
+               ic = ic->prev;
+               count++;
+
+               if (ic->op == LABEL && IC_LABEL (ic)->key == key) {
+                       /* printf("findLabelBackwards = %d\n", count); */
+                       return count;
+               }
+       }
+
+       return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* addSign - complete with sign                                    */
+/*-----------------------------------------------------------------*/
+static void
+addSign (operand * result, int offset, int sign)
+{
+       int size = (getDataSize (result) - offset);
+       if (size > 0) {
+               if (sign) {
+                       emitcode ("rlc", "a");
+                       emitcode ("subb", "a,acc");
+                       while (size--)
+                               aopPut (AOP (result), "a", offset++);
+               }
+               else
+                       while (size--)
+                               aopPut (AOP (result), zero, offset++);
+       }
+}
+
+/*-----------------------------------------------------------------*/
+/* 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;
+
+       for (idx = 0; idx < 32; idx++)
+               if (lit == pw[idx])
+                       return idx + 1;
+       return 0;
+}
+
+/*-----------------------------------------------------------------*/
+/* outAcc - output Acc                                             */
+/*-----------------------------------------------------------------*/
+static void
+outAcc (operand * result)
+{
+       int size, offset;
+       size = getDataSize (result);
+       if (size) {
+               aopPut (AOP (result), "r0", 0);
+               size--;
+               offset = 1;
+               /* unsigned or positive */
+               while (size--) {
+                       aopPut (AOP (result), zero, offset++);
+               }
+       }
+}
+
+#endif // End Unused code section
+
 /*-----------------------------------------------------------------*/
 /* emitcode - writes the code into a file : for now it is simple    */
 /*-----------------------------------------------------------------*/
@@ -115,7 +260,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);
@@ -164,7 +309,7 @@ hasInc (operand *op, iCode *ic)
       return lic;
     }
     /* if the operand used or deffed */
-    if (bitVectBitValue(ic->uses,op->key) || ic->defKey == op->key) {
+    if (bitVectBitValue(ic->uses,op->key) || ((unsigned) ic->defKey == op->key)) {
       return NULL;
     }
     lic = lic->next;
@@ -258,7 +403,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");
@@ -331,10 +475,10 @@ aopForSym (iCode * ic, symbol * sym, bool result)
                                                   _G.nRegsSaved));
                                }
                                else {
-                                       emitcode ("subi", "%s,lo8(%d)",
+                                       emitcode ("subi", "%s,(%d & 0xff)",
                                                  aop->aopu.aop_ptr->name,
                                                  sym->stack - _G.nRegsSaved);
-                                       emitcode ("sbci", "%s,hi8(%d)",
+                                       emitcode ("sbci", "%s,((%d >> 8) & 0xff)",
                                                  aop->aop_ptr2->name,
                                                  sym->stack - _G.nRegsSaved);
                                }
@@ -346,10 +490,10 @@ aopForSym (iCode * ic, symbol * sym, bool result)
                                                  sym->stack);
                                }
                                else {
-                                       emitcode ("subi", "%s,lo8(-%d)",
+                                       emitcode ("subi", "%s,((-%d) & 0xff)",
                                                  aop->aopu.aop_ptr->name,
                                                  sym->stack);
-                                       emitcode ("sbci", "%s,hi8(-%d)",
+                                       emitcode ("sbci", "%s,(((-%d) >> 8) & 0xff))",
                                                  aop->aop_ptr2->name,
                                                  sym->stack);
                                }
@@ -538,7 +682,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;
@@ -600,7 +744,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;
@@ -987,27 +1131,6 @@ aopPut (asmop * aop, char *s, int offset)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* reAdjustPreg - points a register back to where it should        */
-/*-----------------------------------------------------------------*/
-static void
-reAdjustPreg (asmop * aop)
-{
-       int size;
-
-       aop->coff = 0;
-       if ((size = aop->size) <= 1)
-               return;
-       size--;
-       switch (aop->type) {
-       case AOP_X:
-       case AOP_Z:
-               emitcode ("sbiw", "%s,%d", aop->aopu.aop_ptr->name, size);
-               break;
-       }
-
-}
-
 #define AOP(op) op->aop
 #define AOP_TYPE(op) AOP(op)->type
 #define AOP_SIZE(op) AOP(op)->size
@@ -1094,36 +1217,6 @@ getDataSize (operand * op)
        return size;
 }
 
-/*-----------------------------------------------------------------*/
-/* outAcc - output Acc                                             */
-/*-----------------------------------------------------------------*/
-static void
-outAcc (operand * result)
-{
-       int size, offset;
-       size = getDataSize (result);
-       if (size) {
-               aopPut (AOP (result), "r0", 0);
-               size--;
-               offset = 1;
-               /* unsigned or positive */
-               while (size--) {
-                       aopPut (AOP (result), zero, offset++);
-               }
-       }
-}
-
-/*-----------------------------------------------------------------*/
-/* outBitC - output a bit C                                        */
-/*-----------------------------------------------------------------*/
-static void
-outBitC (operand * result)
-{
-       emitcode ("clr", "r0");
-       emitcode ("rol", "r0");
-       outAcc (result);
-}
-
 /*-----------------------------------------------------------------*/
 /* toBoolean - emit code for orl a,operator(sizeop)                */
 /*-----------------------------------------------------------------*/
@@ -1132,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++));
+       }
 }
 
 
@@ -1601,26 +1699,6 @@ resultRemat (iCode * ic)
 #define STRCASECMP strcasecmp
 #endif
 
-/*-----------------------------------------------------------------*/
-/* inExcludeList - return 1 if the string is in exclude Reg list   */
-/*-----------------------------------------------------------------*/
-static bool
-inExcludeList (char *s)
-{
-       int i = 0;
-
-       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;
-}
-
 /*-----------------------------------------------------------------*/
 /* genFunction - generated code for function entry                 */
 /*-----------------------------------------------------------------*/
@@ -1817,31 +1895,7 @@ genLabel (iCode * ic)
 static void
 genGoto (iCode * ic)
 {
-       emitcode ("rjmp", "L%05d:", (IC_LABEL (ic)->key + 100));
-}
-
-/*-----------------------------------------------------------------*/
-/* findLabelBackwards: walks back through the iCode chain looking  */
-/* for the given label. Returns number of iCode instructions     */
-/* between that label and given ic.          */
-/* Returns zero if label not found.          */
-/*-----------------------------------------------------------------*/
-static int
-findLabelBackwards (iCode * ic, int key)
-{
-       int count = 0;
-
-       while (ic->prev) {
-               ic = ic->prev;
-               count++;
-
-               if (ic->op == LABEL && IC_LABEL (ic)->key == key) {
-                       /* printf("findLabelBackwards = %d\n", count); */
-                       return count;
-               }
-       }
-
-       return 0;
+       emitcode ("rjmp", "L%05d", (IC_LABEL (ic)->key));
 }
 
 /*-----------------------------------------------------------------*/
@@ -1877,7 +1931,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;
        }
 
@@ -1894,21 +1948,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;
 
 }
@@ -2081,26 +2135,6 @@ genMinusDec (iCode * ic)
 
 }
 
-/*-----------------------------------------------------------------*/
-/* addSign - complete with sign                                    */
-/*-----------------------------------------------------------------*/
-static void
-addSign (operand * result, int offset, int sign)
-{
-       int size = (getDataSize (result) - offset);
-       if (size > 0) {
-               if (sign) {
-                       emitcode ("rlc", "a");
-                       emitcode ("subb", "a,acc");
-                       while (size--)
-                               aopPut (AOP (result), "a", offset++);
-               }
-               else
-                       while (size--)
-                               aopPut (AOP (result), zero, offset++);
-       }
-}
-
 /*-----------------------------------------------------------------*/
 /* genMinus - generates code for subtraction                       */
 /*-----------------------------------------------------------------*/
@@ -2567,28 +2601,6 @@ genOrOp (iCode * ic)
        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;
-
-       for (idx = 0; idx < 32; idx++)
-               if (lit == pw[idx])
-                       return idx + 1;
-       return 0;
-}
-
 enum {
        AVR_AND = 0, AVR_OR, AVR_XOR
 };
@@ -2887,11 +2899,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 */
@@ -3314,21 +3326,21 @@ 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--;                                               
                                }
                        }
                }
@@ -3338,10 +3350,10 @@ genShiftRightLit (iCode * ic)
                        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");
@@ -4015,10 +4027,13 @@ genGenPointerGet (operand * left, operand * result, iCode * ic, iCode *pi)
        } 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;
        }
 
@@ -4537,6 +4552,7 @@ genIfx (iCode * ic, iCode * popIc)
        operand *cond = IC_COND (ic);
        char *cname ;
        symbol *lbl;
+       int tob = 0;
 
        aopOp (cond, ic, FALSE);
 
@@ -4544,30 +4560,38 @@ 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);
        }
        ic->generated = 1;
 }
-
+/* here */
 /*-----------------------------------------------------------------*/
 /* genAddrOf - generates code for address of                       */
 /*-----------------------------------------------------------------*/
@@ -4583,8 +4607,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",
@@ -4596,24 +4619,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;
@@ -4626,9 +4635,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++);
        }
 
@@ -4886,10 +4895,10 @@ genCast (iCode * ic)
                                l = one;
                                break;
                        case CPOINTER:
-                               l = "#0x02";
+                               l = "0x02";
                                break;
                        case PPOINTER:
-                               l = "#0x03";
+                               l = "0x03";
                                break;
 
                        default:
@@ -4932,8 +4941,11 @@ genCast (iCode * ic)
        }
        else {
                /* we need to extend the sign :{ */
+                // PENDING: Does nothing on avr
+#if 0
                char *l = aopGet (AOP (right), AOP_SIZE (right) - 1);
                MOVA (l);
+#endif
                emitcode ("rlc", "a");
                emitcode ("subb", "a,acc");
                while (size--)
@@ -5005,7 +5017,8 @@ genDjnz (iCode * ic, iCode * ifx)
 static char *recvregs[8] = {
        "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23"
 };
-static recvCnt = 0;
+
+static int recvCnt = 0;
 
 /*-----------------------------------------------------------------*/
 /* genReceive - generate code for a receive iCode                  */
@@ -5042,7 +5055,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 */
@@ -5256,8 +5269,6 @@ genAVRCode (iCode * lic)
 
                default:
                        ic = ic;
-                       /*      piCode(ic,stdout); */
-
                }
        }