mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 19:29:37 +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:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
@ -2866,26 +2868,30 @@ void g_and (unsigned Flags, unsigned long Val)
|
||||
if (Val <= 0xFF) {
|
||||
ldxconst (0);
|
||||
if (Val == 0) {
|
||||
ldaconst (0);
|
||||
AddCodeLine ("lda #$00");
|
||||
} else if (Val != 0xFF) {
|
||||
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);
|
||||
} else if ((Val & 0x00FF) == 0x0000) {
|
||||
AddCodeLine ("txa");
|
||||
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
||||
AddCodeLine ("tax");
|
||||
ldaconst (0);
|
||||
AddCodeLine ("lda #$00");
|
||||
} else {
|
||||
AddCodeLine ("tay");
|
||||
AddCodeLine ("txa");
|
||||
AddCodeLine ("and #$%02X", (unsigned char)(Val >> 8));
|
||||
AddCodeLine ("tax");
|
||||
AddCodeLine ("tya");
|
||||
if ((Val & 0x00FF) != 0x00FF) {
|
||||
if ((Val & 0x00FF) == 0x0000) {
|
||||
AddCodeLine ("lda #$00");
|
||||
} else if ((Val & 0x00FF) != 0x00FF) {
|
||||
AddCodeLine ("and #$%02X", (unsigned char)Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -1845,8 +1845,9 @@ unsigned OptPrecalc (CodeSeg* S)
|
||||
/* Get next entry */
|
||||
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* In = &E->RI->In;
|
||||
|
||||
/* Argument for LDn and flag */
|
||||
const char* Arg = 0;
|
||||
@ -1894,9 +1895,16 @@ unsigned OptPrecalc (CodeSeg* S)
|
||||
/* AND with 0xFF, remove */
|
||||
CS_DelEntry (S, I);
|
||||
++Changes;
|
||||
} else if (CE_IsKnownImm (E, 0x00)) {
|
||||
/* AND with 0x00, replace by lda #$00 */
|
||||
Arg = MakeHexArg (0x00);
|
||||
} else if (RegValIsKnown (Out->RegA)) {
|
||||
/* Accu AND zp with known contents */
|
||||
Arg = MakeHexArg (Out->RegA);
|
||||
} else if (In->RegA == 0xFF) {
|
||||
/* AND but A contains 0xFF - replace by lda */
|
||||
CE_ReplaceOPC (E, OP65_LDA);
|
||||
++Changes;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1905,9 +1913,16 @@ unsigned OptPrecalc (CodeSeg* S)
|
||||
/* ORA with zero, remove */
|
||||
CS_DelEntry (S, I);
|
||||
++Changes;
|
||||
} else if (CE_IsKnownImm (E, 0xFF)) {
|
||||
/* ORA with 0xFF, replace by lda #$ff */
|
||||
Arg = MakeHexArg (0xFF);
|
||||
} else if (RegValIsKnown (Out->RegA)) {
|
||||
/* Accu AND zp with known contents */
|
||||
Arg = MakeHexArg (Out->RegA);
|
||||
} else if (In->RegA == 0) {
|
||||
/* ORA but A contains 0x00 - replace by lda */
|
||||
CE_ReplaceOPC (E, OP65_LDA);
|
||||
++Changes;
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user