1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-05 21:29:03 +00:00

Fixed a problem with OptPtrLoad6 (must correct stack pointer).

git-svn-id: svn://svn.cc65.org/cc65/trunk@4054 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-08-27 16:13:17 +00:00
parent 1b40f00573
commit 7c55f30627

View File

@ -550,7 +550,7 @@ unsigned OptPtrLoad6 (CodeSeg* S)
/* Search for the sequence: /* Search for the sequence:
* *
* jsr pushax * jsr pushax
* ldy xxx * ldy #xxx
* ldx #$00 * ldx #$00
* lda (sp),y * lda (sp),y
* jsr tosaddax * jsr tosaddax
@ -561,11 +561,12 @@ unsigned OptPtrLoad6 (CodeSeg* S)
* *
* sta ptr1 * sta ptr1
* stx ptr1+1 * stx ptr1+1
* ldy xxx * ldy #xxx-2
* lda (sp),y * lda (sp),y
* tay * tay
* ldx #$00 * ldx #$00
* lda (ptr1),y * lda (ptr1),y
* ldy #$00
*/ */
{ {
unsigned Changes = 0; unsigned Changes = 0;
@ -583,6 +584,8 @@ unsigned OptPtrLoad6 (CodeSeg* S)
if (CE_IsCallTo (L[0], "pushax") && if (CE_IsCallTo (L[0], "pushax") &&
CS_GetEntries (S, L+1, I+1, 6) && CS_GetEntries (S, L+1, I+1, 6) &&
L[1]->OPC == OP65_LDY && L[1]->OPC == OP65_LDY &&
CE_IsConstImm (L[1]) &&
L[1]->Num >= 2 &&
L[2]->OPC == OP65_LDX && L[2]->OPC == OP65_LDX &&
CE_IsKnownImm (L[2], 0) && CE_IsKnownImm (L[2], 0) &&
L[3]->OPC == OP65_LDA && L[3]->OPC == OP65_LDA &&
@ -593,7 +596,8 @@ unsigned OptPtrLoad6 (CodeSeg* S)
CE_IsCallTo (L[6], "ldauidx") && CE_IsCallTo (L[6], "ldauidx") &&
!CS_RangeHasLabel (S, I+1, 6)) { !CS_RangeHasLabel (S, I+1, 6)) {
CodeEntry* X; CodeEntry* X;
const char* Arg;
/* sta ptr1 */ /* sta ptr1 */
X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1", 0, L[0]->LI); X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1", 0, L[0]->LI);
@ -603,8 +607,9 @@ unsigned OptPtrLoad6 (CodeSeg* S)
X = NewCodeEntry (OP65_STX, AM65_ZP, "ptr1+1", 0, L[0]->LI); X = NewCodeEntry (OP65_STX, AM65_ZP, "ptr1+1", 0, L[0]->LI);
CS_InsertEntry (S, X, I+8); CS_InsertEntry (S, X, I+8);
/* ldy yyy */ /* ldy #xxx-2 */
X = NewCodeEntry (OP65_LDY, L[1]->AM, L[1]->Arg, 0, L[1]->LI); Arg = MakeHexArg (L[1]->Num - 2);
X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[1]->LI);
CS_InsertEntry (S, X, I+9); CS_InsertEntry (S, X, I+9);
/* lda (sp),y */ /* lda (sp),y */
@ -623,6 +628,10 @@ unsigned OptPtrLoad6 (CodeSeg* S)
X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "ptr1", 0, L[6]->LI); X = NewCodeEntry (OP65_LDA, AM65_ZP_INDY, "ptr1", 0, L[6]->LI);
CS_InsertEntry (S, X, I+13); CS_InsertEntry (S, X, I+13);
/* ldy #$00 (will eventually get removed later) */
X = NewCodeEntry (OP65_LDY, AM65_IMM, "$00", 0, L[5]->LI);
CS_InsertEntry (S, X, I+14);
/* Remove the old code */ /* Remove the old code */
CS_DelEntries (S, I, 7); CS_DelEntries (S, I, 7);