Improved code for or and xor

git-svn-id: svn://svn.cc65.org/cc65/trunk@3102 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2004-06-05 22:10:04 +00:00
parent 5586527fcc
commit c76e14f9f5

View File

@@ -2779,33 +2779,38 @@ void g_or (unsigned flags, unsigned long val)
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case CF_INT: case CF_INT:
if (val <= 0xFF) { if (val <= 0xFF) {
if ((val & 0xFF) != 0) { if ((val & 0xFF) != 0) {
AddCodeLine ("ora #$%02X", (unsigned char)val); AddCodeLine ("ora #$%02X", (unsigned char)val);
} }
return;
} else if ((val & 0xFF00) == 0xFF00) { } else if ((val & 0xFF00) == 0xFF00) {
if ((val & 0xFF) != 0) { if ((val & 0xFF) != 0) {
AddCodeLine ("ora #$%02X", (unsigned char)val); AddCodeLine ("ora #$%02X", (unsigned char)val);
} }
ldxconst (0xFF); ldxconst (0xFF);
return; } else if (val != 0) {
AddCodeLine ("ora #$%02X", (unsigned char)val);
AddCodeLine ("pha");
AddCodeLine ("txa");
AddCodeLine ("ora #$%02X", (unsigned char)(val >> 8));
AddCodeLine ("tax");
AddCodeLine ("pla");
} }
break; return;
case CF_LONG: case CF_LONG:
if (val <= 0xFF) { if (val <= 0xFF) {
if ((val & 0xFF) != 0) { if ((val & 0xFF) != 0) {
AddCodeLine ("ora #$%02X", (unsigned char)val); AddCodeLine ("ora #$%02X", (unsigned char)val);
} }
return; return;
} }
break; break;
default: default:
typeerror (flags); typeerror (flags);
} }
/* If we go here, we didn't emit code. Push the lhs on stack and fall /* If we go here, we didn't emit code. Push the lhs on stack and fall
* into the normal, non-optimized stuff. Note: The standard stuff will * into the normal, non-optimized stuff. Note: The standard stuff will
@@ -2853,16 +2858,17 @@ void g_xor (unsigned flags, unsigned long val)
if (val != 0) { if (val != 0) {
AddCodeLine ("eor #$%02X", (unsigned char)val); AddCodeLine ("eor #$%02X", (unsigned char)val);
} }
return; } else if (val != 0) {
} else if ((val & 0xFF) == 0) { if ((val & 0xFF) != 0) {
AddCodeLine ("eor #$%02X", (unsigned char)val);
}
AddCodeLine ("pha"); AddCodeLine ("pha");
AddCodeLine ("txa"); AddCodeLine ("txa");
AddCodeLine ("eor #$%02X", (unsigned char)(val >> 8)); AddCodeLine ("eor #$%02X", (unsigned char)(val >> 8));
AddCodeLine ("tax"); AddCodeLine ("tax");
AddCodeLine ("pla"); AddCodeLine ("pla");
return;
} }
break; return;
case CF_LONG: case CF_LONG:
if (val <= 0xFF) { if (val <= 0xFF) {