2 static char rcsid[] = "$Id: nextem.c,v 0.9 1994/06/24 13:27:43 ceriel Exp $";
17 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
18 * See the copyright notice in the ACK home directory, in the file "Copyright".
20 * Author: Hans van Staveren
25 extern char em_mnem[][4];
28 byte *trypat(bp,len) register byte *bp; {
41 if (emp[i].em_instr != (*bp++&BMASK))
43 for (i=0;i<patlen;i++)
44 if (emp[i].em_optyp==OPNO)
45 dollar[i].e_typ=EV_UNDEF;
46 else if ((dollar[i].e_typ=argtyp(emp[i].em_instr))==EV_INT)
47 dollar[i].e_v.e_con=emp[i].em_u.em_ioper;
49 dollar[i].e_v.e_addr.ea_str=emp[i].em_soper;
50 dollar[i].e_v.e_addr.ea_off=0;
54 struct emline *svp = saveemp;
57 compute(&enodes[i], &result);
58 if (result.e_typ != EV_INT || result.e_v.e_con == 0) {
65 fprintf(stderr,"Matched:");
66 for (i=0;i<patlen;i++) {
68 if (emp[i].em_instr == op_lab)
69 fprintf(stderr," lab");
72 fprintf(stderr," %3.3s",em_mnem[emp[i].em_instr-sp_fmnem]);
74 fprintf(stderr," %s",emp[i].em_soper);
84 extern char em_flag[];
88 switch(em_flag[mn-sp_fmnem]&EM_PAR) {
104 byte *nextem(toplevel) {
110 register struct emline *ep;
113 if (nemlines && emp>emlines) {
114 nemlines -= emp-emlines;
115 for (i=0,ep=emlines;i<nemlines;i++)
121 hash[0] = emp[0].em_instr;
122 hash[1] = (hash[0]<<4) ^ emp[1].em_instr;
123 hash[2] = (hash[1]<<4) ^ emp[2].em_instr;
125 index = pathash[hash[i]&BMASK];
127 bp = &pattern[index];
128 if ( bp[PO_HASH] == (hash[i]>>8))
129 if ((cp=trypat(&bp[PO_MATCH],i+1)) != 0)
131 index = (bp[PO_NEXT]&BMASK) | (bp[PO_NEXT+1]<<8);