From d0f9a0d6a7d685bdac04aaa88147766d5f68424b Mon Sep 17 00:00:00 2001 From: uz Date: Sat, 15 Aug 2009 16:49:46 +0000 Subject: [PATCH] Fixed wrong insertion order that caused problems with labels. git-svn-id: svn://svn.cc65.org/cc65/trunk@4022 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/codeopt.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cc65/codeopt.c b/src/cc65/codeopt.c index 254f30e23..7473d526f 100644 --- a/src/cc65/codeopt.c +++ b/src/cc65/codeopt.c @@ -109,6 +109,7 @@ static unsigned OptShift1 (CodeSeg* S) unsigned I = 0; while (I < CS_GetEntryCount (S)) { + CodeEntry* N; CodeEntry* X; CodeLabel* L; @@ -138,23 +139,24 @@ static unsigned OptShift1 (CodeSeg* S) ++Changes; } else if (E->RI->In.RegX == 0 && - E->Arg[5] == '1') { + E->Arg[5] == '1' && + (N = CS_GetNextEntry (S, I)) != 0) { /* asl a */ X = NewCodeEntry (OP65_ASL, AM65_ACC, "a", 0, E->LI); - CS_InsertEntry (S, X, I); + CS_InsertEntry (S, X, I+1); /* bcc L1 */ - L = CS_GenLabel (S, E); + L = CS_GenLabel (S, N); X = NewCodeEntry (OP65_BCC, AM65_BRA, L->Name, L, E->LI); - CS_InsertEntry (S, X, I+1); + CS_InsertEntry (S, X, I+2); /* inx */ X = NewCodeEntry (OP65_INX, AM65_IMP, 0, 0, E->LI); - CS_InsertEntry (S, X, I+2); + CS_InsertEntry (S, X, I+3); /* Delete the call to shlax */ - CS_DelEntry (S, I+3); + CS_DelEntry (S, I); /* Remember, we had changes */ ++Changes;