* sim/ucsim/cmd.src/cmdutil.cc: NUL device is detected as CG_FILE type
[fw/sdcc] / src / hc08 / gen.c
index c091a41130f4aeb9ba13c3069971a2b364711c55..8c93b380c85b1083471488e31910cd8b5eb77e86 100644 (file)
@@ -83,7 +83,7 @@ static asmop *hc08_aop_pass[4];
 
 extern int hc08_ptrRegReq;
 extern int hc08_nRegs;
-extern FILE *codeOutFile;
+extern struct dbuf_s *codeOutBuf;
 //static void saveRBank (int, iCode *, bool);
 static bool operandsEqu (operand * op1, operand * op2);
 static void loadRegFromConst (regs *reg, char *c);
@@ -193,6 +193,7 @@ static void
 emitLabel (symbol *tlbl)
 {
   emitcode ("", "%05d$:", (tlbl->key +100));
+  lineCurr->isLabel = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -2187,7 +2188,7 @@ asmopToBool (asmop *aop, bool resultInA)
             emitcode ("tsta", "");
             emitcode ("bne", "%05d$", (tlbl->key + 100));
             emitcode ("tstx", "");
-            emitcode ("", "%05d$:", (tlbl->key + 100));
+            emitLabel (tlbl);
           }
         else
           {
@@ -2248,7 +2249,7 @@ asmopToBool (asmop *aop, bool resultInA)
                 emitcode ("tst", "%s", aopAdrStr (aop, 0, FALSE));
                 emitcode ("bne", "%05d$", (tlbl->key + 100));
                 emitcode ("tst", "%s", aopAdrStr (aop, 1, FALSE));
-                emitcode ("", "%05d$:", (tlbl->key + 100));
+                emitLabel (tlbl);
                 break;
               }
           }
@@ -2838,12 +2839,6 @@ resultRemat (iCode * ic)
   return 0;
 }
 
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
-#else
-#define STRCASECMP strcasecmp
-#endif
-
 /*-----------------------------------------------------------------*/
 /* inExcludeList - return 1 if the string is in exclude Reg list   */
 /*-----------------------------------------------------------------*/
@@ -2885,6 +2880,7 @@ genFunction (iCode * ic)
   emitcode (";", "-----------------------------------------");
 
   emitcode ("", "%s:", sym->rname);
+  lineCurr->isLabel = 1;
   ftype = operandType (IC_LEFT (ic));
   
   _G.stackOfs = 0;
@@ -3165,7 +3161,7 @@ genLabel (iCode * ic)
          
   debugFile->writeLabel(IC_LABEL (ic), ic);
 
-  emitcode ("", "%05d$:", (IC_LABEL (ic)->key + 100));
+  emitLabel (IC_LABEL (ic));
 
 }
 
@@ -8344,7 +8340,7 @@ genhc08Code (iCode * lic)
 
   /* print the allocation information */
   if (allocInfo && currFunc)
-    printAllocInfo (currFunc, codeOutFile);
+    printAllocInfo (currFunc, codeOutBuf);
   /* if debug information required */
   if (options.debug && currFunc)
     {
@@ -8416,13 +8412,16 @@ genhc08Code (iCode * lic)
       if (options.iCodeInAsm) {
        char regsInUse[80];
        int i;
+        char *iLine;
 
        for (i=0; i<6; i++) {
          sprintf (&regsInUse[i],
                   "%c", ic->riu & (1<<i) ? i+'0' : '-'); 
        }
        regsInUse[i]=0;
+        iLine = printILine(ic);
        emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
+        dbuf_free(iLine);
       }
       /* if the result is marked as
          spilt and rematerializable or code for
@@ -8695,6 +8694,6 @@ genhc08Code (iCode * lic)
     peepHole (&lineHead);
 
   /* now do the actual printing */
-  printLine (lineHead, codeOutFile);
+  printLine (lineHead, codeOutBuf);
   return;
 }