From 55e8f67640d1bac23945d064fcea41986a0c3e79 Mon Sep 17 00:00:00 2001 From: uz Date: Thu, 27 Aug 2009 16:59:26 +0000 Subject: [PATCH] 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 --- src/cc65/codegen.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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"); -- 2.39.5