fixed bug in EM replacement code, and use new #defines from tables.h

This commit is contained in:
ceriel 1989-11-08 17:13:33 +00:00
parent 67f9f2a74f
commit 339f9dd942

View file

@ -23,9 +23,6 @@ static char rcsid[] = "$Header$";
#define ALLOW_NEXTEM /* code generator is allowed new try of NEXTEM #define ALLOW_NEXTEM /* code generator is allowed new try of NEXTEM
in exceptional cases */ in exceptional cases */
#define MAXPATTERN 5
#define MAXREPLLEN 5 /* Max length of EM-replacement, should come from boot */
byte startupcode[] = { DO_NEXTEM }; byte startupcode[] = { DO_NEXTEM };
byte *nextem(); byte *nextem();
@ -251,7 +248,7 @@ if (Debug)
unsigned mincost,t; unsigned mincost,t;
token_p tp; token_p tp;
int size,lsize; int size,lsize;
int tokexp[MAXPATTERN]; int tokexp[MAXPATLEN];
int nregneeded; int nregneeded;
token_p regtp[MAXCREG]; token_p regtp[MAXCREG];
c3_p regcp[MAXCREG]; c3_p regcp[MAXCREG];
@ -779,7 +776,7 @@ normalfailed: if (stackpad!=tokpatlen) {
register i; register i;
int j; int j;
int nodeno; int nodeno;
result_t result; result_t result[MAXEMREPLLEN];
int emrepllen,eminstr; int emrepllen,eminstr;
DEBUG("EMREPLACE"); DEBUG("EMREPLACE");
@ -797,8 +794,10 @@ normalfailed: if (stackpad!=tokpatlen) {
getint(eminstr,codep); getint(eminstr,codep);
getint(nodeno,codep); getint(nodeno,codep);
emp[i].em_instr = eminstr; emp[i].em_instr = eminstr;
result = compute(&enodes[nodeno]); result[i] = compute(&enodes[nodeno]);
switch(result.e_typ) { }
for (i=0;i<emrepllen;i++) {
switch(result[i].e_typ) {
default: default:
assert(FALSE); assert(FALSE);
case 0: case 0:
@ -807,12 +806,12 @@ normalfailed: if (stackpad!=tokpatlen) {
break; break;
case EV_INT: case EV_INT:
emp[i].em_optyp = OPINT; emp[i].em_optyp = OPINT;
emp[i].em_soper = tostring(result.e_v.e_con); emp[i].em_soper = tostring(result[i].e_v.e_con);
emp[i].em_u.em_ioper = result.e_v.e_con; emp[i].em_u.em_ioper = result[i].e_v.e_con;
break; break;
case EV_ADDR: case EV_ADDR:
emp[i].em_optyp = OPSYMBOL; emp[i].em_optyp = OPSYMBOL;
emp[i].em_soper = ad2str(result.e_v.e_addr); emp[i].em_soper = ad2str(result[i].e_v.e_addr);
break; break;
} }
} }