cleaned up; hidden names
This commit is contained in:
parent
7d8e3b8fcd
commit
a804cc2e15
|
@ -1,14 +1,19 @@
|
||||||
#include <em.h>
|
#include <em.h>
|
||||||
#include <system.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 File *codefile;
|
||||||
|
|
||||||
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
|
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
|
||||||
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
|
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
|
||||||
*extnd_part(), *extnd_cont();
|
*extnd_part(), *extnd_cont();
|
||||||
|
|
||||||
extern int holno, procno;
|
|
||||||
|
|
||||||
#define swtxt() switchseg( SEGTXT)
|
#define swtxt() switchseg( SEGTXT)
|
||||||
|
|
||||||
#define SEGTXT 0
|
#define SEGTXT 0
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
/* This file contains low-level routines for generating assembly code. */
|
/* 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];
|
char name[256], labeltje[256];
|
||||||
|
|
||||||
File *codefile;
|
File *codefile;
|
||||||
|
@ -41,18 +41,18 @@ dump_label()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *extnd_pro( procno)
|
char *extnd_pro( prcno)
|
||||||
int procno;
|
int prcno;
|
||||||
{
|
{
|
||||||
sprint( name, "pro%d", procno);
|
sprint( name, "pro%d", prcno);
|
||||||
return( name);
|
return( name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *extnd_start( procno)
|
char *extnd_start( prcno)
|
||||||
int procno;
|
int prcno;
|
||||||
{
|
{
|
||||||
sprint( name, "start%d", procno);
|
sprint( name, "start%d", prcno);
|
||||||
return( name);
|
return( name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ arith g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *extnd_ilb( l)
|
char *extnd_ilb( l, prcno)
|
||||||
arith l;
|
arith l;
|
||||||
{
|
{
|
||||||
sprint( name, ILB_FMT, procno, (arith) l);
|
sprint( name, ILB_FMT, prcno, (arith) l);
|
||||||
return( name);
|
return( name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,3 @@
|
||||||
#include "back.h"
|
#include "back.h"
|
||||||
|
|
||||||
extern int cur_seg;
|
extern int cur_seg;
|
||||||
|
|
||||||
extern holno, procno;
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ init_back.c
|
||||||
label.c
|
label.c
|
||||||
memory.c
|
memory.c
|
||||||
misc.c
|
misc.c
|
||||||
mysprint.c
|
|
||||||
output.c
|
output.c
|
||||||
reloc1.c
|
reloc1.c
|
||||||
reloc2.c
|
reloc2.c
|
||||||
|
|
|
@ -4,15 +4,14 @@
|
||||||
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
|
extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(),
|
||||||
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
|
*extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(),
|
||||||
*extnd_part(), *extnd_cont();
|
*extnd_part(), *extnd_cont();
|
||||||
extern holno, procno;
|
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
/* These routines are called very often, thus we turned them into macros. */
|
/* These routines are called very often, thus we turned them into macros. */
|
||||||
|
|
||||||
#define text1(b) {if (--_text_cnt < 0) mem_text(); *text++ = b;}
|
#define text1(b) {if (--text_cnt < 0) mem_text(); *text++ = b;}
|
||||||
#define con1(b) {if (--_data_cnt < 0) mem_data(); *data++ = b;}
|
#define con1(b) {if (--data_cnt < 0) mem_data(); *data++ = b;}
|
||||||
#define rom1(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)
|
#define bss( n) ( nbss += n)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ extern holno, procno;
|
||||||
|
|
||||||
#define swtxt() switchseg( SEGTXT)
|
#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 PC_REL 1
|
||||||
#define ABSOLUTE !PC_REL
|
#define ABSOLUTE !PC_REL
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
common(n)
|
common(n)
|
||||||
arith n;
|
arith n;
|
||||||
{
|
{
|
||||||
extern int Label, label_waiting;
|
extern int _Label, _Label_waiting;
|
||||||
register struct outname *nm = &symbol_table[Label];
|
register struct outname *nm = &symbol_table[_Label];
|
||||||
|
|
||||||
if (label_waiting) {
|
if (_Label_waiting) {
|
||||||
/* If possible, generate a common. Local commons must
|
/* If possible, generate a common. Local commons must
|
||||||
be delt with later.
|
be delt with later.
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@ arith n;
|
||||||
if (n > nm->on_valu) {
|
if (n > nm->on_valu) {
|
||||||
nm->on_valu = n;
|
nm->on_valu = n;
|
||||||
}
|
}
|
||||||
label_waiting = 0;
|
_Label_waiting = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switchseg(SEGBSS);
|
switchseg(SEGBSS);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
con2( w)
|
con2( w)
|
||||||
TWO_BYTES w;
|
TWO_BYTES w;
|
||||||
{
|
{
|
||||||
if ((_data_cnt -= 2) < 0) mem_data();
|
if ((data_cnt -= 2) < 0) mem_data();
|
||||||
#ifdef BYTES_REVERSED
|
#ifdef BYTES_REVERSED
|
||||||
*data++ = w>>8;
|
*data++ = w>>8;
|
||||||
*data++ = w;
|
*data++ = w;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
con4( l)
|
con4( l)
|
||||||
FOUR_BYTES l;
|
FOUR_BYTES l;
|
||||||
{
|
{
|
||||||
if ((_data_cnt -= 4) < 0) mem_data();
|
if ((data_cnt -= 4) < 0) mem_data();
|
||||||
#ifdef WORDS_REVERSED
|
#ifdef WORDS_REVERSED
|
||||||
con2( (int)(l>>16));
|
con2( (int)(l>>16));
|
||||||
con2( (int) l);
|
con2( (int) l);
|
||||||
|
@ -19,5 +19,3 @@ FOUR_BYTES l;
|
||||||
con2( (int) (l>>16));
|
con2( (int) (l>>16));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,42 @@
|
||||||
/* The global datastructures (see "data.c"). */
|
/* 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 cur_value();
|
||||||
extern long get4();
|
extern long get4();
|
||||||
|
|
||||||
|
@ -8,11 +45,11 @@ extern int cur_seg;
|
||||||
extern char *text, *data, *string;
|
extern char *text, *data, *string;
|
||||||
extern int nname;
|
extern int nname;
|
||||||
extern long nbss, size_text, size_data, size_reloc, size_symbol,
|
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 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 _put1(buf, off, w) ((buf)[off] = (w))
|
||||||
#define get1(buf, off) ((buf)[off])
|
#define _get1(buf, off) ((buf)[off])
|
||||||
|
|
|
@ -3,14 +3,7 @@
|
||||||
#include "back.h"
|
#include "back.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
|
|
||||||
|
static
|
||||||
end_back()
|
|
||||||
{
|
|
||||||
finish_tables();
|
|
||||||
do_local_relocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
finish_tables()
|
finish_tables()
|
||||||
|
|
||||||
/* Prepare tables for do_local_relocation() and output().
|
/* Prepare tables for do_local_relocation() and output().
|
||||||
|
@ -23,7 +16,6 @@ finish_tables()
|
||||||
define_segments();
|
define_segments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *seg_name[] = {
|
static char *seg_name[] = {
|
||||||
".text",
|
".text",
|
||||||
".rom",
|
".rom",
|
||||||
|
@ -31,7 +23,7 @@ static char *seg_name[] = {
|
||||||
".bss"
|
".bss"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static
|
||||||
define_segments()
|
define_segments()
|
||||||
{
|
{
|
||||||
int i, s;
|
int i, s;
|
||||||
|
@ -42,3 +34,8 @@ define_segments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end_back()
|
||||||
|
{
|
||||||
|
finish_tables();
|
||||||
|
do_local_relocation();
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,32 @@
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "mach.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
|
/* The extnd_*()s make a name unique. The resulting string is directly stored
|
||||||
* in the symbol_table (by mysprint()). Later additional fields in the
|
* in the symbol_table (by mysprint()). Later additional fields in the
|
||||||
|
@ -12,22 +38,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int string_lengte, index_symbol_table;
|
extern int string_lengte, index_symbol_table;
|
||||||
int procno = 0, holno = 0;
|
|
||||||
|
|
||||||
|
|
||||||
char *extnd_pro( procno)
|
char *extnd_pro( prcno)
|
||||||
int procno;
|
int prcno;
|
||||||
{
|
{
|
||||||
string_lengte = mysprint( "%cprc%d", GENLAB, procno);
|
string_lengte = mysprint( "%cprc%d", GENLAB, prcno);
|
||||||
index_symbol_table = find_sym( string, STORE_STRING);
|
index_symbol_table = find_sym( string, STORE_STRING);
|
||||||
return( symbol_table[ index_symbol_table].on_foff + string_area);
|
return( symbol_table[ index_symbol_table].on_foff + string_area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *extnd_start( procno)
|
char *extnd_start( prcno)
|
||||||
int procno;
|
int prcno;
|
||||||
{
|
{
|
||||||
string_lengte = mysprint( "%cstrt%d", GENLAB, procno);
|
string_lengte = mysprint( "%cstrt%d", GENLAB, prcno);
|
||||||
index_symbol_table = find_sym( string, STORE_STRING);
|
index_symbol_table = find_sym( string, STORE_STRING);
|
||||||
return( symbol_table[ index_symbol_table].on_foff + string_area);
|
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;
|
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);
|
index_symbol_table = find_sym( string, STORE_STRING);
|
||||||
return( symbol_table[ index_symbol_table].on_foff + string_area);
|
return( symbol_table[ index_symbol_table].on_foff + string_area);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,6 @@ struct Hashitem {
|
||||||
int hs_nami;
|
int hs_nami;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define Hashitems _HashItems
|
||||||
|
|
||||||
extern struct Hashitem *Hashitems;
|
extern struct Hashitem *Hashitems;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
#include "back.h"
|
#include "back.h"
|
||||||
|
|
||||||
int Label, label_waiting;
|
int _Label, _Label_waiting;
|
||||||
|
|
||||||
save_label( lab)
|
save_label( lab)
|
||||||
char *lab;
|
char *lab;
|
||||||
|
@ -13,18 +13,18 @@ char *lab;
|
||||||
* is not allowed.
|
* is not allowed.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
Label = find_sym( lab, SYMBOL_DEFINITION);
|
_Label = find_sym( lab, SYMBOL_DEFINITION);
|
||||||
label_waiting = 1;
|
_Label_waiting = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dump_label()
|
dump_label()
|
||||||
{
|
{
|
||||||
if ( label_waiting) {
|
if ( _Label_waiting) {
|
||||||
align_word();
|
align_word();
|
||||||
symbol_table[ Label].on_valu = cur_value();
|
symbol_table[ _Label].on_valu = cur_value();
|
||||||
symbol_table[ Label].on_type |= ( S_MIN + conv_seg( cur_seg));
|
symbol_table[ _Label].on_type |= ( S_MIN + conv_seg( cur_seg));
|
||||||
label_waiting = 0;
|
_Label_waiting = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "back.h"
|
#include "back.h"
|
||||||
|
|
||||||
static reduce_name_table();
|
static reduce_name_table();
|
||||||
|
static convert_outname();
|
||||||
|
|
||||||
static int nrelo;
|
static int nrelo;
|
||||||
|
|
||||||
|
@ -159,10 +160,11 @@ reduce_name_table()
|
||||||
wr_fatal()
|
wr_fatal()
|
||||||
{
|
{
|
||||||
fprint( STDERR, "write failed\n");
|
fprint( STDERR, "write failed\n");
|
||||||
abort();
|
sys_stop(S_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
convert_outname( header)
|
convert_outname( header)
|
||||||
struct outhead *header;
|
struct outhead *header;
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,7 @@ do_local_relocation()
|
||||||
put1( sect, rp->or_addr, (char) newval);
|
put1( sect, rp->or_addr, (char) newval);
|
||||||
}
|
}
|
||||||
else
|
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);
|
rp->or_nami = seg_index((np->on_type & S_TYP) - S_MIN);
|
||||||
/* print(
|
/* print(
|
||||||
"reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n",
|
"reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
swtchsg( 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
|
||||||
|
|
Loading…
Reference in a new issue