mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Fix bug introduced in #2260
bne should have applied to A, not X, but adding a cmp #$00 before makes the change less optimized than the existing.
This commit is contained in:
parent
519a52d92c
commit
2a2cc6cad6
@ -3697,13 +3697,7 @@ void g_dec (unsigned flags, unsigned long val)
|
|||||||
} else {
|
} else {
|
||||||
/* Inline the code */
|
/* Inline the code */
|
||||||
if (val < 0x300) {
|
if (val < 0x300) {
|
||||||
if ((CPUIsets[CPU] & CPU_ISET_65SC02) != 0 && val == 1) {
|
if ((val & 0xFF) != 0) {
|
||||||
unsigned L = GetLocalLabel();
|
|
||||||
AddCodeLine ("bne %s", LocalLabelName (L));
|
|
||||||
AddCodeLine ("dex");
|
|
||||||
g_defcodelabel (L);
|
|
||||||
AddCodeLine ("dea");
|
|
||||||
} else if ((val & 0xFF) != 0) {
|
|
||||||
unsigned L = GetLocalLabel();
|
unsigned L = GetLocalLabel();
|
||||||
AddCodeLine ("sec");
|
AddCodeLine ("sec");
|
||||||
AddCodeLine ("sbc #$%02X", (unsigned char) val);
|
AddCodeLine ("sbc #$%02X", (unsigned char) val);
|
||||||
|
@ -168,6 +168,31 @@ void post_dec_assign_test(void)
|
|||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dex_tests(void) {
|
||||||
|
static unsigned int a, b;
|
||||||
|
|
||||||
|
a = 257;
|
||||||
|
b = a - 1;
|
||||||
|
if (b != 256) {
|
||||||
|
printf("fail 257 => 256\n");
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = 256;
|
||||||
|
b = a - 1;
|
||||||
|
if (b != 255) {
|
||||||
|
printf("fail 256 => 255\n");
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = 255;
|
||||||
|
b = a - 1;
|
||||||
|
if (b != 254) {
|
||||||
|
printf("fail 255 => 254\n");
|
||||||
|
failures++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int0 = 5;
|
int0 = 5;
|
||||||
@ -186,6 +211,8 @@ int main(void)
|
|||||||
int1 = 5;
|
int1 = 5;
|
||||||
post_dec_assign_test();
|
post_dec_assign_test();
|
||||||
|
|
||||||
|
dex_tests();
|
||||||
|
|
||||||
printf("failures: %d\n",failures);
|
printf("failures: %d\n",failures);
|
||||||
|
|
||||||
return failures;
|
return failures;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user