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 switchseg(seg) if ((seg) != cur_seg) swtchsg(seg); else
#define PC_REL 1
#define ABSOLUTE !PC_REL
@ -34,8 +36,7 @@ extern holno, procno;
#define MAXTEXT 4096
#define MAXDATA 2048
#define MAXRELO 100
#define MAXNAME 100
#define MAXSTRING 2048
#define MAXHASH 256
#define MAXRELO 512
#define MAXNAME 512
#define MAXSTRING 4096

View file

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

View file

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

View file

@ -1,14 +1,22 @@
#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)
FOUR_BYTES l;
{
if ((_data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED
con2( (short) ((unsigned long)l>>16));
con2( (short) l);
con2( (int)(l>>16));
con2( (int) l);
#else
con2( (short) l);
con2( (short) ((unsigned long)l>>16));
con2( (int) l);
con2( (int) (l>>16));
#endif
}

View file

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

View file

@ -1,6 +1,7 @@
/* The global datastructures (see "data.c"). */
extern long cur_value();
extern long get4();
extern int cur_seg;
@ -13,3 +14,5 @@ extern char *text_area, *data_area, *string_area;
extern struct outrelo *reloc_info, *relo;
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 "back.h"
gen2( c)
TWO_BYTES c;
gen2( w)
TWO_BYTES w;
{
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;
case SEGCON : con2( c);
return;
case SEGROM : rom2( c);
case SEGCON :
case SEGROM :
if ((_data_cnt -= 2) < 0) mem_data();
#ifdef BYTES_REVERSED
*data++ = w>>8;
*data++ = w;
#else
*data++ = w;
*data++ = w>>8;
#endif
return;
case SEGBSS : bss( 2);
return;

View file

@ -1,16 +1,38 @@
#include <system.h>
#include "mach.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)
FOUR_BYTES c;
gen4( l)
FOUR_BYTES l;
{
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;
case SEGCON : con4( c);
return;
case SEGROM : rom4( c);
case SEGCON :
case SEGROM :
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;
case SEGBSS : bss( 4);
return;

View file

@ -3,9 +3,12 @@
#include <varargs.h>
/* 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*/
int mysprint(va_alist)
va_dcl
@ -16,7 +19,7 @@ int mysprint(va_alist)
va_start(args);
fmt = va_arg(args, char *);
while (string + 1024 - string_area > size_string)
while (string + MAXSTRLEN - string_area > size_string)
mem_string();
retval = _format(string, fmt, args);
string[retval] = '\0';

View file

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

View file

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

View file

@ -9,29 +9,40 @@
* 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)
char *sym;
arith off;
int pcrel;
{
register struct outrelo *r;
if ( relo - reloc_info >= size_reloc)
mem_relo();
relo->or_type = RELO4;
#ifdef BYTES_REVERSED
relo->or_type |= RELBR;
#endif
#ifdef WORDS_REVERSED
relo->or_type |= RELWR;
#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();
gen4( (pcrel) ? off - ( cur_value() + 4) : off);
r = relo;
r->or_type = ( pcrel) ? RELPC|RRR : RRR;
r->or_sect = S_MIN + conv_seg( cur_seg);
r->or_nami = find_sym(sym, REFERENCE);
r->or_addr = cur_value();
gen4( (pcrel) ? off - ( r->or_addr + 4) : off);
/* 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);
*/

View file

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

View file

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

View file

@ -1,14 +1,22 @@
#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)
FOUR_BYTES l;
{
if ((_data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED
rom2( (short) ((unsigned long)l>>16));
rom2( (short) l);
rom2( (int)(l>>16));
rom2( (int) l);
#else
rom2( (short) l);
rom2( (short) ((unsigned long)l>>16));
rom2( (int) l);
rom2( (int) (l>>16));
#endif
}

View file

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

View file

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

View file

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

View file

@ -1,13 +1,21 @@
#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)
FOUR_BYTES l;
{
if ((_text_cnt -= 4) < 0) mem_text();
#ifdef WORDS_REVERSED
text2( (short) ((unsigned long)l>>16));
text2( (short) l);
text2( (int) (l>>16));
text2( (int) l);
#else
text2( (short) l);
text2( (short) ((unsigned long)l>>16));
text2( (int) l);
text2( (int) (l>>16));
#endif
}