cleaned up; hidden names

This commit is contained in:
ceriel 1988-11-18 17:52:39 +00:00
parent 7d8e3b8fcd
commit a804cc2e15
16 changed files with 121 additions and 59 deletions

View file

@ -1,14 +1,19 @@
#include <em.h>
#include <system.h>
#define codefile _codefile
#define cur_seg _cur_seg
#define saved _saved
#define labeltje _labeltje
#define name _name
#define output_back _output_back
extern File *codefile;
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
*extnd_part(), *extnd_cont();
extern int holno, procno;
#define swtxt() switchseg( SEGTXT)
#define SEGTXT 0

View file

@ -4,7 +4,7 @@
/* This file contains low-level routines for generating assembly code. */
int procno = 0, holno = 0, cur_seg = -1, saved = FALSE;
int cur_seg = -1, saved = FALSE;
char name[256], labeltje[256];
File *codefile;
@ -41,18 +41,18 @@ dump_label()
}
char *extnd_pro( procno)
int procno;
char *extnd_pro( prcno)
int prcno;
{
sprint( name, "pro%d", procno);
sprint( name, "pro%d", prcno);
return( name);
}
char *extnd_start( procno)
int procno;
char *extnd_start( prcno)
int prcno;
{
sprint( name, "start%d", procno);
sprint( name, "start%d", prcno);
return( name);
}
@ -81,10 +81,10 @@ arith g;
}
char *extnd_ilb( l)
char *extnd_ilb( l, prcno)
arith l;
{
sprint( name, ILB_FMT, procno, (arith) l);
sprint( name, ILB_FMT, prcno, (arith) l);
return( name);
}

View file

@ -3,5 +3,3 @@
#include "back.h"
extern int cur_seg;
extern holno, procno;

View file

@ -18,7 +18,6 @@ init_back.c
label.c
memory.c
misc.c
mysprint.c
output.c
reloc1.c
reloc2.c

View file

@ -4,15 +4,14 @@
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
*extnd_part(), *extnd_cont();
extern holno, procno;
#include "data.h"
/* These routines are called very often, thus we turned them into macros. */
#define text1(b) {if (--_text_cnt < 0) mem_text(); *text++ = b;}
#define con1(b) {if (--_data_cnt < 0) mem_data(); *data++ = b;}
#define rom1(b) {if (--_data_cnt < 0) mem_data(); *data++ = b;}
#define text1(b) {if (--text_cnt < 0) mem_text(); *text++ = b;}
#define con1(b) {if (--data_cnt < 0) mem_data(); *data++ = b;}
#define rom1(b) {if (--data_cnt < 0) mem_data(); *data++ = b;}
#define bss( n) ( nbss += n)
@ -26,7 +25,7 @@ extern holno, procno;
#define swtxt() switchseg( SEGTXT)
#define switchseg(seg) if ((seg) != cur_seg) swtchsg(seg); else
#define switchseg(seg) if ((seg) != cur_seg) _swtchsg(seg); else
#define PC_REL 1
#define ABSOLUTE !PC_REL

View file

