projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rewrote 8-bit multiplication by constant, implements #1898231
[fw/sdcc]
/
src
/
z80
/
gen.c
diff --git
a/src/z80/gen.c
b/src/z80/gen.c
index 9e995211db9a99afdbd95bf0cb03cf2e35f2e4c0..f957a6ac9ab98aa2655727e6c1e92542efa56a10 100644
(file)
--- a/
src/z80/gen.c
+++ b/
src/z80/gen.c
@@
-4231,7
+4231,9
@@
genMult (iCode * ic)
_G.stack.pushedDE = TRUE;
}
_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)
{
emit2 ("ld e,%s", aopGet (AOP (IC_LEFT (ic)), LSB, FALSE));
if (!byteResult)
@@
-4249,25
+4251,33
@@
genMult (iCode * ic)
i = val;
i = val;
- /* Fully unroled version of mul.s. Not the most efficient.
- */
for (count = 0; count < 16; count++)
{
if (count != 0 && active)
{
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)
{
}
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
{
}
else
{
- emit2 ("add hl,de");
+ if (byteResult)
+ emit2 ("add a,e");
+ else
+ emit2 ("add hl,de");
}
active = TRUE;
}
}
active = TRUE;
}
@@
-4283,7
+4293,7
@@
genMult (iCode * ic)
}
if (byteResult)
}
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);
else
commitPair ( AOP (IC_RESULT (ic)), PAIR_HL);