mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +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)
|
||||
/* Decouple operations, that is, do the following replacements:
|
||||
*
|
||||
* dex -> ldx
|
||||
* inx -> ldx
|
||||
* dey -> ldy
|
||||
* iny -> ldy
|
||||
* tax -> ldx
|
||||
* txa -> lda
|
||||
* tay -> ldy
|
||||
* tya -> lda
|
||||
* dex -> ldx #imm
|
||||
* inx -> ldx #imm
|
||||
* dey -> ldy #imm
|
||||
* iny -> ldy #imm
|
||||
* tax -> ldx #imm
|
||||
* txa -> lda #imm
|
||||
* tay -> ldy #imm
|
||||
* tya -> lda #imm
|
||||
* lda sreg -> lda #imm
|
||||
* ldx sreg -> ldx #imm
|
||||
* ldy sreg -> ldy #imm
|
||||
*
|
||||
* Provided that the register values are known of course.
|
||||
*/
|
||||
@ -1013,6 +1016,42 @@ static unsigned OptDecouple (CodeSeg* S)
|
||||
}
|
||||
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:
|
||||
if (E->RI->In.RegA >= 0) {
|
||||
xsprintf (Buf, sizeof (Buf), "$%02X", E->RI->In.RegA);
|
||||
|
Loading…
Reference in New Issue
Block a user