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;
emit2 ("pop af");
//parity odd <==> P/O=0 <==> interrupt enable flag IFF2 was 0 <==>
//don't enable interrupts as they were off before
- emit2 ("jp po,!tlabel", tlbl->key + 100);
+ emit2 ("jp PO,!tlabel", tlbl->key + 100);
emit2 ("!ei");
emit2 ("!tlabeldef", (tlbl->key + 100));
}
emit2 ("inc %s", aopGet (AOP (IC_RESULT (ic)), offset++, FALSE));
if (size)
{
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
}
}
emitLabel (tlbl->key + 100);
}
else
{
- emit2 ("!shortjp z,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp Z,!tlabel", tlbl->key + 100);
emit2 ("ld a,!one");
emitLabel (tlbl->key + 100);
outAcc (result);
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;
+ setupPair (PAIR_HL, aop, 0);
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);
+ break;
+ case 2:
+ id = PAIR_IY;
+ setupPair (PAIR_IY, aop, 0);
+ break;
+ default:
+ wassertl (0, "Internal error - hit default case");
}
aop->type = AOP_PAIRPTR;
}
static void
-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)
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))
{
}
/* Special case:
- 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
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)
}
}
- setupToPreserveCarry (AOP (IC_RESULT (ic)), AOP (IC_LEFT (ic)), AOP (IC_RIGHT (ic)));
+ setupToPreserveCarry (ic);
while (size--)
{
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--)
jlbl = IC_TRUE (ic);
if (!strcmp (jval, "a"))
{
- inst = "nz";
+ inst = "NZ";
}
else if (!strcmp (jval, "c"))
{
- inst = "c";
+ inst = "C";
}
else if (!strcmp (jval, "nc"))
{
- inst = "nc";
+ inst = "NC";
}
else if (!strcmp (jval, "m"))
{
- inst = "m";
+ inst = "M";
}
else if (!strcmp (jval, "p"))
{
- inst = "p";
+ inst = "P";
}
else
{
/* The buffer contains the bit on A that we should test */
- inst = "nz";
+ inst = "NZ";
}
}
else
jlbl = IC_FALSE (ic);
if (!strcmp (jval, "a"))
{
- inst = "z";
+ inst = "Z";
}
else if (!strcmp (jval, "c"))
{
- inst = "nc";
+ inst = "NC";
}
else if (!strcmp (jval, "nc"))
{
- inst = "c";
+ inst = "C";
}
else if (!strcmp (jval, "m"))
{
- inst = "p";
+ inst = "P";
}
else if (!strcmp (jval, "p"))
{
- inst = "m";
+ inst = "M";
}
else
{
/* The buffer contains the bit on A that we should test */
- inst = "z";
+ inst = "Z";
}
}
/* Z80 can do a conditional long jump */
{
emit2 ("or a,a");
}
- emit2 ("jp nz,!tlabel", lbl->key + 100);
+ emit2 ("jp NZ,!tlabel", lbl->key + 100);
}
else
{
while (size--)
{
- emit2 ("ld a,%s", aopGet (AOP (left), offset, FALSE));
- if ((AOP_TYPE (right) == AOP_LIT) && lit == 0)
+ _moveA (aopGet (AOP (left), offset, FALSE));
+ if ((unsigned int) ((lit >> (offset * 8)) & 0x0FFL) == 0)
emit2 ("or a,a");
else
- emit2 ("cp a,%s", aopGet (AOP (right), offset, FALSE));
- emit2 ("jp nz,!tlabel", lbl->key + 100);
+ emit2 ("sub a,%s", aopGet (AOP (right), offset, FALSE));
+ emit2 ("jp NZ,!tlabel", lbl->key + 100);
offset++;
}
}
while (size--)
{
_moveA (aopGet (AOP (left), offset, FALSE));
- if ((AOP_TYPE (left) == AOP_DIR && AOP_TYPE (right) == AOP_LIT) &&
+ if (/*AOP_TYPE (left) == AOP_DIR &&*/ AOP_TYPE (right) == AOP_LIT &&
((unsigned int) ((lit >> (offset * 8)) & 0x0FFL) == 0))
- /* PENDING */
- emit2 ("jp nz,!tlabel", lbl->key + 100);
+ {
+ /* PENDING */
+ /* MB: pending what? doesn't this need "or a,a"? */
+ /* and I don't think AOP_TYPE(left) has anything to do with this */
+ emit2 ("or a,a");
+ emit2 ("jp NZ,!tlabel", lbl->key + 100);
+ }
else
{
- emit2 ("cp %s", aopGet (AOP (right), offset, FALSE));
- emit2 ("jp nz,!tlabel", lbl->key + 100);
+ emit2 ("sub %s", aopGet (AOP (right), offset, FALSE));
+ emit2 ("jp NZ,!tlabel", lbl->key + 100);
}
offset++;
}
{
_moveA (aopGet (AOP (right), offset, FALSE));
emit2 ("cp %s", aopGet (AOP (left), offset, FALSE));
- emit2 ("!shortjp nz,!tlabel", lbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", lbl->key + 100);
offset++;
}
}
{
tlbl = newiTempLabel (NULL);
_toBoolean (left);
- emit2 ("!shortjp z,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp Z,!tlabel", tlbl->key + 100);
_toBoolean (right);
emitLabel (tlbl->key + 100);
outBitAcc (result);
{
tlbl = newiTempLabel (NULL);
_toBoolean (left);
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
_toBoolean (right);
emitLabel (tlbl->key + 100);
outBitAcc (result);
/* For the flags */
emit2 ("or a,a");
}
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
}
offset++;
}
_moveA (aopGet (AOP (left), offset, FALSE));
/* OR with any literal is the same as OR with itself. */
emit2 ("or a,a");
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
offset++;
}
{
_moveA (aopGet (AOP (left), offset, FALSE));
emit2 ("xor a,%s", aopGet (AOP (right), offset, FALSE));
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
offset++;
}
if (ifx)
emitLabel (tlbl1->key + 100);
emit2 ("dec a");
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
}
}
{
emitLabel (tlbl1->key + 100);
emit2 ("dec a");
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
}
}
}
}
emitLabel (tlbl1->key + 100);
emit2 ("dec a");
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
freeAsmop (left, NULL, ic);
freeAsmop (result, NULL, ic);
}
emitLabel (tlbl1->key + 100);
emit2 ("dec a");
- emit2 ("!shortjp nz,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp NZ,!tlabel", tlbl->key + 100);
freeAsmop (left, NULL, ic);
freeAsmop (result, NULL, ic);
symbol *tlbl = newiTempLabel (NULL);
emit2 ("bit %d,a", blen - 1);
- emit2 ("jp z,!tlabel", tlbl->key + 100);
+ emit2 ("jp Z,!tlabel", tlbl->key + 100);
emit2 ("or a,!immedbyte", (unsigned char) (0xff << blen));
emitLabel (tlbl->key + 100);
}
symbol *tlbl = newiTempLabel (NULL);
emit2 ("bit %d,a", blen - 1);
- emit2 ("jp z,!tlabel", tlbl->key + 100);
+ emit2 ("jp Z,!tlabel", tlbl->key + 100);
emit2 ("or a,!immedbyte", (unsigned char) (0xff << blen));
emitLabel (tlbl->key + 100);
}
symbol *tlbl = newiTempLabel (NULL);
emit2 ("bit %d,a", rlen - 1);
- emit2 ("jp z,!tlabel", tlbl->key + 100);
+ emit2 ("jp Z,!tlabel", tlbl->key + 100);
emit2 ("or a,!immedbyte", (unsigned char) (0xff << rlen));
emitLabel (tlbl->key + 100);
}
//disable interrupt
emit2 ("!di");
//parity odd <==> P/O=0 <==> interrupt enable flag IFF2=0
- emit2 ("jp po,!tlabel", tlbl->key + 100);
+ emit2 ("jp PO,!tlabel", tlbl->key + 100);
aopPut (AOP (IC_RESULT (ic)), "!one", 0);
emit2 ("!tlabeldef", (tlbl->key + 100));
freeAsmop (IC_RESULT (ic), NULL, ic);
aopOp (IC_RIGHT (ic), ic, FALSE, TRUE);
_toBoolean (IC_RIGHT (ic));
//don't enable interrupts if they were off before
- emit2 ("!shortjp z,!tlabel", tlbl->key + 100);
+ emit2 ("!shortjp Z,!tlabel", tlbl->key + 100);
emit2 ("!ei");
emitLabel (tlbl->key + 100);
freeAsmop (IC_RIGHT (ic), NULL, ic);
emit2 ("pop af");
//parity odd <==> P/O=0 <==> interrupt enable flag IFF2 was 0 <==>
//don't enable interrupts as they were off before
- emit2 ("jp po,!tlabel", tlbl->key + 100);
+ emit2 ("jp PO,!tlabel", tlbl->key + 100);
emit2 ("!ei");
emit2 ("!tlabeldef", (tlbl->key + 100));
}
emit2 ("ld a,(hl)");
emit2 ("ldi");
emit2 ("or a");
- emit2 ("!shortjp nz,!tlabel ; 1", label->key);
+ emit2 ("!shortjp NZ,!tlabel ; 1", label->key);
freeAsmop (from, NULL, ic->next);
freeAsmop (to, NULL, ic);