From 2ac436263eb41eda4ad7c56f84e2743c121e45b6 Mon Sep 17 00:00:00 2001 From: jtvolpe Date: Fri, 20 Apr 2001 02:49:24 +0000 Subject: [PATCH 1/1] Fixed mixed type compares and conversions git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@748 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/pic/gen.c | 14 +++++--------- src/pic/genarith.c | 19 ++----------------- src/pic/glue.c | 2 +- src/pic/ralloc.c | 6 +----- 4 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/pic/gen.c b/src/pic/gen.c index 0c8d2825..e42fc0b0 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -36,10 +36,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#if defined(_MSC_VER) -#define __FUNCTION__ __FILE__ -#endif - #ifdef HAVE_SYS_ISA_DEFS_H #include #else @@ -468,9 +464,9 @@ static asmop *aopForRemat (symbol *sym) DEBUGpic14_emitcode(";","%s %d",__FUNCTION__,__LINE__); for (;;) { if (ic->op == '+') - val += operandLitValue(IC_RIGHT(ic)); + val += (int) operandLitValue(IC_RIGHT(ic)); else if (ic->op == '-') - val -= operandLitValue(IC_RIGHT(ic)); + val -= (int) operandLitValue(IC_RIGHT(ic)); else break; @@ -681,7 +677,7 @@ void aopOp (operand *op, iCode *ic, bool result) } if (sym->ruonly ) { - int i; + unsigned i; aop = op->aop = sym->aop = newAsmop(AOP_STR); aop->size = getSize(sym->type); for ( i = 0 ; i < fReturnSizePic ; i++ ) @@ -7032,7 +7028,7 @@ static void genDataPointerSet(operand *right, sprintf(buffer,"%s",l); if (AOP_TYPE(right) == AOP_LIT) { - unsigned int lit = floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit); + unsigned int lit = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit); lit = lit >> (8*offset); if(lit&0xff) { pic14_emitcode("movlw","%d",lit); @@ -7131,7 +7127,7 @@ static void genNearPointerSet (operand *right, } else { if (AOP_TYPE(right) == AOP_LIT) { - unsigned int lit = floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit); + unsigned int lit = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit); if(lit) { pic14_emitcode("movlw","%s",l); pic14_emitcode("movwf","indf ;2"); diff --git a/src/pic/genarith.c b/src/pic/genarith.c index 8aadcda2..d056e5cc 100644 --- a/src/pic/genarith.c +++ b/src/pic/genarith.c @@ -59,21 +59,6 @@ #include "pcode.h" #include "gen.h" - - - - - - - - - - - - - - - /*-----------------------------------------------------------------*/ /* genPlusIncr :- does addition with increment if possible */ /*-----------------------------------------------------------------*/ @@ -97,7 +82,7 @@ bool genPlusIncr (iCode *ic) DEBUGpic14_emitcode ("; ","%s %d",__FUNCTION__,__LINE__); /* if the literal value of the right hand side is greater than 1 then it is faster to add */ - if ((icount = floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 2) + if ((icount = (unsigned int) floatFromVal (AOP(IC_RIGHT(ic))->aopu.aop_lit)) > 2) return FALSE ; /* if increment 16 bits in register */ @@ -383,7 +368,7 @@ void genPlus (iCode *ic) if(AOP(IC_RIGHT(ic))->type == AOP_LIT) { /* Add a literal to something else */ bool know_W=0; - unsigned lit = floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); + unsigned lit = (unsigned) floatFromVal(AOP(IC_RIGHT(ic))->aopu.aop_lit); unsigned l1=0; offset = 0; diff --git a/src/pic/glue.c b/src/pic/glue.c index 32f86b4e..8ede432f 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -105,7 +105,7 @@ int pic14aopLiteral (value *val, int offset) /* if it is a float then it gets tricky */ /* otherwise it is fairly simple */ if (!IS_FLOAT(val->type)) { - unsigned long v = floatFromVal(val); + unsigned long v = (unsigned long) floatFromVal(val); //v >>= (offset * 8); return ( (v >> (offset * 8)) & 0xff); diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index e3b92273..47f44544 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -29,10 +29,6 @@ #include "pcode.h" #include "gen.h" -#if defined(_MSC_VER) -#define __FUNCTION__ __FILE__ -#endif - /*-----------------------------------------------------------------*/ /* At this point we start getting processor specific although */ /* some routines are non-processor specific & can be reused when */ @@ -1580,7 +1576,7 @@ serialRegAssign (eBBlock ** ebbs, int count) /* if we need ptr regs for the right side then mark it */ if (POINTER_GET (ic) && getSize (OP_SYMBOL (IC_LEFT (ic))->type) - <= PTRSIZE) + <= (unsigned) PTRSIZE) { pic14_ptrRegReq++; ptrRegSet = 1; -- 2.30.2