]> git.sur5r.net Git - cc65/blobdiff - src/cc65/coptc02.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / cc65 / coptc02.c
index 4ba8a30323ae7f70ff2994d3e16d0ff9aa4a9449..969f9fd6ed536d95da837bfc9d5f1099aafdc925 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                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                                    */
 /*****************************************************************************/
 
 
@@ -67,40 +67,34 @@ unsigned Opt65C02Ind (CodeSeg* S)
     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;
 }
@@ -113,25 +107,22 @@ unsigned Opt65C02BitOps (CodeSeg* S)
     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                  &&
@@ -167,18 +158,15 @@ unsigned Opt65C02BitOps (CodeSeg* S)
             /* 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;
 }
@@ -191,22 +179,19 @@ unsigned Opt65C02Stores (CodeSeg* S)
     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)) {
 
@@ -217,18 +202,15 @@ unsigned Opt65C02Stores (CodeSeg* S)
             /* 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;
 }