From: cuz Date: Wed, 12 Sep 2001 18:20:30 +0000 (+0000) Subject: Fixed a bug X-Git-Tag: V2.12.0~2685 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1a39515769d86103a40fe3b5cd7d83e7ed1bcae4;p=cc65 Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@895 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 3ec3f12db..48834fed8 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -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);