1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-01 13:41:34 +00:00

Always insert a LDA after the removed PLA during the optimization in OptPushPop.

Fixed Issue 971.
This commit is contained in:
acqn 2019-12-31 16:02:42 +08:00 committed by Oliver Schmidt
parent 5b11eb4bb9
commit 9559625ee8

View File

@ -1948,17 +1948,22 @@ unsigned OptPushPop (CodeSeg* S)
!MemAccess (S, Push+1, Pop-1, E)) {
/* Insert a STA after the PHA */
X = NewCodeEntry (E->OPC, E->AM, E->Arg, E->JumpTo, E->LI);
X = NewCodeEntry (OP65_STA, E->AM, E->Arg, E->JumpTo, E->LI);
CS_InsertEntry (S, X, Push+1);
/* Remove the PHA instead */
CS_DelEntry (S, Push);
/* Insert a LDA after the PLA */
X = NewCodeEntry (OP65_LDA, E->AM, E->Arg, E->JumpTo, CS_GetEntry (S, Pop)->LI);
CS_InsertEntry (S, X, Pop+1);
/* Remove the PLA/STA sequence */
CS_DelEntries (S, Pop, 2);
CS_DelEntry (S, Pop);
CS_DelEntry (S, I);
/* Correct I so we continue with the next insn */
I -= 2;
--I;
/* Remember we had changes */
++Changes;