-#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.
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)) {
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)) {
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)) {
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)) {
/* 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;
/* 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;
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;
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';
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;
case OP65_AND:
case OP65_EOR:
+ case OP65_LSR:
case OP65_ORA:
if (RegValIsKnown (Out->RegA)) {
/* Accu AND zp with known contents */
+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);
+}
+
+
+
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 */