return NULL;
}
+/* Check if reading arg implies reading what. */
+static bool argCont(const char *arg, const char *what)
+{
+ if(arg[0] == '#')
+ return FALSE;
+ return(strstr(arg, what));;
+}
+
static bool
z80MightRead(const lineNode *pl, const char *what)
{
- if(strcmp(pl->line, "call\t__initrleblock") == 0)
- return TRUE;
-
if(strcmp(what, "iyl") == 0 || strcmp(what, "iyh") == 0)
what = "iy";
+ if(strcmp(pl->line, "call\t__initrleblock") == 0)
+ return TRUE;
+
if(strncmp(pl->line, "call\t", 5) == 0 && strchr(pl->line, ',') == 0)
return FALSE;
if(strncmp(pl->line, "adc\t", 4) == 0 ||
strncmp(pl->line, "add\t", 4) == 0 ||
strncmp(pl->line, "and\t", 4) == 0 ||
- strncmp(pl->line, "or\t", 3) == 0 ||
strncmp(pl->line, "sbc\t", 4) == 0 ||
strncmp(pl->line, "sub\t", 4) == 0 ||
strncmp(pl->line, "xor\t", 4) == 0)
{
- if( strstr(pl->line + 3, what) != 0)
+ if(argCont(pl->line + 4, what))
return TRUE;
- if( strstr(pl->line + 3, "hl") == 0 && strcmp("a", what) == 0)
+ if(strstr(pl->line + 4, "hl") == 0 && strcmp("a", what) == 0)
+ return TRUE;
+ return FALSE;
+ }
+
+ if(strncmp(pl->line, "or\t", 3) == 0)
+ {
+ if(argCont(pl->line + 3, what))
+ return TRUE;
+ if(strcmp("a", what) == 0)
return TRUE;
return FALSE;
}
if(
strncmp(pl->line, "dec\t", 4) == 0 ||
strncmp(pl->line, "inc\t", 4) == 0 ||
- strncmp(pl->line, "rl\t", 3) == 0 ||
- strncmp(pl->line, "rr\t", 3) == 0 ||
+ strncmp(pl->line, "rl\t", 4) == 0 ||
+ strncmp(pl->line, "rr\t", 4) == 0 ||
strncmp(pl->line, "sla\t", 4) == 0 ||
strncmp(pl->line, "sra\t", 4) == 0 ||
strncmp(pl->line, "srl\t", 4) == 0)
{
- return (strstr(pl->line + 3, what) != 0);
+ return (argCont(pl->line + 4, what));
+ }
+
+ if(
+ strncmp(pl->line, "rl\t", 3) == 0 ||
+ strncmp(pl->line, "rr\t", 3) == 0)
+ {
+ return (argCont(pl->line + 3, what));
}
if(strncmp(pl->line, "jp\t", 3) == 0 ||
ld c,(hl)
} if notUsed('a'), notUsed('hl')
+replace restart {
+ ld de,#%2 + %3
+ ld a,(de)
+ ld e,a
+} by {
+ ; peephole 0j' used hl for #%2 + %3 instead of de, not going through a.
+ ld hl,#%2 + %3
+ ld e,(hl)
+} if notUsed('a'), notUsed('hl')
+
replace restart {
ex de,hl
push hl
ld %4,a
} if notVolatile(%1), operandsNotRelated(%1 %3), operandsNotRelated(%1 %2)
+replace restart {
+ ld %1,a
+ ld a,%2
+ adc a,#%3
+ ld %4,%1
+} by {
+ ld %1,a
+ ; peephole 0t' loaded %4 from a instead of going through %1.
+ ld %4,a
+ ld a,%2
+ adc a,#%3
+} if notVolatile(%1), operandsNotRelated(%1 %2), operandsNotRelated(%4 %2)
+
+replace restart {
+ ld %1,a
+ ld a,#%2
+ adc a,#%3
+ ld %4,%1
+} by {
+ ld %1,a
+ ; peephole 0t'' loaded %4 from a instead of going through %1.
+ ld %4,a
+ ld a,#%2
+ adc a,#%3
+} if notVolatile(%1)
+
replace restart {
ld %1,(hl)
ld e,%1
} by {
ld %1,a
or a,%2
- ; peephole 17 removed load by reordering or arguments.
+ ; peephole 17a removed load by reordering or arguments.
+} if notVolatile(%1)
+
+replace restart {
+ ld %1,a
+ ld a,%2 (ix)
+ or a,%1
+} by {
+ ld %1,a
+ or a,%2 (ix)
+ ; peephole 17b removed load by reordering or arguments.
} if notVolatile(%1)
replace restart {