1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1985-01-08 09:59:28 +00:00
|
|
|
#ifndef NORCSID
|
2019-05-10 17:17:24 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-08 09:59:28 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-18 17:18:42 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1985-01-08 09:59:28 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "expr.h"
|
2013-05-10 11:04:21 +00:00
|
|
|
#include "extern.h"
|
1985-01-08 09:59:28 +00:00
|
|
|
#include <em_spec.h>
|
|
|
|
#include <em_flag.h>
|
|
|
|
|
|
|
|
extern char em_mnem[][4];
|
|
|
|
|
|
|
|
#define HASHSIZE (2*(sp_lmnem-sp_fmnem))
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
struct emhashmnem
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
char h_name[3];
|
|
|
|
char h_value;
|
|
|
|
} emhashmnem[HASHSIZE];
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
static void enter(char *, int);
|
|
|
|
static unsigned emhash(register char *);
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
|
|
|
|
void initemhash(void)
|
|
|
|
{
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
for (i = 0; i <= sp_lmnem - sp_fmnem; i++)
|
|
|
|
enter(em_mnem[i], i + sp_fmnem);
|
1990-07-18 14:53:19 +00:00
|
|
|
enter("lab", op_lab);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
static unsigned emhash(register char *name)
|
|
|
|
{
|
|
|
|
register unsigned int sum;
|
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (sum = i = 0; *name; i += 3)
|
|
|
|
sum ^= (*name++) << (i & 07);
|
|
|
|
return (sum);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
static void enter(char *name, int value)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
register unsigned h;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
h = emhash(name) % HASHSIZE;
|
1985-01-08 09:59:28 +00:00
|
|
|
while (emhashmnem[h].h_name[0] != 0)
|
2019-05-10 17:17:24 +00:00
|
|
|
h = (h + 1) % HASHSIZE;
|
|
|
|
strncpy(emhashmnem[h].h_name, name, 3);
|
1985-01-08 09:59:28 +00:00
|
|
|
emhashmnem[h].h_value = value;
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
int mlookup(char *name)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
register unsigned h;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
h = emhash(name) % HASHSIZE;
|
|
|
|
while (strncmp(emhashmnem[h].h_name, name, 3) != 0
|
|
|
|
&& emhashmnem[h].h_name[0] != 0)
|
|
|
|
h = (h + 1) % HASHSIZE;
|
|
|
|
return (emhashmnem[h].h_value & 0xFF); /* 0 if not found */
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern char em_flag[];
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
int argtyp(int mn)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (em_flag[mn - sp_fmnem] & EM_PAR)
|
|
|
|
{
|
|
|
|
case PAR_W:
|
|
|
|
case PAR_S:
|
|
|
|
case PAR_Z:
|
|
|
|
case PAR_O:
|
|
|
|
case PAR_N:
|
|
|
|
case PAR_L:
|
|
|
|
case PAR_F:
|
|
|
|
case PAR_R:
|
|
|
|
case PAR_C:
|
|
|
|
return (TYPINT);
|
|
|
|
default:
|
|
|
|
return (TYPADDR);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
}
|