mirror of
https://github.com/cc65/cc65.git
synced 2024-09-11 06:54:33 +00:00
Track sreg in OptDecouple
git-svn-id: svn://svn.cc65.org/cc65/trunk@1019 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
babcf84f17
commit
4fb253cef0
@ -952,14 +952,17 @@ static unsigned OptPtrLoad6 (CodeSeg* S)
|
|||||||
static unsigned OptDecouple (CodeSeg* S)
|
static unsigned OptDecouple (CodeSeg* S)
|
||||||
/* Decouple operations, that is, do the following replacements:
|
/* Decouple operations, that is, do the following replacements:
|
||||||
*
|
*
|
||||||
* dex -> ldx
|
* dex -> ldx #imm
|
||||||
* inx -> ldx
|
* inx -> ldx #imm
|
||||||
* dey -> ldy
|
* dey -> ldy #imm
|
||||||
* iny -> ldy
|
* iny -> ldy #imm
|
||||||
* tax -> ldx
|
* tax -> ldx #imm
|
||||||
* txa -> lda
|
* txa -> lda #imm
|
||||||
* tay -> ldy
|
* tay -> ldy #imm
|
||||||
* tya -> lda
|
* tya -> lda #imm
|
||||||
|
* lda sreg -> lda #imm
|
||||||
|
* ldx sreg -> ldx #imm
|
||||||
|
* ldy sreg -> ldy #imm
|
||||||
*
|
*
|
||||||
* Provided that the register values are known of course.
|
* Provided that the register values are known of course.
|
||||||
*/
|
*/
|
||||||
@ -1013,6 +1016,42 @@ static unsigned OptDecouple (CodeSeg* S)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OP65_LDA:
|
||||||
|
if (E->AM == AM65_ZP) {
|
||||||
|
if ((E->Use & REG_SREG_LO) != 0 && E->RI->In.SRegLo >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegLo);
|
||||||
|
X = NewCodeEntry (OP65_LDA, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
} else if ((E->Use & REG_SREG_HI) != 0 && E->RI->In.SRegHi >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegHi);
|
||||||
|
X = NewCodeEntry (OP65_LDA, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OP65_LDX:
|
||||||
|
if (E->AM == AM65_ZP) {
|
||||||
|
if ((E->Use & REG_SREG_LO) != 0 && E->RI->In.SRegLo >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegLo);
|
||||||
|
X = NewCodeEntry (OP65_LDX, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
} else if ((E->Use & REG_SREG_HI) != 0 && E->RI->In.SRegHi >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegHi);
|
||||||
|
X = NewCodeEntry (OP65_LDX, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OP65_LDY:
|
||||||
|
if (E->AM == AM65_ZP) {
|
||||||
|
if ((E->Use & REG_SREG_LO) != 0 && E->RI->In.SRegLo >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegLo);
|
||||||
|
X = NewCodeEntry (OP65_LDY, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
} else if ((E->Use & REG_SREG_HI) != 0 && E->RI->In.SRegHi >= 0) {
|
||||||
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.SRegHi);
|
||||||
|
X = NewCodeEntry (OP65_LDY, AM65_IMM, Buf, 0, E->LI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case OP65_TAX:
|
case OP65_TAX:
|
||||||
if (E->RI->In.RegA >= 0) {
|
if (E->RI->In.RegA >= 0) {
|
||||||
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.RegA);
|
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.RegA);
|
||||||
|
Loading…
Reference in New Issue
Block a user