]> git.sur5r.net Git - cc65/blobdiff - src/cc65/codeseg.c
Fixed a bug that caused problems locating the last parameter of a function
[cc65] / src / cc65 / codeseg.c
index ab500eee2ee1cdab913f89cad3797335d7d940dd..fede7ae6215b12c694a0afd8668e9a77a752aefa 100644 (file)
@@ -39,6 +39,7 @@
 /* common */
 #include "chartype.h"
 #include "check.h"
+#include "debugflag.h"
 #include "global.h"
 #include "hashstr.h"
 #include "strutil.h"
@@ -1281,9 +1282,21 @@ void CS_Output (const CodeSeg* S, FILE* F)
            /* Line info has changed, remember the new line info */
            LI = E->LI;
 
-           /* Add the source line as a comment */
+           /* Add the source line as a comment. Beware: When line continuation
+             * was used, the line may contain newlines.
+             */
            if (AddSource) {
-               fprintf (F, ";\n; %s\n;\n", LI->Line);
+                const char* L = LI->Line;
+                fputs (";\n; ", F);
+                while (*L) {
+                    if (*L == '\n') {
+                        fputs ("\n; ", F);
+                    } else {
+                        fputc (*L, F);
+                    }
+                    ++L;
+                }
+                fputs ("\n;\n", F);
            }
 
            /* Add line debug info */
@@ -1391,19 +1404,22 @@ void CS_GenRegInfo (CodeSeg* S)
                        break;
                    }
                    if (J->RI->Out2.RegA != Regs.RegA) {
-                       Regs.RegA = -1;
+                       Regs.RegA = UNKNOWN_REGVAL;
                    }
                    if (J->RI->Out2.RegX != Regs.RegX) {
-                       Regs.RegX = -1;
+                       Regs.RegX = UNKNOWN_REGVAL;
                    }
                    if (J->RI->Out2.RegY != Regs.RegY) {
-                       Regs.RegY = -1;
+                       Regs.RegY = UNKNOWN_REGVAL;
                    }
                    if (J->RI->Out2.SRegLo != Regs.SRegLo) {
-                       Regs.SRegLo = -1;
+                       Regs.SRegLo = UNKNOWN_REGVAL;
                    }
                    if (J->RI->Out2.SRegHi != Regs.SRegHi) {
-                       Regs.SRegHi = -1;
+                       Regs.SRegHi = UNKNOWN_REGVAL;
+                   }
+                           if (J->RI->Out2.Tmp1 != Regs.Tmp1) {
+                       Regs.Tmp1 = UNKNOWN_REGVAL;
                    }
                    ++Entry;
                }