From 2d7634aa6b369f00fd9d143fcc29e95bb7b4b04e Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 27 Sep 2001 17:09:10 +0000 Subject: [PATCH] Fixed a bug git-svn-id: svn://svn.cc65.org/cc65/trunk@979 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codeopt.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 0e8012864..dce527cc7 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -2366,9 +2366,9 @@ static unsigned OptPtrLoad4 (CodeSeg* S) * * and replace it by: * - * ldx xxx - * lda label,x + * ldy xxx * ldx #$00 + * lda label,y */ { unsigned Changes = 0; @@ -2421,17 +2421,17 @@ static unsigned OptPtrLoad4 (CodeSeg* S) /* We will create all the new stuff behind the current one so * we keep the line references. */ - X = NewCodeEntry (OP65_LDX, L[3]->AM, L[3]->Arg, 0, L[0]->LI); + X = NewCodeEntry (OP65_LDY, L[3]->AM, L[3]->Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+8); - Label = memcpy (xmalloc (Len-2), L[0]->Arg+2, Len-3); - Label[Len-3] = '\0'; - X = NewCodeEntry (OP65_LDA, AM65_ABSX, Label, 0, L[0]->LI); + X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, L[0]->LI); CS_InsertEntry (S, X, I+9); - xfree (Label); - X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, L[0]->LI); + Label = memcpy (xmalloc (Len-2), L[0]->Arg+2, Len-3); + Label[Len-3] = '\0'; + X = NewCodeEntry (OP65_LDA, AM65_ABSY, Label, 0, L[0]->LI); CS_InsertEntry (S, X, I+10); + xfree (Label); /* Remove the old code */ CS_DelEntries (S, I, 8); @@ -2469,13 +2469,13 @@ static unsigned OptPtrLoad5 (CodeSeg* S) * * ldy #$xx * lda (sp),y - * tax - * lda label,x + * tay * ldx #$00 + * lda label,y */ { unsigned Changes = 0; - + /* Walk over the entries */ unsigned I = 0; while (I < CS_GetEntryCount (S)) { @@ -2528,20 +2528,20 @@ static unsigned OptPtrLoad5 (CodeSeg* S) X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, L[4]->Arg, 0, L[0]->LI); CS_InsertEntry (S, X, I+3); - /* Add the tax */ - X = NewCodeEntry (OP65_TAX, AM65_IMP, 0, 0, L[0]->LI); + /* Add the tay */ + X = NewCodeEntry (OP65_TAY, AM65_IMP, 0, 0, L[0]->LI); CS_InsertEntry (S, X, I+4); + /* Add the ldx */ + X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, L[0]->LI); + CS_InsertEntry (S, X, I+5); + /* Add the lda */ Label = memcpy (xmalloc (Len-2), L[0]->Arg+2, Len-3); Label[Len-3] = '\0'; - X = NewCodeEntry (OP65_LDA, AM65_ABSX, Label, 0, L[0]->LI); - CS_InsertEntry (S, X, I+5); - xfree (Label); - - /* Add the ldx */ - X = NewCodeEntry (OP65_LDX, AM65_IMM, "$00", 0, L[0]->LI); + X = NewCodeEntry (OP65_LDA, AM65_ABSY, Label, 0, L[0]->LI); CS_InsertEntry (S, X, I+6); + xfree (Label); /* Remove the old code */ CS_DelEntries (S, I, 2); -- 2.39.5