]> git.sur5r.net Git - cc65/blobdiff - src/cc65/reginfo.c
Fixed two compiler warnings.
[cc65] / src / cc65 / reginfo.c
index f62dd3791e144df0f6333e91483d298e81b53b86..00590e6f8b6838fbd6850a70dede21d8e010f960 100644 (file)
@@ -6,9 +6,9 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001      Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
+/* (C) 2001-2003 Ullrich von Bassewitz                                       */
+/*               Römerstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
 /* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 void RC_Invalidate (RegContents* C)
 /* Invalidate all registers */
 {
-    C->RegA   = -1;
-    C->RegX   = -1;
-    C->RegY   = -1;
-    C->SRegLo = -1;
-    C->SRegHi = -1;
+    C->RegA   = UNKNOWN_REGVAL;
+    C->RegX   = UNKNOWN_REGVAL;
+    C->RegY   = UNKNOWN_REGVAL;
+    C->SRegLo = UNKNOWN_REGVAL;
+    C->SRegHi = UNKNOWN_REGVAL;
+    C->Ptr1Lo = UNKNOWN_REGVAL;
+    C->Ptr1Hi = UNKNOWN_REGVAL;
+    C->Tmp1   = UNKNOWN_REGVAL;
+}
+
+
+
+void RC_InvalidateZP (RegContents* C)
+/* Invalidate all ZP registers */
+{
+    C->SRegLo = UNKNOWN_REGVAL;
+    C->SRegHi = UNKNOWN_REGVAL;
+    C->Ptr1Lo = UNKNOWN_REGVAL;
+    C->Ptr1Hi = UNKNOWN_REGVAL;
+    C->Tmp1   = UNKNOWN_REGVAL;
+}
+
+
+
+static void RC_Dump1 (FILE* F, const char* Desc, short Val)
+/* Dump one register value */
+{
+    if (RegValIsKnown (Val)) {
+        fprintf (F, "%s=$%02X ", Desc, Val);
+    } else {
+        fprintf (F, "%s=$XX ", Desc);
+    }
+}
+
+
+
+void RC_Dump (FILE* F, const RegContents* RC)
+/* Dump the contents of the given RegContents struct */
+{
+    RC_Dump1 (F, "A", RC->RegA);
+    RC_Dump1 (F, "X", RC->RegX);
+    RC_Dump1 (F, "Y", RC->RegY);
+    RC_Dump1 (F, "SREG", RC->SRegLo);
+    RC_Dump1 (F, "SREG+1", RC->SRegHi);
+    RC_Dump1 (F, "PTR1", RC->Ptr1Lo);
+    RC_Dump1 (F, "PTR1+1", RC->Ptr1Hi);
+    RC_Dump1 (F, "TMP1", RC->Tmp1);
+    fprintf (F, "\n");
 }
 
 
@@ -70,11 +113,13 @@ RegInfo* NewRegInfo (const RegContents* RC)
 
     /* Initialize the registers */
     if (RC) {
-       RI->In  = *RC;
-       RI->Out = *RC;
+       RI->In   = *RC;
+       RI->Out  = *RC;
+       RI->Out2 = *RC;
     } else {
        RC_Invalidate (&RI->In);
        RC_Invalidate (&RI->Out);
+       RC_Invalidate (&RI->Out2);
     }
 
     /* Return the new struct */
@@ -91,3 +136,15 @@ void FreeRegInfo (RegInfo* RI)
 
 
 
+void DumpRegInfo (const char* Desc, const RegInfo* RI)
+/* Dump the register info for debugging */
+{
+    fprintf (stdout, "%s:\n", Desc);
+    fprintf (stdout, "In:  ");
+    RC_Dump (stdout, &RI->In);
+    fprintf (stdout, "Out: ");
+    RC_Dump (stdout, &RI->Out);
+}
+
+
+