Fixed up ENDIAN warning with mingw32. Added ability to disable ucsim and device...
[fw/sdcc] / src / pic / gen.c
index 0c8d2825a42487c7467903567fe6791e23ac6484..023ee3e7995ff7133d3b8c96db6b046a0eebb331 100644 (file)
 #include "SDCCglobl.h"
 #include "newalloc.h"
 
-#if defined(_MSC_VER)
-#define __FUNCTION__           __FILE__
-#endif
-
 #ifdef HAVE_SYS_ISA_DEFS_H
 #include <sys/isa_defs.h>
 #else
 #ifdef HAVE_ENDIAN_H
 #include <endian.h>
 #else
-#if !defined(__BORLANDC__) && !defined(_MSC_VER)
+#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__)
 #warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
 #warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
 #endif
@@ -151,7 +147,7 @@ void emitpcode(PIC_OPCODE poc, pCodeOp *pcop)
 void pic14_emitcode (char *inst,char *fmt, ...)
 {
     va_list ap;
-    char lb[MAX_INLINEASM];  
+    char lb[INITIAL_INLINEASM];  
     char *lbp = lb;
 
     va_start(ap,fmt);   
@@ -183,7 +179,7 @@ void pic14_emitcode (char *inst,char *fmt, ...)
 void DEBUGpic14_emitcode (char *inst,char *fmt, ...)
 {
     va_list ap;
-    char lb[MAX_INLINEASM];  
+    char lb[INITIAL_INLINEASM];  
     char *lbp = lb;
 
     if(!debug_verbose)
@@ -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++ )
@@ -4948,13 +4944,13 @@ release :
 /*-----------------------------------------------------------------*/
 static void genInline (iCode *ic)
 {
-    char buffer[MAX_INLINEASM];
-    char *bp = buffer;
-    char *bp1= buffer;
+    char *buffer, *bp, *bp1;
     
     DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
 
     _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 */
@@ -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");