From: cuz Date: Mon, 6 Oct 2003 10:29:17 +0000 (+0000) Subject: Fixed a bug. X-Git-Tag: V2.12.0~1299 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=387ebfd3961c28ac419a42ef02ee5d3b00497043;p=cc65 Fixed a bug. Added/moved debug code. git-svn-id: svn://svn.cc65.org/cc65/trunk@2472 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index f9e74a11c..3868a3531 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -427,19 +427,6 @@ void CE_FreeRegInfo (CodeEntry* E) -#if 0 /* Used for debugging */ -static void DumpRegInfo (const char* Desc, const RegInfo* RI) -{ - fprintf (stdout, "%s:\n", Desc); - fprintf (stdout, "In: "); - RC_Dump (stdout, &RI->In); - fprintf (stdout, "Out: "); - RC_Dump (stdout, &RI->Out); -} -#endif - - - void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) /* Generate register info for this instruction. If an old info exists, it is * overwritten. @@ -510,7 +497,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) break; case OP65_ASL: - if (E->AM == AM65_ACC && In->RegA >= 0) { + if (E->AM == AM65_ACC && RegValIsKnown (In->RegA)) { Out->RegA = (In->RegA << 1) & 0xFF; } else if (E->AM == AM65_ZP) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { @@ -597,7 +584,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) break; case OP65_DEC: - if (E->AM == AM65_ACC && In->RegA >= 0) { + if (E->AM == AM65_ACC && RegValIsKnown (In->RegA)) { Out->RegA = (In->RegA - 1) & 0xFF; } else if (E->AM == AM65_ZP) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { @@ -673,7 +660,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) break; case OP65_INC: - if (E->AM == AM65_ACC && In->RegA >= 0) { + if (E->AM == AM65_ACC && RegValIsKnown (In->RegA)) { Out->RegA = (In->RegA + 1) & 0xFF; } else if (E->AM == AM65_ZP) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { @@ -876,7 +863,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) break; case OP65_LSR: - if (E->AM == AM65_ACC && In->RegA >= 0) { + if (E->AM == AM65_ACC && RegValIsKnown (In->RegA)) { Out->RegA = (In->RegA >> 1) & 0xFF; } else if (E->AM == AM65_ZP) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { @@ -1153,7 +1140,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) /* Invalidates all ZP registers */ RC_InvalidateZP (Out); } else if (E->AM == AM65_ZP) { - if (In->RegA >= 0) { + if (RegValIsKnown (In->RegA)) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { case REG_TMP1: Out->Tmp1 &= ~In->RegA; @@ -1198,7 +1185,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs) /* Invalidates all ZP registers */ RC_InvalidateZP (Out); } else if (E->AM == AM65_ZP) { - if (In->RegA >= 0) { + if (RegValIsKnown (In->RegA)) { switch (GetKnownReg (E->Chg & REG_ZP, In)) { case REG_TMP1: Out->Tmp1 |= In->RegA; diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index a7b46ca1b..fe647e0f9 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -138,8 +138,7 @@ static unsigned OptShift1 (CodeSeg* S) static unsigned OptShift2 (CodeSeg* S) /* A call to the shraxN routine may get replaced by one or more lsr insns - * if the value of X is not used later, or if the value of X is known and - * zero. + * if the value of X is zero. */ { unsigned Changes = 0; @@ -160,7 +159,7 @@ static unsigned OptShift2 (CodeSeg* S) strncmp (E->Arg, "shrax", 5) == 0 && strlen (E->Arg) == 6 && IsDigit (E->Arg[5]) && - (E->RI->In.RegX == 0 || !RegXUsed (S, I+1))) { + E->RI->In.RegX == 0) { /* Insert shift insns */ unsigned Count = E->Arg[5] - '0'; @@ -1907,13 +1906,13 @@ static unsigned RunOptGroup1 (CodeSeg* S) Changes += RunOptFunc (S, &DOptAdd1, 1); Changes += RunOptFunc (S, &DOptAdd2, 1); Changes += RunOptFunc (S, &DOptAdd3, 1); + Changes += RunOptFunc (S, &DOptStore4, 1); Changes += RunOptFunc (S, &DOptShift1, 1); Changes += RunOptFunc (S, &DOptShift2, 1); Changes += RunOptFunc (S, &DOptShift3, 1); Changes += RunOptFunc (S, &DOptStore1, 1); Changes += RunOptFunc (S, &DOptStore2, 5); Changes += RunOptFunc (S, &DOptStore3, 5); - Changes += RunOptFunc (S, &DOptStore4, 1); /* Return the number of changes */ return Changes; diff --git a/src/cc65/coptind.c b/src/cc65/coptind.c index f1478b9a9..3efa843af 100644 --- a/src/cc65/coptind.c +++ b/src/cc65/coptind.c @@ -1320,6 +1320,7 @@ unsigned OptPrecalc (CodeSeg* S) case OP65_AND: case OP65_EOR: + case OP65_LSR: case OP65_ORA: if (RegValIsKnown (Out->RegA)) { /* Accu AND zp with known contents */ diff --git a/src/cc65/reginfo.c b/src/cc65/reginfo.c index a90da9231..00590e6f8 100644 --- a/src/cc65/reginfo.c +++ b/src/cc65/reginfo.c @@ -136,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); +} + + + diff --git a/src/cc65/reginfo.h b/src/cc65/reginfo.h index fd2034fce..52cb40d71 100644 --- a/src/cc65/reginfo.h +++ b/src/cc65/reginfo.h @@ -121,6 +121,9 @@ RegInfo* NewRegInfo (const RegContents* RC); void FreeRegInfo (RegInfo* RI); /* Free a RegInfo struct */ +void DumpRegInfo (const char* Desc, const RegInfo* RI); +/* Dump the register info for debugging */ + /* End of reginfo.h */