/*****************************************************************************/
/* */
-/* coptc02.h */
+/* coptc02.h */
/* */
-/* 65C02 specific optimizations */
+/* 65C02 specific optimizations */
/* */
/* */
/* */
-/* (C) 2001-2002 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2012, Ullrich von Bassewitz */
+/* Roeerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/*****************************************************************************/
-/* Helper functions */
+/* Helper functions */
/*****************************************************************************/
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
unsigned Changes = 0;
unsigned I;
- /* Generate register info for this step */
- CS_GenRegInfo (S);
-
/* Walk over the entries */
I = 0;
while (I < CS_GetEntryCount (S)) {
- /* Get next entry */
- CodeEntry* E = CS_GetEntry (S, I);
+ /* Get next entry */
+ CodeEntry* E = CS_GetEntry (S, I);
- /* Check for addressing mode indirect indexed Y where Y is zero.
- * Note: All opcodes that are available as (zp),y are also available
- * as (zp), so we can ignore the actual opcode here.
- */
- if (E->AM == AM65_ZP_INDY && E->RI->In.RegY == 0) {
+ /* Check for addressing mode indirect indexed Y where Y is zero.
+ * Note: All opcodes that are available as (zp),y are also available
+ * as (zp), so we can ignore the actual opcode here.
+ */
+ if (E->AM == AM65_ZP_INDY && E->RI->In.RegY == 0) {
- /* Replace it by indirect addressing mode */
- CodeEntry* X = NewCodeEntry (E->OPC, AM65_ZP_IND, E->Arg, 0, E->LI);
- CS_InsertEntry (S, X, I+1);
- CS_DelEntry (S, I);
+ /* Replace it by indirect addressing mode */
+ CodeEntry* X = NewCodeEntry (E->OPC, AM65_ZP_IND, E->Arg, 0, E->LI);
+ CS_InsertEntry (S, X, I+1);
+ CS_DelEntry (S, I);
- /* We had changes */
- ++Changes;
+ /* We had changes */
+ ++Changes;
- }
+ }
- /* Next entry */
- ++I;
+ /* Next entry */
+ ++I;
}
- /* Free register info */
- CS_FreeRegInfo (S);
-
/* Return the number of changes made */
return Changes;
}
unsigned Changes = 0;
unsigned I;
- /* Generate register info for this step */
- CS_GenRegInfo (S);
-
/* Walk over the entries */
I = 0;
while (I < CS_GetEntryCount (S)) {
- CodeEntry* L[3];
+ CodeEntry* L[3];
- /* Get next entry */
- L[0] = CS_GetEntry (S, I);
+ /* Get next entry */
+ L[0] = CS_GetEntry (S, I);
- /* Check for the sequence */
- if (L[0]->OPC == OP65_LDA &&
+ /* Check for the sequence */
+ if (L[0]->OPC == OP65_LDA &&
(L[0]->AM == AM65_ZP || L[0]->AM == AM65_ABS) &&
!CS_RangeHasLabel (S, I+1, 2) &&
CS_GetEntries (S, L+1, I+1, 2) &&
(L[1]->OPC == OP65_AND || L[1]->OPC == OP65_ORA) &&
- CE_KnownImm (L[1]) &&
+ CE_IsConstImm (L[1]) &&
L[2]->OPC == OP65_STA &&
L[2]->AM == L[0]->AM &&
strcmp (L[2]->Arg, L[0]->Arg) == 0 &&
/* Delete the old stuff */
CS_DelEntries (S, I, 3);
- /* We had changes */
- ++Changes;
- }
+ /* We had changes */
+ ++Changes;
+ }
- /* Next entry */
- ++I;
+ /* Next entry */
+ ++I;
}
- /* Free register info */
- CS_FreeRegInfo (S);
-
/* Return the number of changes made */
return Changes;
}
unsigned Changes = 0;
unsigned I;
- /* Generate register info for this step */
- CS_GenRegInfo (S);
-
/* Walk over the entries */
I = 0;
while (I < CS_GetEntryCount (S)) {
- /* Get next entry */
- CodeEntry* E = CS_GetEntry (S, I);
+ /* Get next entry */
+ CodeEntry* E = CS_GetEntry (S, I);
- /* Check for a store with a register value of zero and an addressing
- * mode available with STZ.
- */
- if (((E->OPC == OP65_STA && E->RI->In.RegA == 0) ||
- (E->OPC == OP65_STX && E->RI->In.RegX == 0) ||
- (E->OPC == OP65_STY && E->RI->In.RegY == 0)) &&
+ /* Check for a store with a register value of zero and an addressing
+ * mode available with STZ.
+ */
+ if (((E->OPC == OP65_STA && E->RI->In.RegA == 0) ||
+ (E->OPC == OP65_STX && E->RI->In.RegX == 0) ||
+ (E->OPC == OP65_STY && E->RI->In.RegY == 0)) &&
(E->AM == AM65_ZP || E->AM == AM65_ABS ||
E->AM == AM65_ZPX || E->AM == AM65_ABSX)) {
/* Delete the old stuff */
CS_DelEntry (S, I);
- /* We had changes */
- ++Changes;
- }
+ /* We had changes */
+ ++Changes;
+ }
- /* Next entry */
- ++I;
+ /* Next entry */
+ ++I;
}
- /* Free register info */
- CS_FreeRegInfo (S);
-
/* Return the number of changes made */
return Changes;
}