* as/hc08/lkaomf51.c (OutputName): made name unsigned char,
[fw/sdcc] / src / pic / pcode.c
index e956863cf059fc7c5a1b7aad1705c6fede77bb68..5128c5ad85a8636f87c767f2fe5bb34699f9ac62 100644 (file)
@@ -124,6 +124,8 @@ pBlock *newpBlock(void);
 pCodeOp *popCopyGPR2Bit(pCodeOp *pc, int bitval);
 void pCodeRegMapLiveRanges(pBlock *pb);
 
+pBranch * pBranchAppend(pBranch *h, pBranch *n);
+
 
 /****************************************************************/
 /*                    PIC Instructions                          */
@@ -1395,7 +1397,7 @@ void  pCodeInitRegisters(void)
 /*                                                                 */
 /*-----------------------------------------------------------------*/
 
-int mnem2key(char const *mnem)
+int mnem2key(unsigned char const *mnem)
 {
        int key = 0;
        
@@ -2065,7 +2067,7 @@ pCode *newpCodeAsmDir(char *asdir, char *argfmt, ...)
 
   if(asdir && *asdir) {
 
-    while(isspace(*asdir))asdir++;     // strip any white space from the beginning
+    while(isspace((unsigned char)*asdir))asdir++;      // strip any white space from the beginning
 
     pcad->directive = Safe_strdup( asdir );
   }
@@ -2078,7 +2080,7 @@ pCode *newpCodeAsmDir(char *asdir, char *argfmt, ...)
 
   va_end(ap);
 
-  while(isspace(*lbp))lbp++;
+  while(isspace((unsigned char)*lbp))lbp++;
 
   if(lbp && *lbp)
     pcad->arg = Safe_strdup( lbp );
@@ -2666,7 +2668,20 @@ void unlinkpCode(pCode *pc)
                        pc->prev->next = pc->next;
                if(pc->next)
                        pc->next->prev = pc->prev;
-               
+
+#if 0
+               /* RN: I believe this should be right here, but this did not
+                *     cure the bug I was hunting... */
+               /* must keep labels -- attach to following instruction */
+               if (isPCI(pc) && PCI(pc)->label && pc->next)
+               {
+                 pCodeInstruction *pcnext = PCI(findNextInstruction (pc->next));
+                 if (pcnext)
+                 {
+                   pBranchAppend (pcnext->label, PCI(pc)->label);
+                 }
+               }
+#endif
                pc->prev = pc->next = NULL;
        }
 }
@@ -3179,7 +3194,8 @@ char *pCode2str(char *str, size_t size, pCode *pc)
     SAFE_snprintf(&s,&size,";\t--FLOW change\n");
     break;
   case PC_CSOURCE:
-    SAFE_snprintf(&s,&size,";#CSRC\t%s %d\n; %s\n", PCCS(pc)->file_name, PCCS(pc)->line_number, PCCS(pc)->line);
+//    SAFE_snprintf(&s,&size,";#CSRC\t%s %d\n; %s\n", PCCS(pc)->file_name, PCCS(pc)->line_number, PCCS(pc)->line);
+    SAFE_snprintf(&s,&size,"%s\t.line\t%d; \"%s\"\t%s\n",(options.debug?"":";"),PCCS(pc)->line_number, PCCS(pc)->file_name, PCCS(pc)->line);
     break;
   case PC_ASMDIR:
     if(PCAD(pc)->directive) {
@@ -3293,7 +3309,8 @@ static void genericPrint(FILE *of, pCode *pc)
     break;
 
   case PC_CSOURCE:
-    fprintf(of,";#CSRC\t%s %d\n;  %s\n", PCCS(pc)->file_name, PCCS(pc)->line_number, PCCS(pc)->line);
+//    fprintf(of,";#CSRC\t%s %d\n;  %s\n", PCCS(pc)->file_name, PCCS(pc)->line_number, PCCS(pc)->line);
+    fprintf(of,"%s\t.line\t%d; \"%s\"\t%s\n", (options.debug?"":";"), PCCS(pc)->line_number, PCCS(pc)->file_name, PCCS(pc)->line);
     break;
 
   case PC_ASMDIR:
@@ -5782,7 +5799,7 @@ void AnalyzepCode(char dbName)
                                pBlockMergeLabels(pb);
                                AnalyzepBlock(pb);
                        } else {
-                               DFPRINTF((stderr," skipping block analysis dbName=%c blockname=%c\n",dbName,getpBlock_dbName));
+                               DFPRINTF((stderr," skipping block analysis dbName=%c blockname=%c\n",dbName,getpBlock_dbName(pb)));
                        }
                }