mirror of
https://github.com/cc65/cc65.git
synced 2025-01-22 06:30:38 +00:00
Fixed OptPush1 in case later code would rely on that pushax zeroes register Y.
This commit is contained in:
parent
2a3d996077
commit
f45d2515eb
@ -56,12 +56,14 @@ unsigned OptPush1 (CodeSeg* S)
|
|||||||
**
|
**
|
||||||
** ldy #xx+2
|
** ldy #xx+2
|
||||||
** jsr pushwysp
|
** jsr pushwysp
|
||||||
|
** ldy #$00 ; present if later code expects Y = 0
|
||||||
**
|
**
|
||||||
** saving 3 bytes and several cycles.
|
** saving several cycles.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
unsigned Changes = 0;
|
unsigned Changes = 0;
|
||||||
|
unsigned R;
|
||||||
|
|
||||||
/* Walk over the entries */
|
/* Walk over the entries */
|
||||||
I = 0;
|
I = 0;
|
||||||
@ -79,7 +81,7 @@ unsigned OptPush1 (CodeSeg* S)
|
|||||||
(L[1] = CS_GetNextEntry (S, I)) != 0 &&
|
(L[1] = CS_GetNextEntry (S, I)) != 0 &&
|
||||||
!CE_HasLabel (L[1]) &&
|
!CE_HasLabel (L[1]) &&
|
||||||
CE_IsCallTo (L[1], "pushax") &&
|
CE_IsCallTo (L[1], "pushax") &&
|
||||||
!RegAXUsed (S, I+2)) {
|
((R = (GetRegInfo (S, I+2, REG_AXY))) & REG_AX) == 0) {
|
||||||
|
|
||||||
/* Insert new code behind the pushax */
|
/* Insert new code behind the pushax */
|
||||||
const char* Arg;
|
const char* Arg;
|
||||||
@ -94,12 +96,25 @@ unsigned OptPush1 (CodeSeg* S)
|
|||||||
X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwysp", 0, L[1]->LI);
|
X = NewCodeEntry (OP65_JSR, AM65_ABS, "pushwysp", 0, L[1]->LI);
|
||||||
CS_InsertEntry (S, X, I+3);
|
CS_InsertEntry (S, X, I+3);
|
||||||
|
|
||||||
|
/* pushax sets Y = 0 and following code might rely on this */
|
||||||
|
if ((R & REG_Y) != 0) {
|
||||||
|
/* ldy #0 */
|
||||||
|
X = NewCodeEntry (OP65_LDY, AM65_IMM, MakeHexArg (0), 0, L[1]->LI);
|
||||||
|
CS_InsertEntry (S, X, I+4);
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete the old code */
|
/* Delete the old code */
|
||||||
CS_DelEntries (S, I, 2);
|
CS_DelEntries (S, I, 2);
|
||||||
|
|
||||||
/* Remember, we had changes */
|
/* Remember, we had changes */
|
||||||
++Changes;
|
++Changes;
|
||||||
|
|
||||||
|
/* Skip the handled lines */
|
||||||
|
if ((R & REG_Y) == 0) {
|
||||||
|
++I;
|
||||||
|
} else {
|
||||||
|
I += 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next entry */
|
/* Next entry */
|
||||||
|
@ -52,16 +52,16 @@
|
|||||||
unsigned OptPush1 (CodeSeg* S);
|
unsigned OptPush1 (CodeSeg* S);
|
||||||
/* Given a sequence
|
/* Given a sequence
|
||||||
**
|
**
|
||||||
** ldy #xx
|
|
||||||
** jsr ldaxysp
|
** jsr ldaxysp
|
||||||
** jsr pushax
|
** jsr pushax
|
||||||
**
|
**
|
||||||
** If a/x are not used later, replace that by
|
** If a/x are not used later, and Y is known, replace that by
|
||||||
**
|
**
|
||||||
** ldy #xx+2
|
** ldy #xx+2
|
||||||
** jsr pushwysp
|
** jsr pushwysp
|
||||||
|
** ldy #$00 ; present if later code expects Y = 0
|
||||||
**
|
**
|
||||||
** saving 3 bytes and several cycles.
|
** saving several cycles.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned OptPush2 (CodeSeg* S);
|
unsigned OptPush2 (CodeSeg* S);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user