Add em22 compile, change EM machine executable format to put proc table in text
[Ack-5.5.git] / util / ass / assda.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 #include        "ass00.h"
6 #include        "assex.h"
7
8 #ifndef NORCSID
9 static char rcs_id[] = "$Id: assda.c,v 2.8 1994/06/24 10:15:33 ceriel Exp $" ;
10 static char rcs_ass[]= RCS_ASS ;
11 static char rcs_ex[] = RCS_EX ;
12 #endif
13
14 /*
15  * global data
16  */
17
18 int     wordsize ;
19 int     ptrsize ;
20 cons_t  maxadr ;
21 cons_t  maxint;
22 cons_t  maxdint;
23 cons_t  maxunsig;
24 cons_t  maxdunsig;
25
26 /*
27         The structure containing used for procedure environment stacking
28 */
29 stat_t  pstate ;
30
31 /*
32  * pointers to not yet allocated storage
33  */
34 glob_t  *mglobs;                        /* pointer to module symbols */
35 glob_t  *xglobs;                        /* pointer to extern symbols */
36 proc_t  *mprocs;                        /* pointer to local procs */
37 proc_t  *xprocs;                        /* pointer to external procs */
38 ptab_t  *proctab;                       /* pointer to proctab[] */
39
40 /*
41  * some array and structures of known size
42  */
43 FILE    *ifile;                         /* input file buffer */
44 FILE    *tfile;                         /* code file buffer */
45 FILE    *dfile;                         /* data file buffer */
46 FILE    *rtfile;                        /* code file buffer */
47 FILE    *rdfile;                        /* data file buffer */
48 char    string[MAXSTRING];
49
50 /*
51  * some other pointers
52  */
53 glob_t  *lastglosym;                    /* last global symbol */
54 glob_t  *curglosym;                     /* current global symbol */
55 relc_t  *f_data = (relc_t *)0 ;         /* first data reloc pointer */
56 relc_t  *l_data = (relc_t *)0 ;         /* last data reloc pointer */
57 relc_t  *f_text = (relc_t *)0 ;         /* first text reloc pointer */
58 relc_t  *l_text = (relc_t *)0 ;         /* last text reloc pointer */
59
60 /*
61  * some indices
62  */
63 int     strlngth;                       /* index in string[] */
64 FOFFSET inpoff;                         /* offset in current input file */
65 FOFFSET libeof;                         /* ceiling for above number */
66
67 /*
68  * some other counters
69  */
70 int     procnum;                        /* generic for unique proc-descr. */
71 cons_t  prog_size;                      /* length of current proc */
72 int     max_bytes;
73 int     pass;
74 int     line_num;                       /* line number for error messages */
75 int     nerrors;                        /* number of nonfatal errors */
76 cons_t  consiz;                         /* size of U,I or F value */
77 cons_t  procbytes;                      /* size of process table */
78 cons_t  textbytes;                      /* size of code file */
79 cons_t  databytes;                      /* highwater mark in data */
80 FOFFSET dataoff;                        /* size of data file */
81 FOFFSET textoff;                        /* size of text file */
82 FOFFSET lastoff;                        /* previous size before last block */
83 int     datamode;                       /* what kind of data */
84 int     datablocks;                     /* number of datablocks written out */
85 relc_t *lastheader;                     /* pointer into datareloc */
86 cons_t  holbase;
87 cons_t  holsize;
88 int     unresolved;                     /* # of unresolved references */
89 int     sourcelines;                    /* number of lines in source program*/
90 int     intflags        =  1;           /* flags for interpreter */
91 /*
92  * some flags
93  */
94 int     archmode;                       /* reading library ? */
95 int     procflag;                       /* print "namelist" of procedures */
96 #ifdef  DUMP
97 int     c_flag;                         /* print unused opcodes */
98 char    opcnt1[256];                    /* count primary opcodes */
99 char    opcnt2[256];                    /* count secondary opcodes */
100 char    opcnt3[256];                    /* count long opcodes */
101 #endif
102 int     d_flag          =  0;           /* don't dump */
103 int     r_flag          =  0;           /* don't dump relocation tables */
104 #ifdef JOHAN
105 int     jflag;
106 #endif
107 int     wflag           =  0;           /* don't issue warning messages */
108 int     Uflag           =  0;           /* exit status 0 on unresolved refs */
109 int     eof_seen;
110 int     mod_sizes;                      /* Size info in current module ok? */
111
112 #define BASE    (sizeof (struct lines) - sizeof (addr_u))
113
114 char    linesize[VALLOW+1] = {
115         BASE,                           /* MISSING */
116         BASE + sizeof (cons_t),         /* CONST */
117         BASE + sizeof prp_cast,         /* PROCNAME */
118         BASE + sizeof gbp_cast,         /* GLOSYM */
119         BASE + sizeof lbp_cast,         /* LOCSYM */
120         BASE + sizeof (struct sad_df),  /* GLOOFF */
121         BASE + sizeof (struct sad_ln),  /* LINES */
122         BASE                            /* VALLOW */
123 } ;
124
125 /*
126  * miscellaneous
127  */
128 char    *progname;                      /* argv[0] */
129 char    *curfile        =  0;           /* name of current file */
130 char    *eout           =  "e.out";
131 arch_t  archhdr;
132 siz_t  sizes[NDEFAULT] = {
133 /*   mlab, glab,mproc,xproc, proc */
134     { 151,   29,   31,   73,  130 },    /* small */
135     { 307,  127,  151,  401,  460 },    /* medium */
136     { 601,  251,  151,  401,  600 },    /* large */
137     {1601, 1601, 1601, 1601, 2000 }     /* extra large */
138 };
139 siz_t  *oursize        =  &sizes[2] ;  /* point to selected sizes */