@ -5,10 +5,10 @@
common(n)
arith n;
{
extern int Label, label_waiting;
register struct outname *nm = &symbol_table[Label];
extern int _Label, _Label_waiting;
register struct outname *nm = &symbol_table[_Label];
if (label_waiting) {
if (_Label_waiting) {
/* If possible, generate a common. Local commons must
be delt with later.
*/
@ -16,7 +16,7 @@ arith n;
if (n > nm->on_valu) {
nm->on_valu = n;
}
label_waiting = 0;
_Label_waiting = 0;
return;
}
switchseg(SEGBSS);

View file

@ -4,7 +4,7 @@
con2( w)
TWO_BYTES w;
{
if ((_data_cnt -= 2) < 0) mem_data();
if ((data_cnt -= 2) < 0) mem_data();
#ifdef BYTES_REVERSED
*data++ = w>>8;
*data++ = w;

View file

@ -10,7 +10,7 @@
con4( l)
FOUR_BYTES l;
{
if ((_data_cnt -= 4) < 0) mem_data();
if ((data_cnt -= 4) < 0) mem_data();
#ifdef WORDS_REVERSED
con2( (int)(l>>16));
con2( (int) l);
@ -19,5 +19,3 @@ FOUR_BYTES l;
con2( (int) (l>>16));
#endif
}

View file

@ -1,5 +1,42 @@
/* The global datastructures (see "data.c"). */
#define cur_value _cur_value
#define get4 _get4
#define cur_seg _cur_seg
#define text _text
#define data _data
#define string _string
#define nname _nname
#define nbss _nbss
#define size_text _size_text
#define size_data _size_data
#define size_reloc _size_reloc
#define size_symbol _size_symbol
#define size_string _size_string
#define text_cnt _text_cnt
#define data_cnt _data_cnt
#define text_area _text_area
#define data_area _data_area
#define string_area _string_area
#define reloc_info _reloc_info
#define relo _relo
#define symbol_table _symbol_table
#define mem_text _mem_text
#define mem_data _mem_data
#define mem_relo _mem_relo
#define mem_string _mem_string
#define mem_symbol_hash _mem_symbol_hash
#define put1 _put1
#define put2 _put2
#define put4 _put4
#define get1 _get1
#define get2 _get2
#define get4 _get4
#define do_local_relocation _do_local_relocation
#define string_lengte _string_length
#define index_symbol_table _index_symbol_table
#define output_back _output_back
extern long cur_value();
extern long get4();
@ -8,11 +45,11 @@ extern int cur_seg;
extern char *text, *data, *string;
extern int nname;
extern long nbss, size_text, size_data, size_reloc, size_symbol,
size_string, _text_cnt, _data_cnt;
size_string, text_cnt, data_cnt;
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])
#define _put1(buf, off, w) ((buf)[off] = (w))
#define _get1(buf, off) ((buf)[off])

View file

@ -3,14 +3,7 @@
#include "back.h"
#include "header.h"
end_back()
{
finish_tables();
do_local_relocation();
}
static
finish_tables()
/* Prepare tables for do_local_relocation() and output().
@ -23,7 +16,6 @@ finish_tables()
define_segments();
}
static char *seg_name[] = {
".text",
".rom",
@ -31,7 +23,7 @@ static char *seg_name[] = {
".bss"
};
static
define_segments()
{
int i, s;
@ -42,3 +34,8 @@ define_segments()
}
}
end_back()
{
finish_tables();
do_local_relocation();
}

View file

@ -4,6 +4,32 @@
#include "header.h"
#include "data.h"
#include "mach.h"
#include <varargs.h>
/* Mysprint() stores the string directly in the string_arae. This saves
* a copy action. It is assumed that the strings stored in the string-table
* are never longer than MAXSTRLEN bytes.
*/
#define MAXSTRLEN 1024
/*VARARGS*/
static int mysprint(va_alist)
va_dcl
{
char *fmt;
va_list args;
int retval;
va_start(args);
fmt = va_arg(args, char *);
while (string + MAXSTRLEN - string_area > size_string)
mem_string();
retval = _format(string, fmt, args);
string[retval] = '\0';
va_end(args);
return retval;
}
/* The extnd_*()s make a name unique. The resulting string is directly stored
* in the symbol_table (by mysprint()). Later additional fields in the
@ -12,22 +38,21 @@
*/
extern int string_lengte, index_symbol_table;
int procno = 0, holno = 0;
char *extnd_pro( procno)
int procno;
char *extnd_pro( prcno)
int prcno;
{
string_lengte = mysprint( "%cprc%d", GENLAB, procno);
string_lengte = mysprint( "%cprc%d", GENLAB, prcno);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}
char *extnd_start( procno)
int procno;
char *extnd_start( prcno)
int prcno;
{
string_lengte = mysprint( "%cstrt%d", GENLAB, procno);
string_lengte = mysprint( "%cstrt%d", GENLAB, prcno);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}
@ -60,10 +85,10 @@ arith g;
}
char *extnd_ilb( l)
char *extnd_ilb( l, prcno)
arith l;
{
string_lengte = mysprint( ILB_FMT, procno, (arith) l);
string_lengte = mysprint( ILB_FMT, prcno, (arith) l);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}

View file

@ -3,4 +3,6 @@ struct Hashitem {
int hs_nami;
};
#define Hashitems _HashItems
extern struct Hashitem *Hashitems;

View file

@ -2,7 +2,7 @@
#include "header.h"
#include "back.h"
int Label, label_waiting;
int _Label, _Label_waiting;
save_label( lab)
char *lab;
@ -13,18 +13,18 @@ char *lab;
* is not allowed.
*/
{
Label = find_sym( lab, SYMBOL_DEFINITION);
label_waiting = 1;
_Label = find_sym( lab, SYMBOL_DEFINITION);
_Label_waiting = 1;
}
dump_label()
{
if ( label_waiting) {
if ( _Label_waiting) {
align_word();
symbol_table[ Label].on_valu = cur_value();
symbol_table[ Label].on_type |= ( S_MIN + conv_seg( cur_seg));
label_waiting = 0;
symbol_table[ _Label].on_valu = cur_value();
symbol_table[ _Label].on_type |= ( S_MIN + conv_seg( cur_seg));
_Label_waiting = 0;
}
}

View file

@ -5,6 +5,7 @@
#include "back.h"
static reduce_name_table();
static convert_outname();
static int nrelo;
@ -159,10 +160,11 @@ reduce_name_table()
wr_fatal()
{
fprint( STDERR, "write failed\n");
abort();
sys_stop(S_ABORT);
}
static
convert_outname( header)
struct outhead *header;
{

View file

@ -71,7 +71,7 @@ do_local_relocation()
put1( sect, rp->or_addr, (char) newval);
}
else
print( STDERR, "do_relo() : bad relocation size\n");
fprint( STDERR, "do_relo() : bad relocation size\n");
rp->or_nami = seg_index((np->on_type & S_TYP) - S_MIN);
/* print(
"reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n",

View file

@ -1,6 +1,6 @@
#include "data.h"
swtchsg( seg)
_swtchsg( seg)
int seg;
/* The EM definition demands that pseudo instructions are aligned