(shiftIntoPair): added case 2 for PAIR_IY,
(setupToPreserveCarry): replaced parameters with iCode and check if
PAIR_DE is in use to fix bug
1399290,
(genPlus, genMinus): updated call to setupToPreserveCarry
* support/regression/tests/bug1399290.c: new
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4323
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2006-08-07 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * src/z80/gen.c (aopPut): fixed bug !*ixy should be !*iyx,
+ (shiftIntoPair): added case 2 for PAIR_IY,
+ (setupToPreserveCarry): replaced parameters with iCode and check if
+ PAIR_DE is in use to fix bug 1399290,
+ (genPlus, genMinus): updated call to setupToPreserveCarry
+ * support/regression/tests/bug1399290.c: new
+
2006-08-06 Maarten Brock <sourceforge.brock AT dse.nl>
* device/lib/Makefile.in (Z80SOURCES): enabled float support
2006-08-06 Maarten Brock <sourceforge.brock AT dse.nl>
* device/lib/Makefile.in (Z80SOURCES): enabled float support
if (aop->aopu.aop_pairId==PAIR_IX)
emit2 ("ld !*ixx,%s", 0, s);
else if (aop->aopu.aop_pairId==PAIR_IY)
if (aop->aopu.aop_pairId==PAIR_IX)
emit2 ("ld !*ixx,%s", 0, s);
else if (aop->aopu.aop_pairId==PAIR_IY)
- emit2 ("ld !*ixy,%s", 0, s);
+ emit2 ("ld !*iyx,%s", 0, s);
else
emit2 ("ld (%s),%s", _pairs[aop->aopu.aop_pairId].name, s);
break;
else
emit2 ("ld (%s),%s", _pairs[aop->aopu.aop_pairId].name, s);
break;
wassertl (IS_Z80, "Only implemented for the Z80");
// wassertl (aop->type == AOP_EXSTK, "Only implemented for EXSTK");
wassertl (IS_Z80, "Only implemented for the Z80");
// wassertl (aop->type == AOP_EXSTK, "Only implemented for EXSTK");
+ emitDebug ("; Shift into pair idx %u", idx);
+
switch (idx)
{
case 0:
id = PAIR_HL;
switch (idx)
{
case 0:
id = PAIR_HL;
+ setupPair (PAIR_HL, aop, 0);
break;
case 1:
id = PAIR_DE;
_push (PAIR_DE);
break;
case 1:
id = PAIR_DE;
_push (PAIR_DE);
- break;
- default:
- wassertl (0, "Internal error - hit default case");
- }
-
- emitDebug ("; Shift into pair idx %u", idx);
-
- if (id == PAIR_HL)
- {
- setupPair (PAIR_HL, aop, 0);
- }
- else
- {
setupPair (PAIR_IY, aop, 0);
emit2 ("push iy");
emit2 ("pop %s", _pairs[id].name);
setupPair (PAIR_IY, aop, 0);
emit2 ("push iy");
emit2 ("pop %s", _pairs[id].name);
+ break;
+ case 2:
+ id = PAIR_IY;
+ setupPair (PAIR_IY, aop, 0);
+ break;
+ default:
+ wassertl (0, "Internal error - hit default case");
}
aop->type = AOP_PAIRPTR;
}
aop->type = AOP_PAIRPTR;
-setupToPreserveCarry (asmop *result, asmop *left, asmop *right)
+setupToPreserveCarry (iCode * ic)
+ asmop *left = AOP (IC_LEFT (ic));
+ asmop *right = AOP (IC_RIGHT (ic));
+ asmop *result = AOP (IC_RESULT (ic));
+
wassert (left && right);
if (IS_Z80)
wassert (left && right);
if (IS_Z80)
shiftIntoPair (0, right);
/* check result again, in case right == result */
if (couldDestroyCarry (result))
shiftIntoPair (0, right);
/* check result again, in case right == result */
if (couldDestroyCarry (result))
- shiftIntoPair (1, result);
+ {
+ if (!isPairInUse (PAIR_DE, ic))
+ shiftIntoPair (1, result);
+ else
+ shiftIntoPair (2, result);
+ }
}
else if (couldDestroyCarry (right))
{
}
else if (couldDestroyCarry (right))
{
- ld hl,sp+n trashes C so we cant afford to do it during an
- add with stack based varibles. Worst case is:
+ ld hl,sp+n trashes C so we can't afford to do it during an
+ add with stack based variables. Worst case is:
ld hl,sp+left
ld a,(hl)
ld hl,sp+right
ld hl,sp+left
ld a,(hl)
ld hl,sp+right
adc (hl)
ld hl,sp+result+1
ld (hl),a
adc (hl)
ld hl,sp+result+1
ld (hl),a
- So you cant afford to load up hl if either left, right, or result
+ So you can't afford to load up hl if either left, right, or result
is on the stack (*sigh*) The alt is:
ld hl,sp+left
ld de,(hl)
is on the stack (*sigh*) The alt is:
ld hl,sp+left
ld de,(hl)
- setupToPreserveCarry (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)), AOP (IC_RIGHT (ic)));
+ setupToPreserveCarry (ic);
freeAsmop (IC_LEFT (ic), NULL, ic);
freeAsmop (IC_RIGHT (ic), NULL, ic);
freeAsmop (IC_RESULT (ic), NULL, ic);
freeAsmop (IC_LEFT (ic), NULL, ic);
freeAsmop (IC_RIGHT (ic), NULL, ic);
freeAsmop (IC_RESULT (ic), NULL, ic);
}
/*-----------------------------------------------------------------*/
}
/*-----------------------------------------------------------------*/
- setupToPreserveCarry (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)), AOP (IC_RIGHT (ic)));
+ setupToPreserveCarry (ic);
/* if literal, add a,#-lit, else normal subb */
while (size--)
/* if literal, add a,#-lit, else normal subb */
while (size--)
--- /dev/null
+/* bug1399290.c\r
+ */\r
+#include <testfwk.h>\r
+\r
+unsigned long Left = 0x12345678;\r
+\r
+void\r
+testLongPlus(void)\r
+{\r
+ static unsigned long Result;\r
+ static unsigned long Rhs = 0x87654321;\r
+ static unsigned long *Lhs = &Left;\r
+\r
+ Result = *Lhs + Rhs;\r
+ ASSERT (Result == 0x99999999);\r
+}\r