mirror of
https://github.com/cc65/cc65.git
synced 2024-12-24 11:31:31 +00:00
Code improvements
git-svn-id: svn://svn.cc65.org/cc65/trunk@4081 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
7f7dc69290
commit
b098d8045e
@ -2855,7 +2855,9 @@ void g_and (unsigned Flags, unsigned long Val)
|
|||||||
|
|
||||||
case CF_CHAR:
|
case CF_CHAR:
|
||||||
if (Flags & CF_FORCECHAR) {
|
if (Flags & CF_FORCECHAR) {
|
||||||
if ((Val & 0xFF) != 0xFF) {
|
if ((Val & 0xFF) == 0x00) {
|
||||||
|
AddCodeLine ("lda #$00");
|
||||||
|
} else if ((Val & 0xFF) != 0xFF) {
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2866,26 +2868,30 @@ void g_and (unsigned Flags, unsigned long Val)
|
|||||||
if (Val <= 0xFF) {
|
if (Val <= 0xFF) {
|
||||||
ldxconst (0);
|
ldxconst (0);
|
||||||
if (Val == 0) {
|
if (Val == 0) {
|
||||||
ldaconst (0);
|
AddCodeLine ("lda #$00");
|
||||||
} else if (Val != 0xFF) {
|
} else if (Val != 0xFF) {
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
||||||
}
|
}
|
||||||
} else if ((Val & 0xFF00) == 0xFF00) {
|
} else if ((Val & 0xFFFF) == 0xFF00) {
|
||||||
|
AddCodeLine ("lda #$00");
|
||||||
|
} else if ((Val & 0xFF00) == 0xFF00) {
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
||||||
} else if ((Val & 0x00FF) == 0x0000) {
|
} else if ((Val & 0x00FF) == 0x0000) {
|
||||||
AddCodeLine ("txa");
|
AddCodeLine ("txa");
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
||||||
AddCodeLine ("tax");
|
AddCodeLine ("tax");
|
||||||
ldaconst (0);
|
AddCodeLine ("lda #$00");
|
||||||
} else {
|
} else {
|
||||||
AddCodeLine ("tay");
|
AddCodeLine ("tay");
|
||||||
AddCodeLine ("txa");
|
AddCodeLine ("txa");
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
||||||
AddCodeLine ("tax");
|
AddCodeLine ("tax");
|
||||||
AddCodeLine ("tya");
|
AddCodeLine ("tya");
|
||||||
if ((Val & 0x00FF) != 0x00FF) {
|
if ((Val & 0x00FF) == 0x0000) {
|
||||||
|
AddCodeLine ("lda #$00");
|
||||||
|
} else if ((Val & 0x00FF) != 0x00FF) {
|
||||||
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1845,8 +1845,9 @@ unsigned OptPrecalc (CodeSeg* S)
|
|||||||
/* Get next entry */
|
/* Get next entry */
|
||||||
CodeEntry* E = CS_GetEntry (S, I);
|
CodeEntry* E = CS_GetEntry (S, I);
|
||||||
|
|
||||||
/* Get a pointer to the output registers of the insn */
|
/* Get pointers to the input and output registers of the insn */
|
||||||
const RegContents* Out = &E->RI->Out;
|
const RegContents* Out = &E->RI->Out;
|
||||||
|
const RegContents* In = &E->RI->In;
|
||||||
|
|
||||||
/* Argument for LDn and flag */
|
/* Argument for LDn and flag */
|
||||||
const char* Arg = 0;
|
const char* Arg = 0;
|
||||||
@ -1894,9 +1895,16 @@ unsigned OptPrecalc (CodeSeg* S)
|
|||||||
/* AND with 0xFF, remove */
|
/* AND with 0xFF, remove */
|
||||||
CS_DelEntry (S, I);
|
CS_DelEntry (S, I);
|
||||||
++Changes;
|
++Changes;
|
||||||
|
} else if (CE_IsKnownImm (E, 0x00)) {
|
||||||
|
/* AND with 0x00, replace by lda #$00 */
|
||||||
|
Arg = MakeHexArg (0x00);
|
||||||
} else if (RegValIsKnown (Out->RegA)) {
|
} else if (RegValIsKnown (Out->RegA)) {
|
||||||
/* Accu AND zp with known contents */
|
/* Accu AND zp with known contents */
|
||||||
Arg = MakeHexArg (Out->RegA);
|
Arg = MakeHexArg (Out->RegA);
|
||||||
|
} else if (In->RegA == 0xFF) {
|
||||||
|
/* AND but A contains 0xFF - replace by lda */
|
||||||
|
CE_ReplaceOPC (E, OP65_LDA);
|
||||||
|
++Changes;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1905,9 +1913,16 @@ unsigned OptPrecalc (CodeSeg* S)
|
|||||||
/* ORA with zero, remove */
|
/* ORA with zero, remove */
|
||||||
CS_DelEntry (S, I);
|
CS_DelEntry (S, I);
|
||||||
++Changes;
|
++Changes;
|
||||||
|
} else if (CE_IsKnownImm (E, 0xFF)) {
|
||||||
|
/* ORA with 0xFF, replace by lda #$ff */
|
||||||
|
Arg = MakeHexArg (0xFF);
|
||||||
} else if (RegValIsKnown (Out->RegA)) {
|
} else if (RegValIsKnown (Out->RegA)) {
|
||||||
/* Accu AND zp with known contents */
|
/* Accu AND zp with known contents */
|
||||||
Arg = MakeHexArg (Out->RegA);
|
Arg = MakeHexArg (Out->RegA);
|
||||||
|
} else if (In->RegA == 0) {
|
||||||
|
/* ORA but A contains 0x00 - replace by lda */
|
||||||
|
CE_ReplaceOPC (E, OP65_LDA);
|
||||||
|
++Changes;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user