+2006-11-03 Maarten Brock <sourceforge.brock AT dse.nl>
+
+ * device/include/mcs51/c8051f020.h,
+ * device/include/mcs51/c8051f040.h,
+ * device/include/mcs51/c8051f060.h,
+ * device/include/mcs51/c8051f120.h: added PS0, fixed bug 1589279
+ * src/z80/gen.c (gencjneshort),
+ * src/z80/peeph.def: applied patch 1571373, thanks Philipp Krause
+
2006-10-31 Borut Razem <borut.razem AT siol.net>
* debugger/mcs51/acinclude.m4, debugger/mcs51/aclocal.m4,
__sbit __at (0xA9) ET0 ; /* TIMER 0 INTERRUPT ENABLE */
__sbit __at (0xAA) EX1 ; /* EXTERNAL INTERRUPT 1 ENABLE */
__sbit __at (0xAB) ET1 ; /* TIMER 1 INTERRUPT ENABLE */
-__sbit __at (0xAC) ES ; /* SERIAL PORT 0 INTERRUPT ENABLE */
__sbit __at (0xAC) ES0 ; /* SERIAL PORT 0 INTERRUPT ENABLE */
+__sbit __at (0xAC) ES ; /* SERIAL PORT 0 INTERRUPT ENABLE */
__sbit __at (0xAD) ET2 ; /* TIMER 2 INTERRUPT ENABLE */
__sbit __at (0xAF) EA ; /* GLOBAL INTERRUPT ENABLE */
__sbit __at (0xB9) PT0 ; /* TIMER 0 PRIORITY */
__sbit __at (0xBA) PX1 ; /* EXTERNAL INTERRUPT 1 PRIORITY */
__sbit __at (0xBB) PT1 ; /* TIMER 1 PRIORITY */
+__sbit __at (0xBC) PS0 ; /* SERIAL PORT PRIORITY */
__sbit __at (0xBC) PS ; /* SERIAL PORT PRIORITY */
__sbit __at (0xBD) PT2 ; /* TIMER 2 PRIORITY */
__sfr __at 0xE8 P6 ; /* PORT 6 */
__sfr __at 0xF8 P7 ; /* PORT 7 */
+/*
+Do NOT use sfr16 for CAN0DAT !
+*/
/* BIT Registers */
__sbit __at 0xB9 PT0 ; /* TIMER 0 PRIORITY */
__sbit __at 0xBA PX1 ; /* EXTERNAL INTERRUPT 1 PRIORITY */
__sbit __at 0xBB PT1 ; /* TIMER 1 PRIORITY */
+__sbit __at 0xBC PS0 ; /* SERIAL PORT PRIORITY */
__sbit __at 0xBC PS ; /* SERIAL PORT PRIORITY */
__sbit __at 0xBD PT2 ; /* TIMER 2 PRIORITY */
__sbit __at 0xB9 PT0 ; /* TIMER 0 PRIORITY */
__sbit __at 0xBA PX1 ; /* EXTERNAL INTERRUPT 1 PRIORITY */
__sbit __at 0xBB PT1 ; /* TIMER 1 PRIORITY */
+__sbit __at 0xBC PS0 ; /* SERIAL PORT PRIORITY */
__sbit __at 0xBC PS ; /* SERIAL PORT PRIORITY */
__sbit __at 0xBD PT2 ; /* TIMER 2 PRIORITY */
__sbit __at (0xB9) PT0 ; /* TIMER 0 PRIORITY */
__sbit __at (0xBA) PX1 ; /* EXTERNAL INTERRUPT 1 PRIORITY */
__sbit __at (0xBB) PT1 ; /* TIMER 1 PRIORITY */
+__sbit __at (0xBC) PS0 ; /* SERIAL PORT PRIORITY */
__sbit __at (0xBC) PS ; /* SERIAL PORT PRIORITY */
__sbit __at (0xBD) PT2 ; /* TIMER 2 PRIORITY */
{
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 ("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 ("sub %s", aopGet (AOP (right), offset, FALSE));
emit2 ("jp NZ,!tlabel", lbl->key + 100);
}
offset++;
} by {
ERROR - peephole - caught (hl),(hl)
}
+
replace restart {
ld %1,%1
} by {
- ; Removed redundent load
+ ; peephole removed redundant load.
}
+
replace restart {
xor a,a
or a,%1
or a,%1
jp %2,%3
}
-replace restart {
- cp a,#0x00
- jp NZ,%1
-} by {
- or a,a
- jp NZ,%1
-}
+
replace restart {
jp NZ,%1
jp %2
%1:
jp %3
%2:
-}
+} if labelRefCountChange(%1 -1)
+
replace restart {
jp NZ,%1
jp %2
} by {
jp Z,%2
%1:
-}
+} if labelRefCountChange(%1 -1)
+
replace restart {
jp Z,%1
jp %2
} by {
jp NZ,%2
%1:
-}
+} if labelRefCountChange(%1 -1)
+
replace restart {
or a,%1
or a,a
} by {
or a,%1
}
+
replace restart {
or a,%1)
or a,a
} by {
or a,%1)
}
+
replace restart {
xor a,a
or a,%1
or a,%3
jp Z,%2
}
+
replace restart {
jp NZ,%1
inc %3)
inc %3)
%1:
jp %2
-}
+} if labelRefCountChange(%1 -1), labelRefCountChange(%2 1)
+
replace restart {
xor a,a
ld a,#0x00
} by {
xor a,a
}
+
replace {
ld e,#0x00
ld d,#0x00
} by {
ld de,#0x0000
}
+
replace {
ld l,#0x00
ld h,#0x00
} by {
ld hl,#0x0000
}
+
replace {
ld c,#0x00
ld b,#0x00
} by {
ld bc,#0x0000
}
+
replace restart {
ld %1,a
ld a,%1
} by {
ld %1,a
} if notVolatile %1
+
replace restart {
jp %1,%2
jr %3
jr %3
%2:
jp %4
-}
+} if labelRefCountChange(%2 -1), labelRefCountChange(%4 1)
+
replace {
ld l,e
ld h,d
push de
push bc
}
+
replace {
and a,#%1
or a,a
} by {
and a,#%1
}
+
replace {
ld b,l
ld a,b
pop bc
ld b,a
}
+
replace {
ld d,l
ld a,d
pop de
ld d,a
}
+
replace {
ld a,b
push af
push bc
inc sp
}
+
replace {
ld a,d
push af
push de
inc sp
}
+
replace {
ld a,%1
sub a,#%2
cp a,#%4
jp P,%5
}
+
replace {
ld e,l
ld d,h
ld e,l
ld d,h
}
+
replace {
ld %1,%2
ld %3,%4
ld %3,%4
}
+// From: Philipp Klaus Krause
+replace restart {
+ ld %1,a
+ ld a,%2
+ add a,%1
+ ld %1,a
+} by {
+ ; peephole removed loads by exploiting commutativity of addition.
+ add a,%2
+ ld %1,a
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+ ld %1,a
+ ld a,%2
+ add a,%1
+} by {
+ ld %1, a
+ ; peephole removed load by exploiting commutativity of addition.
+ add a, %2
+}
+
+// From: Philipp Klaus Krause
+replace {
+ or a,%1
+ jp NZ,%2
+ ld %3,#0x00
+} by {
+ or a,%1
+ jp NZ,%2
+ ld %3,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ and a,%1
+ jp NZ,%2
+ ld %3,#0x00
+} by {
+ and a,%1
+ jp NZ,%2
+ ld %3,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ sub a,%1
+ jp NZ,%2
+ ld %3,#0x00
+} by {
+ sub a,%1
+ jp NZ,%2
+ ld %3,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ dec a
+ jp NZ,%1
+ ld %2,#0x00
+} by {
+ dec a
+ jp NZ,%1
+ ld %2,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ or a,%1
+ jp NZ,%2
+ ld a,%3
+ or a,a
+} by {
+ or a,%1
+ jp NZ,%2
+ or a,%3
+ ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ and a,%1
+ jp NZ,%2
+ ld a,%3
+ or a,a
+} by {
+ and a,%1
+ jp NZ,%2
+ or a,%3
+ ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ sub a,%1
+ jp NZ,%2
+ ld a,%3
+ or a,a
+} by {
+ sub a,%1
+ jp NZ,%2
+ or a,%3
+ ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+ dec a
+ jp NZ,%1
+ ld a,%2
+ or a,a
+} by {
+ dec a
+ jp NZ,%1
+ or a,%2
+ ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+ or a,%1
+ jp NZ,%2
+ push %3
+ ld %4,#0x00
+} by {
+ or a,%1
+ jp NZ,%2
+ push %3
+ ld %4,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+ and a,%1
+ jp NZ,%2
+ push %3
+ ld %4,#0x00
+} by {
+ sub a,%1
+ jp NZ,%2
+ push %3
+ ld %4,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+ sub a,%1
+ jp NZ,%2
+ push %3
+ ld %4,#0x00
+} by {
+ sub a,%1
+ jp NZ,%2
+ push %3
+ ld %4,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+ dec a
+ jp NZ,%1
+ push %2
+ ld %3,#0x00
+} by {
+ dec a
+ jp NZ,%1
+ push %2
+ ld %3,a
+ ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart{
+ jp NZ,%1
+ or a,%2
+ jp Z,%3
+%1:
+ jp %4
+%3:
+} by {
+ jp NZ,%4
+ ; peephole redirected jump
+ or a,%2
+ jp NZ,%4
+ ; peephole redirected jump
+%3:
+} if labelRefCount(%1 1), labelRefCountChange(%1 -1), labelRefCountChange(%3 -1), labelRefCountChange(%4 1)
+
+// Should be one of the last ones. Opens the code to further peephole optimization.
+// From: Philipp Klaus Krause
+replace restart {
+%1:
+} by {
+ ; peephole removed unused label %1.
+} if labelRefCount(%1 0)
+
+// From: Philipp Klaus Krause
+replace {
+ jp Z,%5
+} by {
+ jr Z,%5
+} if labelInRange()
+
+replace {
+ jp NZ,%5
+} by {
+ jr NZ,%5
+} if labelInRange()
+
+replace {
+ jp C,%5
+} by {
+ jr C,%5
+} if labelInRange()
+
+replace {
+ jp NC,%5
+} by {
+ jr NC,%5
+} if labelInRange()