From 532c279ca9fb4c277b562293645543fc5e894067 Mon Sep 17 00:00:00 2001 From: epetrich Date: Thu, 29 Jan 2004 06:36:41 +0000 Subject: [PATCH] * src/z80/gen.c (genMult): handle single byte result product * src/SDCCopt.c (killDeadCode): never convert ADDRESS_OF iCode to DUMMY_READ_VOLATILE (fixed bug #886367) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3156 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++++ src/SDCCopt.c | 5 ++++- src/z80/gen.c | 22 ++++++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index cd836033..b3453cdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-01-27 Erik Petrich + + * src/z80/gen.c (genMult): handle single byte result product + * src/SDCCopt.c (killDeadCode): never convert ADDRESS_OF iCode to + DUMMY_READ_VOLATILE (fixed bug #886367) + 2004-01-27 Bernhard Held * support/regression/tests/libmullong.c: fixed logic, on little endian diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 05eab6f5..8ae80be0 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -878,7 +878,10 @@ killDeadCode (eBBlock ** ebbs, int count) bool volRight = IS_SYMOP (IC_RIGHT (ic)) && isOperandVolatile (IC_RIGHT (ic), FALSE); - + /* a dead address-of operation should die, even if volatile */ + if (ic->op == ADDRESS_OF) + volLeft = FALSE; + if (ic->next && ic->seqPoint == ic->next->seqPoint && (ic->next->op == '+' || ic->next->op == '-')) { diff --git a/src/z80/gen.c b/src/z80/gen.c index cd669c7c..281dc7ba 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -4042,11 +4042,14 @@ genMult (iCode * ic) int count, i; /* If true then the final operation should be a subtract */ bool active = FALSE; + bool byteResult; /* Shouldn't occur - all done through function calls */ aopOp (IC_LEFT (ic), ic, FALSE, FALSE); aopOp (IC_RIGHT (ic), ic, FALSE, FALSE); aopOp (IC_RESULT (ic), ic, TRUE, FALSE); + + byteResult = (AOP_SIZE (IC_RESULT (ic)) == 1); if (AOP_SIZE (IC_LEFT (ic)) > 2 || AOP_SIZE (IC_RIGHT (ic)) > 2 || @@ -4077,10 +4080,13 @@ genMult (iCode * ic) if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic))))) { emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE)); - emit2 ("ld a,e"); - emit2 ("rlc a"); - emit2 ("sbc a,a"); - emit2 ("ld d,a"); + if (!byteResult) + { + emit2 ("ld a,e"); + emit2 ("rlc a"); + emit2 ("sbc a,a"); + emit2 ("ld d,a"); + } } else { @@ -4102,7 +4108,8 @@ genMult (iCode * ic) if (active == FALSE) { emit2 ("ld l,e"); - emit2 ("ld h,d"); + if (!byteResult) + emit2 ("ld h,d"); } else { @@ -4121,7 +4128,10 @@ genMult (iCode * ic) _G.stack.pushedDE = FALSE; } - commitPair ( AOP (IC_RESULT (ic)), PAIR_HL); + if (byteResult) + aopPut (AOP (IC_RESULT (ic)), _pairs[PAIR_HL].l, 0); + else + commitPair ( AOP (IC_RESULT (ic)), PAIR_HL); freeAsmop (IC_LEFT (ic), NULL, ic); freeAsmop (IC_RIGHT (ic), NULL, ic); -- 2.47.2