]> git.sur5r.net Git - cc65/blobdiff - src/cc65/coptpush.c
Fixed the cc65 code that handled an addition of a pointer to a 32-bit offset.
[cc65] / src / cc65 / coptpush.c
index 54b54fc03e178413878bc3e0ed69fe2138153f70..5c3daffca0d687e33b295194884ce733bc7f0b7f 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                               coptpush.c                                 */
+/*                                coptpush.c                                 */
 /*                                                                           */
-/*                         Optimize push sequences                          */
+/*                          Optimize push sequences                          */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
 
 unsigned OptPush1 (CodeSeg* S)
 /* Given a sequence
- *
- *     jsr     ldaxysp
- *     jsr     pushax
- *
- * If a/x are not used later, and Y is known, replace that by
- *
- *     ldy     #xx+2
- *     jsr     pushwysp
- *
- * saving 3 bytes and several cycles.
- */
+**
+**     jsr     ldaxysp
+**     jsr     pushax
+**
+** If a/x are not used later, and Y is known, replace that by
+**
+**     ldy     #xx+2
+**     jsr     pushwysp
+**
+** saving 3 bytes and several cycles.
+*/
 {
     unsigned I;
     unsigned Changes = 0;
@@ -67,43 +67,43 @@ unsigned OptPush1 (CodeSeg* S)
     I = 0;
     while (I < CS_GetEntryCount (S)) {
 
-       CodeEntry* L[2];
+        CodeEntry* L[2];
 
-       /* Get next entry */
-               L[0] = CS_GetEntry (S, I);
+        /* Get next entry */
+        L[0] = CS_GetEntry (S, I);
 
-       /* Check for the sequence */
-               if (CE_IsCallTo (L[0], "ldaxysp")               &&
+        /* Check for the sequence */
+        if (CE_IsCallTo (L[0], "ldaxysp")               &&
             RegValIsKnown (L[0]->RI->In.RegY)           &&
             L[0]->RI->In.RegY < 0xFE                    &&
             (L[1] = CS_GetNextEntry (S, I)) != 0        &&
             !CE_HasLabel (L[1])                         &&
-                   CE_IsCallTo (L[1], "pushax")                &&
-                   !RegAXUsed (S, I+2)) {
+            CE_IsCallTo (L[1], "pushax")                &&
+            !RegAXUsed (S, I+2)) {
 
-           /* Insert new code behind the pushax */
-           const char* Arg;
-           CodeEntry* X;
+            /* Insert new code behind the pushax */
+            const char* Arg;
+            CodeEntry* X;
 
-           /* ldy     #xx+1 */
-           Arg = MakeHexArg (L[0]->RI->In.RegY+2);
-           X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[0]->LI);
-           CS_InsertEntry (S, X, I+2);
+            /* ldy     #xx+1 */
+            Arg = MakeHexArg (L[0]->RI->In.RegY+2);
+            X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[0]->LI);
+            CS_InsertEntry (S, X, I+2);
 
-           /* jsr pushwysp */
-           X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwysp", 0, L[1]->LI);
-           CS_InsertEntry (S, X, I+3);
+            /* jsr pushwysp */
+            X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwysp", 0, L[1]->LI);
+            CS_InsertEntry (S, X, I+3);
 
-           /* Delete the old code */
-           CS_DelEntries (S, I, 2);
+            /* Delete the old code */
+            CS_DelEntries (S, I, 2);
 
-           /* Remember, we had changes */
-           ++Changes;
+            /* Remember, we had changes */
+            ++Changes;
 
-       }
+        }
 
-       /* Next entry */
-       ++I;
+        /* Next entry */
+        ++I;
 
     }
 
@@ -115,15 +115,14 @@ unsigned OptPush1 (CodeSeg* S)
 
 unsigned OptPush2 (CodeSeg* S)
 /* A sequence
- *
- *     jsr     ldaxidx
- *     jsr     pushax
- *
- * may get replaced by
- *
- *     jsr     pushwidx
- *
- */
+**
+**     jsr     ldaxidx
+**     jsr     pushax
+**
+** may get replaced by
+**
+**     jsr     pushwidx
+*/
 {
     unsigned I;
     unsigned Changes = 0;
@@ -132,40 +131,37 @@ unsigned OptPush2 (CodeSeg* S)
     I = 0;
     while (I < CS_GetEntryCount (S)) {
 
-       CodeEntry* L[2];
+        CodeEntry* L[2];
 
-       /* Get next entry */
-               L[0] = CS_GetEntry (S, I);
+        /* Get next entry */
+        L[0] = CS_GetEntry (S, I);
 
-       /* Check for the sequence */
-               if (CE_IsCallTo (L[0], "ldaxidx")               &&
+        /* Check for the sequence */
+        if (CE_IsCallTo (L[0], "ldaxidx")               &&
             (L[1] = CS_GetNextEntry (S, I)) != 0        &&
             !CE_HasLabel (L[1])                         &&
-                   CE_IsCallTo (L[1], "pushax")) {
+            CE_IsCallTo (L[1], "pushax")) {
 
-           /* Insert new code behind the pushax */
-           CodeEntry* X;
+            /* Insert new code behind the pushax */
+            CodeEntry* X;
 
-           /* jsr pushwidx */
-           X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwidx", 0, L[1]->LI);
-           CS_InsertEntry (S, X, I+2);
+            /* jsr pushwidx */
+            X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwidx", 0, L[1]->LI);
+            CS_InsertEntry (S, X, I+2);
 
-           /* Delete the old code */
-           CS_DelEntries (S, I, 2);
+            /* Delete the old code */
+            CS_DelEntries (S, I, 2);
 
-           /* Remember, we had changes */
-           ++Changes;
+            /* Remember, we had changes */
+            ++Changes;
 
-       }
+        }
 
-       /* Next entry */
-       ++I;
+        /* Next entry */
+        ++I;
 
     }
 
     /* Return the number of changes made */
     return Changes;
 }
-
-
-