#endif
/* symbol table management */
-#define H_SIZE 256 /* hash size */
+#define H_SIZE 307 /* hash size, must be od */
#define H_KEY (0*H_SIZE) /* key symbol headers */
#define H_LOCAL (1*H_SIZE) /* module symbol headers */
#ifdef ASLD
#endif
/* forward function declarations */
+#ifdef ASLD
extern char *readident();
+#endif
extern char *remember();
extern item_t *fb_shift();
extern item_t *fb_alloc();
/* ========== Machine independent rules ========== */
#ifdef LISTING
-#define LISTLINE(n) listline(n)
+#define LISTLINE(n) if (listflag) listline(n); \
+ else if (listtemp) { listflag = listtemp; listeoln = 1; }
#else
#define LISTLINE(n) /* empty */
#endif LISTING
hllino++;
newsymb(
(char *)0,
- (short)(DOTTYP | S_LIN),
- (short)hllino,
+ (DOTTYP | S_LIN),
+ hllino,
(valu_t)DOTVAL
);
}
hllino = 0;
newsymb(
stringbuf,
- (short)(DOTTYP | S_FIL),
- (short)0,
+ (DOTTYP | S_FIL),
+ 0,
(valu_t)DOTVAL
);
}
* the user is familiar with. Moreover, it is not reproducable.
*/
if ((sflag & (SYM_EXT|SYM_LOC|SYM_LAB)) && PASS_SYMB)
- newsymb(s, S_MOD, (short)0, (valu_t)0);
+ newsymb(s, S_MOD, 0, (valu_t)0);
#endif
#ifdef LISTING
listtemp = 0;
newsymb(
ip->i_name,
ip->i_type & (S_EXT|S_TYP),
- (short)0,
+ 0,
load(ip)
);
#else not ASLD
newsymb(
ip->i_name,
ip->i_type,
- (short) 0,
+ 0,
cp->c_size
);
}
newsymb(
ip->i_name,
S_EXT|S_UND,
- (short)0,
+ 0,
(valu_t)0
);
}
ip = sp->s_item;
newsymb(
ip->i_name,
- (short)(ip->i_type | S_SCT),
- (short)0,
+ (ip->i_type | S_SCT),
+ 0,
load(ip)
);
}
return(c>>8);
}
+static char name[NAMEMAX+1];
+
inident(c)
-char c;
+register c;
{
- register char *p;
+ register char *p = name;
register item_t *ip;
+ register n = NAMEMAX;
- p = readident(c);
- ip = item_search(p);
+ do {
+ if (--n >= 0)
+ *p++ = c;
+ c = nextchar();
+ } while (ISALNUM(c));
+ *p = '\0';
+ peekc = c;
+ ip = item_search(name);
if (ip == 0) {
ip = item_alloc(S_UND);
- ip->i_name = remember(p);
+ ip->i_name = remember(name);
/* printf("ident %s %o\n", ip->i_name, ip); */
unresolved++;
item_insert(ip, H_LOCAL + (hashindex%H_SIZE));
return(IDENT);
}
+#ifdef ASLD
char *
readident(c)
register c;
{
- static char name[NAMEMAX+1];
register n = NAMEMAX;
register char *p = name;
peekc = c;
return(name);
}
+#endif
innumber(c)
register c;
item_t *
item_search(p)
-register char *p;
+char *p;
{
register h;
register item_t *ip;
newequate(ip, typ)
register item_t *ip;
-register short typ;
+register int typ;
{
typ &= ~S_EXT;
if (typ & S_COM)
newsymb(
ip->i_name,
ip->i_type & (S_EXT|S_TYP),
- (short)0,
+ 0,
load(ip)
);
}
newsect(ip)
register item_t *ip;
{
- register short typ;
+ register int typ;
register sect_t *sp = NULL;
typ = ip->i_type & S_TYP;
}
switchsect(newtyp)
-short newtyp;
+int newtyp;
{
register sect_t *sp;
#ifdef RELOCATION
newrelo(s, n)
-short s;
{
int iscomm;
struct outrelo outrelo;
newsymb(name, type, desc, valu)
register char *name;
-short type;
-short desc;
valu_t valu;
{
struct outname outname;
register item_t *ip;
{
#ifdef ASLD
- register short typ;
+ register typ;
typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */
valu_t val;
{
#ifdef ASLD
- register short typ;
+ register typ;
typ = ip->i_type & S_TYP;
if ((typ -= S_MIN) >= 0)
emit1(arg)
{
+ static int olddottyp = -1;
#ifdef LISTING
if (listeoln) {
if (listflag & 1) {
DOTSCT->s_zero = 0;
break;
case PASS_3:
- wr_outsect(DOTTYP-S_MIN);
+ if (DOTTYP != olddottyp) {
+ wr_outsect(DOTTYP-S_MIN);
+ olddottyp = DOTTYP;
+ }
while (DOTSCT->s_zero) {
wr_putc(0);
DOTSCT->s_zero--;
case 1:
emit1((int)val); break;
case 2:
- emit2((int)val); break;
+#ifdef BYTES_REVERSED
+ emit1(((int)val>>8)); emit1((int)val);
+#else
+ emit1((int)val); emit1(((int)val>>8));
+#endif
+ break;
case 4:
- emit4((long)val); break;
+#ifdef WORDS_REVERSED
+ emit2((int)(val>>16)); emit2((int)(val));
+#else
+ emit2((int)(val)); emit2((int)(val>>16));
+#endif
+ break;
default:
assert(0);
}