Added grind support

This commit is contained in:
ceriel
1991-11-01 11:53:42 +00:00
parent e4168af8fb
commit 3da953fa85
22 changed files with 179 additions and 39 deletions

View File

@@ -33,3 +33,4 @@ symtable.c
text2.c
text4.c
common.c
dbsym.c

View File

@@ -77,9 +77,9 @@ char *s;
char *extnd_dlb( g)
arith g;
label g;
{
string_lengte = mysprint( DLB_FMT, (arith)g);
string_lengte = mysprint( DLB_FMT, (long)g);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}
@@ -88,7 +88,7 @@ arith g;
char *extnd_ilb( l, prcno)
arith l;
{
string_lengte = mysprint( ILB_FMT, prcno, (arith) l);
string_lengte = mysprint( ILB_FMT, prcno, (long) l);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}

View File

@@ -3,5 +3,6 @@
#define SYMBOL_DEFINITION 1
#define REFERENCE 2
#define STORE_STRING 3
#define FORCE_DEF 4
#define conv_seg( s) ( ( s == SEGROM) ? SEGCON : s)

View File

@@ -17,7 +17,7 @@ output_back()
{
struct outhead header;
struct outsect sect;
long ntext = text - text_area,
long ntext = text - text_area,
ndata = data - data_area,
nchar;
@@ -94,12 +94,13 @@ reduce_name_table()
* After that, the string table is reduced.
*/
#define S_NEEDED 0x8000
#define removable(nm) (!(nm.on_type & S_NEEDED) && *(nm.on_foff+string_area) == GENLAB)
#define S_NEEDED S_MOD
#define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB)
register int *diff_index =
(int *) Malloc((unsigned)(nname + 1) * sizeof(int));
register struct outrelo *rp = reloc_info;
register struct outname *np;
register int i;
char *new_str;
register char *p, *q;
@@ -113,22 +114,31 @@ reduce_name_table()
rp++;
}
for (i = 0; i < nname; i++) {
for (i = 0, np = symbol_table; i < nname; i++, np++) {
diff_index[i] = diff_index[i-1];
if (removable(symbol_table[i])) {
if (removable(np)) {
diff_index[i]++;
}
if ((np->on_type & S_TYP) == S_CRS) {
struct outname *n = &symbol_table[(int) np->on_valu];
if (! (n->on_type & S_COM)) {
np->on_type &= ~S_TYP;
np->on_type |= (n->on_type & S_TYP);
np->on_valu = n->on_valu;
}
}
}
rp = reloc_info;
for (i = 0; i < nrelo; i++) {
symbol_table[rp->or_nami].on_type &= ~S_NEEDED;
rp->or_nami -= diff_index[rp->or_nami];
rp++;
}
for (i = 0; i < nname; i++) {
register struct outname *np = &symbol_table[i];
np->on_type &= ~S_NEEDED;
for (i = 0, np = symbol_table; i < nname; i++, np++) {
if ((np->on_type & S_TYP) == S_CRS) {
np->on_valu -= diff_index[(int) np->on_valu];
}
if (diff_index[i] && diff_index[i] == diff_index[i-1]) {
symbol_table[i - diff_index[i]] = *np;
}
@@ -138,14 +148,20 @@ reduce_name_table()
free((char *)(diff_index-1));
new_str = q = Malloc((unsigned)(string - string_area));
for (i = 0; i < nname; i++) {
p = symbol_table[i].on_foff + string_area;
symbol_table[i].on_foff = q - new_str;
for (i = 0, np = symbol_table; i < nname; i++, np++) {
p = np->on_foff + string_area;
np->on_foff = q - new_str;
while (*q++ = *p) p++;
}
free(string_area);
string_area = new_str;
string = q;
for (i = 0, np = symbol_table; i < nname; i++, np++) {
if ((np->on_type & S_TYP) == S_CRS) {
/* replace by reference to string */
np->on_valu = symbol_table[(int) np->on_valu].on_foff;
}
}
}
wr_fatal()
@@ -159,11 +175,14 @@ static
convert_outname( header)
struct outhead *header;
{
int i;
int i;
register struct outname *np;
register long l = OFF_CHAR(*header);
for ( i=0; i < nname; i++) {
symbol_table[ i].on_foff += OFF_CHAR( *header);
}
for (i = 0, np = symbol_table; i < nname; i++, np++) {
np->on_foff += l;
if ((np->on_type & S_TYP) == S_CRS) {
np->on_valu += l;
}
}
}

View File

@@ -17,7 +17,8 @@ all: data.$(SUF) con2.$(SUF) con4.$(SUF) relocation.$(SUF) end_back.$(SUF) \
reloc1.$(SUF) reloc2.$(SUF) reloc4.$(SUF) rom2.$(SUF) rom4.$(SUF) \
set_global.$(SUF) set_local.$(SUF) switchseg.$(SUF) symboldef.$(SUF) \
text2.$(SUF) text4.$(SUF) do_open.$(SUF) do_close.$(SUF) memory.$(SUF) \
label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF)
label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF) \
dbsym.$(SUF)
data.$(SUF) : data.h back.h header.h $(SOURCE)/data.c
$(CC) $(CFLAGS) -c $(SOURCE)/data.c
@@ -106,3 +107,5 @@ label.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/label.c
common.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/common.c
$(CC) $(CFLAGS) -c $(SOURCE)/common.c
dbsym.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/dbsym.c
$(CC) $(CFLAGS) -c $(SOURCE)/dbsym.c

View File

@@ -45,7 +45,8 @@ int isdef;
register struct Hashitem *ip;
register int h;
if ( index_symbol_table != -1 ) {
if (isdef != FORCE_DEF) {
if ( index_symbol_table != -1 ) {
s = symbol_table + index_symbol_table;
if ( sym == s->on_foff + string_area) {
if ( (s->on_valu == -2) && ( isdef == REFERENCE)) {
@@ -54,10 +55,10 @@ int isdef;
}
return( index_symbol_table);
}
}
}
h = Hash(sym);
for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems;
h = Hash(sym);
for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems;
ip = (ip->hs_next) + Hashitems) {
register char *p = sym, *q;
@@ -70,26 +71,30 @@ int isdef;
}
return ip->hs_nami;
}
}
}
if ( nname >= size_symbol)
mem_symbol_hash();
s = symbol_table + nname;
ip = Hashitems + nname + 1; /* skip the first entry */
if (isdef == REFERENCE) {
if (isdef != FORCE_DEF) {
ip = Hashitems + nname + 1; /* skip the first entry */
if (isdef == REFERENCE) {
s->on_type = S_EXT;
s->on_valu = -1;
}
if (isdef == STORE_STRING) {
}
if (isdef == STORE_STRING) {
s->on_type = S_UND;
s->on_valu = -2;
}
}
ip->hs_nami = nname;
ip->hs_next = Hashtab[h];
Hashtab[h] = ip - Hashitems;
ip->hs_nami = nname;
ip->hs_next = Hashtab[h];
Hashtab[h] = ip - Hashitems;
}
if ( sym == string)
string += string_lengte;