many modyfications in search for more speed

This commit is contained in:
ceriel 1988-10-31 15:42:15 +00:00
parent 63f793aff3
commit 7851ff900f
19 changed files with 208 additions and 134 deletions

View file

@ -26,6 +26,8 @@ extern holno, procno;
#define swtxt() switchseg( SEGTXT) #define swtxt() switchseg( SEGTXT)
#define switchseg(seg) if ((seg) != cur_seg) swtchsg(seg); else
#define PC_REL 1 #define PC_REL 1
#define ABSOLUTE !PC_REL #define ABSOLUTE !PC_REL
@ -34,8 +36,7 @@ extern holno, procno;
#define MAXTEXT 4096 #define MAXTEXT 4096
#define MAXDATA 2048 #define MAXDATA 2048
#define MAXRELO 100 #define MAXRELO 512
#define MAXNAME 100 #define MAXNAME 512
#define MAXSTRING 2048 #define MAXSTRING 4096
#define MAXHASH 256

View file

@ -9,9 +9,9 @@ arith n;
register struct outname *nm = &symbol_table[Label]; register struct outname *nm = &symbol_table[Label];
if (label_waiting && (nm->on_type & S_EXT)) { if (label_waiting && (nm->on_type & S_EXT)) {
symbol_table[Label].on_type |= S_COM | (S_MIN+SEGBSS); nm->on_type |= S_COM | (S_MIN+SEGBSS);
if (n > symbol_table[Label].on_valu) { if (n > nm->on_valu) {
symbol_table[Label].on_valu = n; nm->on_valu = n;
} }
label_waiting = 0; label_waiting = 0;
return; return;

View file

@ -6,11 +6,11 @@ TWO_BYTES w;
{ {
if ((_data_cnt -= 2) < 0) mem_data(); if ((_data_cnt -= 2) < 0) mem_data();
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
*data++ = ( unsigned short)w>>8; *data++ = w>>8;
*data++ = w; *data++ = w;
#else #else
*data++ = w; *data++ = w;
*data++ = ( unsigned short)w>>8; *data++ = w>>8;
#endif #endif
} }

View file

@ -1,14 +1,22 @@
#include "mach.h" #include "mach.h"
#include "back.h"
#ifdef BYTES_REVERSED
#define con2(w) { *data++ = ((w) >> 8); *data++ = (w);}
#else
#define con2(w) { *data++ = (w); *data++ = ((w)>>8);}
#endif
con4( l) con4( l)
FOUR_BYTES l; FOUR_BYTES l;
{ {
if ((_data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
con2( (short) ((unsigned long)l>>16)); con2( (int)(l>>16));
con2( (short) l); con2( (int) l);
#else #else
con2( (short) l); con2( (int) l);
con2( (short) ((unsigned long)l>>16)); con2( (int) (l>>16));
#endif #endif
} }

View file

@ -1,5 +1,6 @@
#include <system.h> #include <system.h>
#include <out.h> #include <out.h>
#include "data.h"
#include "mach.h" #include "mach.h"
/* Global datastructures : /* Global datastructures :
@ -36,26 +37,17 @@ long nbss = 0, size_text, size_data, size_reloc, size_symbol,
size_string, _text_cnt, _data_cnt; size_string, _text_cnt, _data_cnt;
put1(sect,addr,b)
char *sect;
long addr;
char b;
{
sect[addr] = b;
}
put2(sect,addr,w) put2(sect,addr,w)
char *sect; char *sect;
long addr; long addr;
int w; int w;
{ {
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
put1(sect,addr,(char) (w>>8)); put1(sect, addr, (w>>8));
put1(sect,addr+1,(char) w); put1(sect, addr+1, w);
#else #else
put1(sect,addr,(char) w); put1(sect, addr, w);
put1(sect,addr+1,(char) (w>>8)); put1(sect, addr+1, (w>>8));
#endif #endif
} }
@ -66,37 +58,23 @@ long addr;
long l; long l;
{ {
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
put2(sect,addr,(short) (l>>16)); put2(sect,addr,(int) (l>>16));
put2(sect,addr+2,(short) l); put2(sect,addr+2,(int) l);
#else #else
put2(sect,addr,(short) l); put2(sect,addr,(int) l);
put2(sect,addr+2,(short) (l>>16)); put2(sect,addr+2,(int) (l>>16));
#endif #endif
} }
int get2(sect,addr)
char get1( sect, addr)
char *sect; char *sect;
long addr; long addr;
{ {
return( sect[addr]);
}
short get2(sect,addr)
char *sect;
long addr;
{
short h,l;
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
h = sect[addr]; return (get1(sect,addr) << 8) | (get1(sect,addr+1) & 255);
l = sect[addr+1];
#else #else
l = sect[addr]; return (get1(sect,addr+1) << 8) | (get1(sect,addr) & 255);
h = sect[addr+1];
#endif #endif
return( ( h << 8) | ( l & 255));
} }
@ -104,14 +82,9 @@ long get4(sect,addr)
char *sect; char *sect;
long addr; long addr;
{ {
long l,h;
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
h = get2(sect,addr); return ((long)get2(sect,addr) << 16) | get2(sect, addr+2);
l = get2(sect,addr+2);
#else #else
l = get2(sect,addr); return ((long)get2(sect,addr+2) << 16) | get2(sect, addr);
h = get2(sect,addr+2);
#endif #endif
return( ( h << 16) | ( l & 65535L));
} }

View file

@ -1,6 +1,7 @@
/* The global datastructures (see "data.c"). */ /* The global datastructures (see "data.c"). */
extern long cur_value(); extern long cur_value();
extern long get4();
extern int cur_seg; extern int cur_seg;
@ -13,3 +14,5 @@ extern char *text_area, *data_area, *string_area;
extern struct outrelo *reloc_info, *relo; extern struct outrelo *reloc_info, *relo;
extern struct outname *symbol_table; extern struct outname *symbol_table;
#define put1(buf, off, w) ((buf)[off] = (w))
#define get1(buf, off) ((buf)[off])

View file

@ -2,15 +2,30 @@
#include "mach.h" #include "mach.h"
#include "back.h" #include "back.h"
gen2( c) gen2( w)
TWO_BYTES c; TWO_BYTES w;
{ {
switch ( cur_seg) { switch ( cur_seg) {
case SEGTXT : text2( c); case SEGTXT :
if ((_text_cnt -= 2) < 0) mem_text();
#ifdef BYTES_REVERSED
*text++ = w>>8;
*text++ = w;
#else
*text++ = w;
*text++ = w>>8;
#endif
return; return;
case SEGCON : con2( c); case SEGCON :
return; case SEGROM :
case SEGROM : rom2( c); if ((_data_cnt -= 2) < 0) mem_data();
#ifdef BYTES_REVERSED
*data++ = w>>8;
*data++ = w;
#else
*data++ = w;
*data++ = w>>8;
#endif
return; return;
case SEGBSS : bss( 2); case SEGBSS : bss( 2);
return; return;

View file

@ -1,16 +1,38 @@
#include <system.h> #include <system.h>
#include "mach.h" #include "mach.h"
#include "back.h" #include "back.h"
#ifdef BYTES_REVERSED
#define text2(w) { *text++ = ((w) >> 8); *text++ = (w);}
#define con2(w) { *data++ = ((w) >> 8); *data++ = (w);}
#else
#define text2(w) { *text++ = (w); *text++ = ((w)>>8);}
#define con2(w) { *data++ = (w); *data++ = ((w)>>8);}
#endif
gen4( c) gen4( l)
FOUR_BYTES c; FOUR_BYTES l;
{ {
switch ( cur_seg) { switch ( cur_seg) {
case SEGTXT : text4( c); case SEGTXT :
if ((_text_cnt -= 4) < 0) mem_text();
#ifdef WORDS_REVERSED
text2( (int) (l>>16));
text2( (int) l);
#else
text2( (int) l);
text2( (int) (l>>16));
#endif
return; return;
case SEGCON : con4( c); case SEGCON :
return; case SEGROM :
case SEGROM : rom4( c); if ((_data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED
con2( (int)(l>>16));
con2( (int) l);
#else
con2( (int) l);
con2( (int) (l>>16));
#endif
return; return;
case SEGBSS : bss( 4); case SEGBSS : bss( 4);
return; return;

View file

@ -3,9 +3,12 @@
#include <varargs.h> #include <varargs.h>
/* Mysprint() stores the string directly in the string_arae. This saves /* Mysprint() stores the string directly in the string_arae. This saves
* a copy action. * a copy action. It is assumed that the strings stored in the string-table
* are never longer than MAXSTRLEN bytes.
*/ */
#define MAXSTRLEN 1024
/*VARARGS*/ /*VARARGS*/
int mysprint(va_alist) int mysprint(va_alist)
va_dcl va_dcl
@ -16,7 +19,7 @@ int mysprint(va_alist)
va_start(args); va_start(args);
fmt = va_arg(args, char *); fmt = va_arg(args, char *);
while (string + 1024 - string_area > size_string) while (string + MAXSTRLEN - string_area > size_string)
mem_string(); mem_string();
retval = _format(string, fmt, args); retval = _format(string, fmt, args);
string[retval] = '\0'; string[retval] = '\0';

View file

@ -8,26 +8,36 @@
* absolute. * absolute.
*/ */
#ifdef WORDS_REVERSED
#ifdef BYTES_REVERSED
#define RRR (RELO1|RELBR|RELWR)
#else
#define RRR (RELO1|RELWR)
#endif
#else
#ifdef BYTES_REVERSED
#define RRR (RELO1|RELBR)
#else
#define RRR (RELO1)
#endif
#endif
reloc1( sym, off, pcrel) reloc1( sym, off, pcrel)
char *sym; char *sym;
arith off; arith off;
int pcrel; int pcrel;
{ {
register struct outrelo *r;
if ( relo - reloc_info >= size_reloc) if ( relo - reloc_info >= size_reloc)
mem_relo(); mem_relo();
relo->or_type = RELO1; r = relo;
#ifdef BYTES_REVERSED r->or_type |= ( pcrel) ? RELPC|RRR : RRR;
relo->or_type |= RELBR; r->or_sect = S_MIN + conv_seg( cur_seg);
#endif r->or_nami = find_sym(sym, REFERENCE);
#ifdef WORDS_REVERSED r->or_addr = cur_value();
relo->or_type |= RELWR; gen1( (pcrel) ? off - ( r->or_addr + 1) : off);
#endif
relo->or_type |= ( pcrel) ? RELPC : S_UND;
relo->or_sect = S_MIN + conv_seg( cur_seg);
relo->or_nami = find_sym(sym, REFERENCE);
relo->or_addr = cur_value();
gen1( (pcrel) ? off - ( cur_value() + 1) : off);
relo++; relo++;
} }

View file

@ -8,26 +8,36 @@
* absolute. * absolute.
*/ */
#ifdef WORDS_REVERSED
#ifdef BYTES_REVERSED
#define RRR (RELO2|RELBR|RELWR)
#else
#define RRR (RELO2|RELWR)
#endif
#else
#ifdef BYTES_REVERSED
#define RRR (RELO2|RELBR)
#else
#define RRR (RELO2)
#endif
#endif
reloc2( sym, off, pcrel) reloc2( sym, off, pcrel)
char *sym; char *sym;
arith off; arith off;
int pcrel; int pcrel;
{ {
register struct outrelo *r;
if ( relo - reloc_info >= size_reloc) if ( relo - reloc_info >= size_reloc)
mem_relo(); mem_relo();
relo->or_type = RELO2; r = relo;
#ifdef BYTES_REVERSED r->or_type = ( pcrel) ? RELPC|RRR : RRR;
relo->or_type |= RELBR; r->or_sect = S_MIN + conv_seg( cur_seg);
#endif r->or_nami = find_sym(sym, REFERENCE);
#ifdef WORDS_REVERSED r->or_addr = cur_value();
relo->or_type |= RELWR; gen2( (pcrel) ? off - ( r->or_addr + 2) : off);
#endif
relo->or_type |= ( pcrel) ? RELPC : S_UND;
relo->or_sect = S_MIN + conv_seg( cur_seg);
relo->or_nami = find_sym(sym, REFERENCE);
relo->or_addr = cur_value();
gen2( (pcrel) ? off - ( cur_value() + 2) : off);
relo++; relo++;
} }

View file

@ -9,29 +9,40 @@
* absolute. * absolute.
*/ */
#ifdef WORDS_REVERSED
#ifdef BYTES_REVERSED
#define RRR (RELO4|RELBR|RELWR)
#else
#define RRR (RELO4|RELWR)
#endif
#else
#ifdef BYTES_REVERSED
#define RRR (RELO4|RELBR)
#else
#define RRR (RELO4)
#endif
#endif
reloc4( sym, off, pcrel) reloc4( sym, off, pcrel)
char *sym; char *sym;
arith off; arith off;
int pcrel; int pcrel;
{ {
register struct outrelo *r;
if ( relo - reloc_info >= size_reloc) if ( relo - reloc_info >= size_reloc)
mem_relo(); mem_relo();
relo->or_type = RELO4; r = relo;
#ifdef BYTES_REVERSED
relo->or_type |= RELBR; r->or_type = ( pcrel) ? RELPC|RRR : RRR;
#endif r->or_sect = S_MIN + conv_seg( cur_seg);
#ifdef WORDS_REVERSED r->or_nami = find_sym(sym, REFERENCE);
relo->or_type |= RELWR; r->or_addr = cur_value();
#endif gen4( (pcrel) ? off - ( r->or_addr + 4) : off);
relo->or_type |= ( pcrel) ? RELPC : S_UND;
relo->or_sect = S_MIN + conv_seg( cur_seg);
relo->or_nami = find_sym(sym, REFERENCE);
relo->or_addr = cur_value();
gen4( (pcrel) ? off - ( cur_value() + 4) : off);
/* print( "r %s r %ld s %d in %d adrr %ld off %ld\n", /* print( "r %s r %ld s %d in %d adrr %ld off %ld\n",
sym, pcrel, cur_seg, relo->or_nami, relo->or_addr, sym, pcrel, cur_seg, r->or_nami, r->or_addr,
(pcrel) ? off-cur_value() : off); (pcrel) ? off-cur_value() : off);
*/ */

View file

@ -1,6 +1,7 @@
#include <system.h> #include <system.h>
#include <out.h> #include <out.h>
#include "back.h" #include "back.h"
#include "data.h"
/* Solve the local references. /* Solve the local references.
*/ */
@ -8,9 +9,6 @@
#define seg_index( s) ( nname - SEGBSS - 1 + s) #define seg_index( s) ( nname - SEGBSS - 1 + s)
long get4(); long get4();
extern short get2();
extern char get1();
do_local_relocation() do_local_relocation()

View file

@ -6,10 +6,10 @@ TWO_BYTES w;
{ {
if ((_data_cnt -= 2) < 0) mem_data(); if ((_data_cnt -= 2) < 0) mem_data();
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
*data++ = ( unsigned short)w>>8; *data++ = w>>8;
*data++ = w; *data++ = w;
#else #else
*data++ = w; *data++ = w;
*data++ = ( unsigned short)w>>8; *data++ = w>>8;
#endif #endif
} }

View file

@ -1,14 +1,22 @@
#include "mach.h" #include "mach.h"
#include "back.h"
#ifdef BYTES_REVERSED
#define rom2(w) { *data++ = ((w) >> 8); *data++ = (w);}
#else
#define rom2(w) { *data++ = (w); *data++ = ((w)>>8);}
#endif
rom4( l) rom4( l)
FOUR_BYTES l; FOUR_BYTES l;
{ {
if ((_data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
rom2( (short) ((unsigned long)l>>16)); rom2( (int)(l>>16));
rom2( (short) l); rom2( (int) l);
#else #else
rom2( (short) l); rom2( (int) l);
rom2( (short) ((unsigned long)l>>16)); rom2( (int) (l>>16));
#endif #endif
} }

View file

@ -1,14 +1,12 @@
#include "data.h" #include "data.h"
switchseg( seg) swtchsg( seg)
int seg; int seg;
/* The EM definition demands that pseudo instructions are aligned /* The EM definition demands that pseudo instructions are aligned
* at word boundaries. * at word boundaries.
*/ */
{ {
if ( seg == cur_seg)
return;
cur_seg = seg; cur_seg = seg;
align_word(); align_word();
} }

View file

@ -30,6 +30,9 @@ int string_lengte = 0,
index_symbol_table = -1; index_symbol_table = -1;
struct Hashitem *Hashitems ; struct Hashitem *Hashitems ;
/* MAXHASH must be a power of two ... */
#define MAXHASH 512
static int Hashtab[ MAXHASH]; static int Hashtab[ MAXHASH];
static int Hash(); static int Hash();
@ -38,7 +41,6 @@ int find_sym( sym, isdef)
char *sym; char *sym;
int isdef; int isdef;
{ {
register char *p;
register struct outname *s; register struct outname *s;
register struct Hashitem *ip; register struct Hashitem *ip;
register int h; register int h;
@ -57,8 +59,11 @@ int isdef;
h = Hash(sym); h = Hash(sym);
for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems; for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems;
ip = (ip->hs_next) + Hashitems) { ip = (ip->hs_next) + Hashitems) {
register char *p = sym, *q;
s = symbol_table + ip->hs_nami; s = symbol_table + ip->hs_nami;
if (strcmp(sym, (s->on_foff) + string_area) == 0) { q = string_area + s->on_foff;
while (*p == *q++) if (*p++ == '\0') {
if ( (s->on_valu == -2) && (isdef == REFERENCE)) { if ( (s->on_valu == -2) && (isdef == REFERENCE)) {
s->on_type = S_EXT; s->on_type = S_EXT;
s->on_valu = -1; s->on_valu = -1;
@ -89,6 +94,8 @@ int isdef;
if ( sym == string) if ( sym == string)
string += string_lengte; string += string_lengte;
else { /* zie C_fil, C_lin, C_lni */ else { /* zie C_fil, C_lin, C_lni */
register char *p;
string_lengte = 0; string_lengte = 0;
for( p=sym; *p != '\0' ; p++) { for( p=sym; *p != '\0' ; p++) {
string_lengte++; string_lengte++;
@ -111,15 +118,14 @@ int isdef;
static int Hash(sym) static int Hash(sym)
register char *sym; char *sym;
{ {
register unsigned h; register unsigned h;
register c; register char *s = sym;
h = 0; h = 0;
while (c = *sym++) { while (*s) {
h <<= 2; h = (h << 2) + *s++;
h += c;
} }
return (h % MAXHASH); return (h & (MAXHASH - 1));
} }

View file

@ -6,10 +6,10 @@ TWO_BYTES w;
{ {
if ((_text_cnt -= 2) < 0) mem_text(); if ((_text_cnt -= 2) < 0) mem_text();
#ifdef BYTES_REVERSED #ifdef BYTES_REVERSED
*text++ = ( unsigned short)w>>8; *text++ = w>>8;
*text++ = w; *text++ = w;
#else #else
*text++ = w; *text++ = w;
*text++ = ( unsigned short)w>>8; *text++ = w>>8;
#endif #endif
} }

View file

@ -1,13 +1,21 @@
#include "mach.h" #include "mach.h"
#include "back.h"
#ifdef BYTES_REVERSED
#define text2(w) { *text++ = ((w) >> 8); *text++ = (w);}
#else
#define text2(w) { *text++ = (w); *text++ = ((w)>>8);}
#endif
text4( l) text4( l)
FOUR_BYTES l; FOUR_BYTES l;
{ {
if ((_text_cnt -= 4) < 0) mem_text();
#ifdef WORDS_REVERSED #ifdef WORDS_REVERSED
text2( (short) ((unsigned long)l>>16)); text2( (int) (l>>16));
text2( (short) l); text2( (int) l);
#else #else
text2( (short) l); text2( (int) l);
text2( (short) ((unsigned long)l>>16)); text2( (int) (l>>16));
#endif #endif
} }