mirror of
https://github.com/cc65/cc65.git
synced 2025-01-14 00:32:08 +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:
parent
f783f6d3c1
commit
387ebfd396
@ -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)
|
void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
||||||
/* Generate register info for this instruction. If an old info exists, it is
|
/* Generate register info for this instruction. If an old info exists, it is
|
||||||
* overwritten.
|
* overwritten.
|
||||||
@ -510,7 +497,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OP65_ASL:
|
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;
|
Out->RegA = (In->RegA << 1) & 0xFF;
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
@ -597,7 +584,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OP65_DEC:
|
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;
|
Out->RegA = (In->RegA - 1) & 0xFF;
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
@ -673,7 +660,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OP65_INC:
|
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;
|
Out->RegA = (In->RegA + 1) & 0xFF;
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
@ -876,7 +863,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OP65_LSR:
|
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;
|
Out->RegA = (In->RegA >> 1) & 0xFF;
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
@ -1153,7 +1140,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
/* Invalidates all ZP registers */
|
/* Invalidates all ZP registers */
|
||||||
RC_InvalidateZP (Out);
|
RC_InvalidateZP (Out);
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
if (In->RegA >= 0) {
|
if (RegValIsKnown (In->RegA)) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
case REG_TMP1:
|
case REG_TMP1:
|
||||||
Out->Tmp1 &= ~In->RegA;
|
Out->Tmp1 &= ~In->RegA;
|
||||||
@ -1198,7 +1185,7 @@ void CE_GenRegInfo (CodeEntry* E, RegContents* InputRegs)
|
|||||||
/* Invalidates all ZP registers */
|
/* Invalidates all ZP registers */
|
||||||
RC_InvalidateZP (Out);
|
RC_InvalidateZP (Out);
|
||||||
} else if (E->AM == AM65_ZP) {
|
} else if (E->AM == AM65_ZP) {
|
||||||
if (In->RegA >= 0) {
|
if (RegValIsKnown (In->RegA)) {
|
||||||
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
switch (GetKnownReg (E->Chg & REG_ZP, In)) {
|
||||||
case REG_TMP1:
|
case REG_TMP1:
|
||||||
Out->Tmp1 |= In->RegA;
|
Out->Tmp1 |= In->RegA;
|
||||||
|
@ -138,8 +138,7 @@ static unsigned OptShift1 (CodeSeg* S)
|
|||||||
|
|
||||||
static unsigned OptShift2 (CodeSeg* S)
|
static unsigned OptShift2 (CodeSeg* S)
|
||||||
/* A call to the shraxN routine may get replaced by one or more lsr insns
|
/* 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
|
* if the value of X is zero.
|
||||||
* zero.
|
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned Changes = 0;
|
unsigned Changes = 0;
|
||||||
@ -160,7 +159,7 @@ static unsigned OptShift2 (CodeSeg* S)
|
|||||||
strncmp (E->Arg, "shrax", 5) == 0 &&
|
strncmp (E->Arg, "shrax", 5) == 0 &&
|
||||||
strlen (E->Arg) == 6 &&
|
strlen (E->Arg) == 6 &&
|
||||||
IsDigit (E->Arg[5]) &&
|
IsDigit (E->Arg[5]) &&
|
||||||
(E->RI->In.RegX == 0 || !RegXUsed (S, I+1))) {
|
E->RI->In.RegX == 0) {
|
||||||
|
|
||||||
/* Insert shift insns */
|
/* Insert shift insns */
|
||||||
unsigned Count = E->Arg[5] - '0';
|
unsigned Count = E->Arg[5] - '0';
|
||||||
@ -1907,13 +1906,13 @@ static unsigned RunOptGroup1 (CodeSeg* S)
|
|||||||
Changes += RunOptFunc (S, &DOptAdd1, 1);
|
Changes += RunOptFunc (S, &DOptAdd1, 1);
|
||||||
Changes += RunOptFunc (S, &DOptAdd2, 1);
|
Changes += RunOptFunc (S, &DOptAdd2, 1);
|
||||||
Changes += RunOptFunc (S, &DOptAdd3, 1);
|
Changes += RunOptFunc (S, &DOptAdd3, 1);
|
||||||
|
Changes += RunOptFunc (S, &DOptStore4, 1);
|
||||||
Changes += RunOptFunc (S, &DOptShift1, 1);
|
Changes += RunOptFunc (S, &DOptShift1, 1);
|
||||||
Changes += RunOptFunc (S, &DOptShift2, 1);
|
Changes += RunOptFunc (S, &DOptShift2, 1);
|
||||||
Changes += RunOptFunc (S, &DOptShift3, 1);
|
Changes += RunOptFunc (S, &DOptShift3, 1);
|
||||||
Changes += RunOptFunc (S, &DOptStore1, 1);
|
Changes += RunOptFunc (S, &DOptStore1, 1);
|
||||||
Changes += RunOptFunc (S, &DOptStore2, 5);
|
Changes += RunOptFunc (S, &DOptStore2, 5);
|
||||||
Changes += RunOptFunc (S, &DOptStore3, 5);
|
Changes += RunOptFunc (S, &DOptStore3, 5);
|
||||||
Changes += RunOptFunc (S, &DOptStore4, 1);
|
|
||||||
|
|
||||||
/* Return the number of changes */
|
/* Return the number of changes */
|
||||||
return Changes;
|
return Changes;
|
||||||
|
@ -1320,6 +1320,7 @@ unsigned OptPrecalc (CodeSeg* S)
|
|||||||
|
|
||||||
case OP65_AND:
|
case OP65_AND:
|
||||||
case OP65_EOR:
|
case OP65_EOR:
|
||||||
|
case OP65_LSR:
|
||||||
case OP65_ORA:
|
case OP65_ORA:
|
||||||
if (RegValIsKnown (Out->RegA)) {
|
if (RegValIsKnown (Out->RegA)) {
|
||||||
/* Accu AND zp with known contents */
|
/* Accu AND zp with known contents */
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,6 +121,9 @@ RegInfo* NewRegInfo (const RegContents* RC);
|
|||||||
void FreeRegInfo (RegInfo* RI);
|
void FreeRegInfo (RegInfo* RI);
|
||||||
/* Free a RegInfo struct */
|
/* Free a RegInfo struct */
|
||||||
|
|
||||||
|
void DumpRegInfo (const char* Desc, const RegInfo* RI);
|
||||||
|
/* Dump the register info for debugging */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of reginfo.h */
|
/* End of reginfo.h */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user