From: spth Date: Fri, 22 Feb 2008 16:18:04 +0000 (+0000) Subject: Rewrote 8-bit multiplication by constant, implements #1898231 X-Git-Url: https://git.gag.com/?p=fw%2Fsdcc;a=commitdiff_plain;h=31dc61b2804673867ffd66fad66c5d2638ec4ea2 Rewrote 8-bit multiplication by constant, implements #1898231 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5041 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 506b5b01..e0b1aa68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2008-02-22 Philipp Klaus Krause + + * src/z80/gen.c (genMult): Rewrote 8-bit multiplication by constant, + implements #1898231 + 2008-02-22 Philipp Klaus Krause * device/lib/z80/mul.s: Rewrote __muluchar_rrx_s, to improve 8-bit mult., - implements #1896290. + implements #1896290 2008-02-22 Maarten Brock diff --git a/src/z80/gen.c b/src/z80/gen.c index 9e995211..f957a6ac 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -4231,7 +4231,9 @@ genMult (iCode * ic) _G.stack.pushedDE = TRUE; } - if ( AOP_SIZE (IC_LEFT (ic)) == 1 && !SPEC_USIGN (getSpec (operandType ( IC_LEFT (ic))))) + if (byteResult) + emit2 ("ld a,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE)); + else 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)); if (!byteResult) @@ -4249,25 +4251,33 @@ genMult (iCode * ic) i = val; - /* Fully unroled version of mul.s. Not the most efficient. - */ for (count = 0; count < 16; count++) { if (count != 0 && active) { - emit2 ("add hl,hl"); + if (byteResult) + emit2 ("add a,a"); + else + emit2 ("add hl,hl"); } if (i & 0x8000U) { if (active == FALSE) { - emit2 ("ld l,e"); - if (!byteResult) - emit2 ("ld h,d"); + if (byteResult) + emit2("ld e,a"); + else + { + emit2 ("ld l,e"); + emit2 ("ld h,d"); + } } else { - emit2 ("add hl,de"); + if (byteResult) + emit2 ("add a,e"); + else + emit2 ("add hl,de"); } active = TRUE; } @@ -4283,7 +4293,7 @@ genMult (iCode * ic) } if (byteResult) - aopPut (AOP (IC_RESULT (ic)), _pairs[PAIR_HL].l, 0); + aopPut (AOP (IC_RESULT (ic)), "a", 0); else commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);