Fix bad code generation due to not correctly flushing the stack before

comparisons.
This commit is contained in:
David Given 2019-02-12 22:19:07 +01:00
parent a2b5202081
commit f4b45f1ed7
2 changed files with 47 additions and 27 deletions

View file

@ -2048,14 +2048,15 @@ gen xra a
#ifdef USE_I80_RSTS #ifdef USE_I80_RSTS
pat lol zeq sfit($1, 8) pat lol zeq sfit($1, 8)
uses hlreg, areg with STACK
gen uses hlreg, areg
rst {const1, 3} gen
data1 {const1, $1} rst {const1, 3}
mov a, {m} data1 {const1, $1}
inx hl mov a, {m}
ora {m} inx hl
jz {label, $2} ora {m}
jz {label, $2}
#endif #endif
pat lol zeq pat lol zeq
@ -2070,25 +2071,26 @@ pat lol zeq
#ifdef USE_I80_RSTS #ifdef USE_I80_RSTS
pat lol zne sfit($1, 8) pat lol zne sfit($1, 8)
uses hlreg, areg with STACK
gen uses hlreg, areg
rst {const1, 3} gen
data1 {const1, $1} rst {const1, 3}
mov a, {m} data1 {const1, $1}
inx hl mov a, {m}
ora {m} inx hl
jnz {label, $2} ora {m}
jnz {label, $2}
#endif #endif
pat lol zne pat lol zne
with STACK with STACK
uses hlreg={const2,$1}, areg uses hlreg={const2,$1}, areg
gen gen
dad lb dad lb
mov a,{m} mov a,{m}
inx hl inx hl
ora {m} ora {m}
jnz {label,$2} jnz {label,$2}
pat ior zeq $1==2 pat ior zeq $1==2
with hl_or_de hl_or_de STACK with hl_or_de hl_or_de STACK

View file

@ -56,7 +56,7 @@ void demo2(int lval, va_list ap)
ASSERT(strcmp(ptmp, "35") == 0); ASSERT(strcmp(ptmp, "35") == 0);
} }
void doit1(char *x, ...) void doit1a(char *x, ...)
{ {
va_list ptr; va_list ptr;
va_start(ptr, x); va_start(ptr, x);
@ -64,7 +64,15 @@ void doit1(char *x, ...)
va_end(ptr); va_end(ptr);
} }
void doit2(char *x, ...) void doit1b(char *x, ...)
{
va_list ptr;
va_start(ptr, x);
demo(1,ptr);
va_end(ptr);
}
void doit2a(char *x, ...)
{ {
va_list ptr; va_list ptr;
va_start(ptr, x); va_start(ptr, x);
@ -72,10 +80,20 @@ void doit2(char *x, ...)
va_end(ptr); va_end(ptr);
} }
void doit2b(char *x, ...)
{
va_list ptr;
va_start(ptr, x);
demo2(1,ptr);
va_end(ptr);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
doit1("", 35); doit1a("", 35);
doit2("", 35); doit1b("", 35L);
doit2a("", 35);
doit2b("", 35L);
finished(); finished();
return 0; return 0;
} }