1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-13 09:31:53 +00:00

Fixed a bug.

Added/moved debug code.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2472 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-10-06 10:29:17 +00:00
parent f783f6d3c1
commit 387ebfd396
5 changed files with 25 additions and 23 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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);
}

View File

@ -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 */