]> git.sur5r.net Git - cc65/commitdiff
Fixed a bug
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 12 Sep 2001 18:20:30 +0000 (18:20 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 12 Sep 2001 18:20:30 +0000 (18:20 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@895 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/cc65/codeopt.c

index 3ec3f12db6e0ac8a70364accd7daca05406350a6..48834fed8c330b09058067f55afd02873bb1764a 100644 (file)
@@ -1,3 +1,4 @@
+
 /*****************************************************************************/
 /*                                                                           */
 /*                                codeopt.c                                 */
@@ -552,7 +553,7 @@ static unsigned OptAdd1 (CodeSeg* S)
  *
  * and replace it by:
  *
- *      ldy     xxx
+ *      ldy     xxx-2
  *      clc
  *      adc     (sp),y
  *      bcc     L
@@ -576,6 +577,7 @@ static unsigned OptAdd1 (CodeSeg* S)
            strcmp (E->Arg, "pushax") == 0                   &&
                    CS_GetEntries (S, L, I+1, 5)                     &&
                    L[0]->OPC == OP65_LDY                            &&
+           CE_KnownImm (L[0])                               &&
            !CE_HasLabel (L[0])                              &&
            L[1]->OPC == OP65_LDX                            &&
            CE_KnownImm (L[1])                               &&
@@ -589,10 +591,16 @@ static unsigned OptAdd1 (CodeSeg* S)
 
            CodeEntry* X;
            CodeLabel* Label;
+           char Buf [16];
 
            /* Remove the call to pushax */
            CS_DelEntry (S, I);
 
+           /* Correct the stack offset (needed since pushax was removed) */
+           L[0]->Num -= 2;
+           xsprintf (Buf, sizeof (Buf), "$%02lX", L[0]->Num);
+           CE_SetArg (L[0], Buf);
+
            /* Add the clc . */
            X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, L[3]->LI);
            CS_InsertEntry (S, X, I+1);