* doc/sdccman.lyx, src/SDCCmain.c, src/SDCCglobal.h, src/ds390/gen.c,
[fw/sdcc] / src / hc08 / gen.c
index aa324162b77e4a8d945bdf6ef7838953817e663f..23084dfe6cd84dfe28d6dc5d82713cdbfc6ab9cd 100644 (file)
@@ -28,8 +28,7 @@
 -------------------------------------------------------------------------*/
 
 /* Use the D macro for basic (unobtrusive) debugging messages */
-//#define D(x)
-#define D(x) x
+#define D(x) do if (!options.noVerboseAsm) {x;} while(0)
 /* Use the DD macro for detailed debugging messages */
 #define DD(x)
 //#define DD(x) x
@@ -83,7 +82,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);
@@ -1621,6 +1620,7 @@ operandsEqu (operand * op1, operand * op2)
   if (sym1 == sym2)
     return TRUE;
 
+  /* if they have the same rname */
   if (sym1->rname[0] && sym2->rname[0]
       && strcmp (sym1->rname, sym2->rname) == 0)
     return TRUE;
@@ -2839,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   */
 /*-----------------------------------------------------------------*/
@@ -4235,8 +4229,9 @@ negatedCmp (int opcode)
   return EQ_OP; /* shouldn't happen, but need to return something */
 }
 
-/* compile only if the debugging macro D is enabled */
-#if (D(1) -0)
+/*------------------------------------------------------------------*/
+/* nameCmp : helper function for human readable debug output        */
+/*------------------------------------------------------------------*/
 static char *
 nameCmp (int opcode)
 {
@@ -4258,7 +4253,6 @@ nameCmp (int opcode)
       return "invalid";
     }
 }
-#endif
 
 /*------------------------------------------------------------------*/
 /* branchInstCmp : returns the conditional branch instruction that  */
@@ -5708,7 +5702,7 @@ genSwap (iCode * ic)
       hc08_freeReg (hc08_reg_a);
       break;
     case 2: /* swap bytes in a word */
-      if (operandsEqu (left, result))
+      if (operandsEqu (left, result) || sameRegs (AOP (left), AOP (result)))
         {
           loadRegFromAop (hc08_reg_a, AOP (left), 0);
           hc08_useReg (hc08_reg_a);
@@ -8346,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)
     {
@@ -8418,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
@@ -8697,6 +8694,6 @@ genhc08Code (iCode * lic)
     peepHole (&lineHead);
 
   /* now do the actual printing */
-  printLine (lineHead, codeOutFile);
+  printLine (lineHead, codeOutBuf);
   return;
 }