From: uz Date: Thu, 27 Aug 2009 16:59:26 +0000 (+0000) Subject: Try to generate more predicable code. clc always before adc or sbc. X-Git-Tag: V2.13.0rc1~200 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=55e8f67640d1bac23945d064fcea41986a0c3e79;p=cc65 Try to generate more predicable code. clc always before adc or sbc. git-svn-id: svn://svn.cc65.org/cc65/trunk@4056 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 6527e76d1..a905e7128 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -3235,13 +3235,18 @@ void g_inc (unsigned flags, unsigned long val) if (val >= 0x300) { AddCodeLine ("inx"); } - } else { + } else if ((val & 0xFF) != 0) { AddCodeLine ("clc"); - if ((val & 0xFF) != 0) { - AddCodeLine ("adc #$%02X", (unsigned char) val); - } + AddCodeLine ("adc #$%02X", (unsigned char) val); + AddCodeLine ("pha"); + AddCodeLine ("txa"); + AddCodeLine ("adc #$%02X", (unsigned char) (val >> 8)); + AddCodeLine ("tax"); + AddCodeLine ("pla"); + } else { AddCodeLine ("pha"); AddCodeLine ("txa"); + AddCodeLine ("clc"); AddCodeLine ("adc #$%02X", (unsigned char) (val >> 8)); AddCodeLine ("tax"); AddCodeLine ("pla");