From b1d7f78bcef467e929cab425af2589c4a0d447b5 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 4 Jun 2004 14:36:36 +0000 Subject: [PATCH] More debugging output git-svn-id: svn://svn.cc65.org/cc65/trunk@3084 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codeent.c | 52 +++++++++++++++++++++++++++++++++++++++------- src/cc65/codeseg.c | 20 +++++++++++------- src/cc65/codeseg.h | 4 ++-- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index 3868a3531..a891aeb3d 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2001-2003 Ullrich von Bassewitz */ +/* (C) 2001-2004 Ullrich von Bassewitz */ /* Römerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -1269,6 +1269,35 @@ static char* RegInfoDesc (unsigned U, char* Buf) +static char* RegContentDesc (const RegContents* RC, char* Buf) +/* Return a string containing register contents */ +{ + char* B = Buf; + + if (RegValIsUnknown (RC->RegA)) { + strcpy (B, "A:XX "); + } else { + sprintf (B, "A:%02X ", RC->RegA); + } + B += 5; + if (RegValIsUnknown (RC->RegX)) { + strcpy (B, "X:XX "); + } else { + sprintf (B, "X:%02X ", RC->RegX); + } + B += 5; + if (RegValIsUnknown (RC->RegY)) { + strcpy (B, "Y:XX"); + } else { + sprintf (B, "Y:%02X", RC->RegY); + } + B += 4; + + return Buf; +} + + + void CE_Output (const CodeEntry* E, FILE* F) /* Output the code entry to a file */ { @@ -1357,15 +1386,24 @@ void CE_Output (const CodeEntry* E, FILE* F) char Use [128]; char Chg [128]; fprintf (F, - "%*s; USE: %-12s CHG: %-12s SIZE: %u\n", + "%*s; USE: %-12s CHG: %-12s SIZE: %u", 30-Chars, "", - RegInfoDesc (E->Use, Use), - RegInfoDesc (E->Chg, Chg), + RegInfoDesc (E->Use, Use), + RegInfoDesc (E->Chg, Chg), E->Size); - } else { - /* Terminate the line */ - fprintf (F, "\n"); + + if (E->RI) { + char RegIn[32]; + char RegOut[32]; + fprintf (F, + " In %s Out %s", + RegContentDesc (&E->RI->In, RegIn), + RegContentDesc (&E->RI->Out, RegOut)); + } } + + /* Terminate the line */ + fprintf (F, "\n"); } diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index 710494cac..8eb594f79 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2001-2003 Ullrich von Bassewitz */ +/* (C) 2001-2004 Ullrich von Bassewitz */ /* Römerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -807,7 +807,7 @@ CodeLabel* CS_GenLabel (CodeSeg* S, struct CodeEntry* E) /* Attach this label to the code entry */ CE_AttachLabel (E, L); - } + } /* Return the label */ return L; @@ -1253,7 +1253,7 @@ void CS_OutputEpilogue (const CodeSeg* S, FILE* F) -void CS_Output (const CodeSeg* S, FILE* F) +void CS_Output (CodeSeg* S, FILE* F) /* Output the code segment data to a file */ { unsigned I; @@ -1267,6 +1267,9 @@ void CS_Output (const CodeSeg* S, FILE* F) return; } + /* Generate register info */ + CS_GenRegInfo (S); + /* Output the segment directive */ fprintf (F, ".segment\t\"%s\"\n\n", S->SegName); @@ -1303,7 +1306,7 @@ void CS_Output (const CodeSeg* S, FILE* F) /* Add line debug info */ if (DebugInfo) { fprintf (F, "\t.dbg\tline, \"%s\", %u\n", - GetInputName (LI), GetInputLine (LI)); + GetInputName (LI), GetInputLine (LI)); } } /* Output the code */ @@ -1314,6 +1317,9 @@ void CS_Output (const CodeSeg* S, FILE* F) if (DebugInfo) { fputs ("\t.dbg\tline\n", F); } + + /* Free register info */ + CS_FreeRegInfo (S); } @@ -1463,7 +1469,7 @@ void CS_GenRegInfo (CodeSeg* S) /* A is zero in one execution flow direction */ if (BC == BC_EQ) { E->RI->Out2.RegA = 0; - } else { + } else { E->RI->Out.RegA = 0; } break; @@ -1477,7 +1483,7 @@ void CS_GenRegInfo (CodeSeg* S) E->RI->Out2.RegA = (unsigned char)P->Num; } else { E->RI->Out.RegA = (unsigned char)P->Num; - } + } } break; @@ -1516,7 +1522,7 @@ void CS_GenRegInfo (CodeSeg* S) E->RI->Out2.RegX = 0; } else { E->RI->Out.RegX = 0; - } + } break; case OP65_DEY: diff --git a/src/cc65/codeseg.h b/src/cc65/codeseg.h index 4a96bb57d..cde8c4ff1 100644 --- a/src/cc65/codeseg.h +++ b/src/cc65/codeseg.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2001-2003 Ullrich von Bassewitz */ +/* (C) 2001-2004 Ullrich von Bassewitz */ /* Römerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -275,7 +275,7 @@ void CS_OutputEpilogue (const CodeSeg* S, FILE* F); * assembler epilogue into the file. That is: Close the local function scope. */ -void CS_Output (const CodeSeg* S, FILE* F); +void CS_Output (CodeSeg* S, FILE* F); /* Output the code segment data to a file */ void CS_FreeRegInfo (CodeSeg* S);