From: uz Date: Fri, 4 Sep 2009 20:16:18 +0000 (+0000) Subject: Fix problem with OptPtrLoad1 - never insert before the deleted code, always X-Git-Tag: V2.13.0rc1~139 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fa2064ae3b947a7f5ddf0f6575fc4ee3c32d64a5;p=cc65 Fix problem with OptPtrLoad1 - never insert before the deleted code, always delete after! Otherwise labels will get wrong. git-svn-id: svn://svn.cc65.org/cc65/trunk@4117 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/coptptrload.c b/src/cc65/coptptrload.c index b8b9f38fc..4c445d013 100644 --- a/src/cc65/coptptrload.c +++ b/src/cc65/coptptrload.c @@ -108,7 +108,7 @@ unsigned OptPtrLoad1 (CodeSeg* S) CodeEntry* P; /* Track the insertion point */ - unsigned IP = I; + unsigned IP = I+9; /* sta ptr1 */ X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1", 0, L[2]->LI); @@ -127,8 +127,9 @@ unsigned OptPtrLoad1 (CodeSeg* S) } CS_InsertEntry (S, X, IP++); - /* clc is now in the right place */ - ++IP; + /* clc */ + X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, L[0]->LI); + CS_InsertEntry (S, X, IP++); /* adc yyy */ X = NewCodeEntry (OP65_ADC, L[4]->AM, L[4]->Arg, 0, L[4]->LI); @@ -151,7 +152,7 @@ unsigned OptPtrLoad1 (CodeSeg* S) CS_InsertEntry (S, X, IP++); /* Remove the old instructions */ - CS_DelEntries (S, IP, 8); + CS_DelEntries (S, I, 9); /* Remember, we had changes */ ++Changes;