From 252222902186a93ae5cf7dccfafb2c5f75c35a76 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Sun, 12 Oct 2003 18:49:27 +0000 Subject: [PATCH] src/mcs51/gen.c (genCpl): fixed bug http://sf.net/mailarchive/message.php?msg_id=6263915 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2935 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 +++++ src/mcs51/gen.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a835827..0222cd69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-10-12 Bernhard Held + + * src/mcs51/gen.c (genCpl): fixed bug + http://sf.net/mailarchive/message.php?msg_id=6263915 + 2003-10-10 Bernhard Held * src/SDCCast.c (decorateType): added extended constant folding diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index fc821211..c453a792 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -1439,17 +1439,32 @@ genCpl (iCode * ic) aopOp (IC_RESULT (ic), ic, TRUE); /* special case if in bit space */ - if (AOP_TYPE (IC_RESULT (ic)) == AOP_CRY) { - if (AOP_TYPE (IC_LEFT (ic)) == AOP_CRY) { - emitcode ("mov", "c,%s", IC_LEFT (ic)->aop->aopu.aop_dir); - emitcode ("cpl", "c"); - emitcode ("mov", "%s,c", IC_RESULT (ic)->aop->aopu.aop_dir); - goto release; - } + if (AOP_TYPE (IC_RESULT (ic)) == AOP_CRY) + { + if (AOP_TYPE (IC_LEFT (ic)) == AOP_CRY) + { + emitcode ("mov", "c,%s", IC_LEFT (ic)->aop->aopu.aop_dir); + emitcode ("cpl", "c"); + emitcode ("mov", "%s,c", IC_RESULT (ic)->aop->aopu.aop_dir); + goto release; + } + tlbl=newiTempLabel(NULL); - emitcode ("cjne", "%s,#0x01,%05d$", - aopGet(AOP(IC_LEFT(ic)), 0, FALSE,FALSE), tlbl->key+100); - emitcode ("", "%05d$:", tlbl->key+100); + if (AOP_TYPE (IC_LEFT (ic)) == AOP_ACC || + AOP_TYPE (IC_LEFT (ic)) == AOP_REG || + IS_AOP_PREG (IC_LEFT (ic))) + { + emitcode ("cjne", "%s,#0x01,%05d$", + aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE), + tlbl->key + 100); + } + else + { + char *l = aopGet (AOP (IC_LEFT (ic)), 0, FALSE, FALSE); + MOVA (l); + emitcode ("cjne", "a,#0x01,%05d$", tlbl->key + 100); + } + emitcode ("", "%05d$:", tlbl->key + 100); outBitC (IC_RESULT(ic)); goto release; } -- 2.47.2