Next batch.

This commit is contained in:
Manoel Trapier
2013-03-08 19:13:03 +01:00
committed by Manoël Trapier
parent 60330b05cd
commit 3d1d1277b7
34 changed files with 568 additions and 603 deletions

View File

@@ -9,25 +9,22 @@
/* $Id$ */
static arg();
static pseudo();
static void arg(struct e_instr *p, int comma);
static void pseudo(struct e_instr *p);
extern char em_flag[];
char *C_error;
#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR)
struct e_instr *
C_alloc()
struct e_instr * C_alloc()
{
static struct e_instr b;
return &b;
}
int
C_out(p)
register struct e_instr *p;
int C_out(struct e_instr *p)
{
/* Generate EM-code from the e_instr structure "p"
*/
@@ -82,9 +79,7 @@ C_out(p)
return 1;
}
static
arg(p, comma)
register struct e_instr *p;
static void arg(struct e_instr *p, int comma)
{
/* Output the argument of "p".
*/
@@ -145,9 +140,7 @@ arg(p, comma)
}
}
static
pseudo(p)
register struct e_instr *p;
static void pseudo(struct e_instr *p)
{
PS(p->em_opcode);

View File

@@ -19,8 +19,8 @@
int C_ontmpfile = 0;
int C_sequential = 1;
Part *C_curr_part;
int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)();
Part *C_curr_part;
void (*C_outpart)(int), (*C_swtout)(void), (*C_swttmp)(void);
#ifdef INCORE
char *C_BASE;
@@ -50,8 +50,8 @@ char *C_current_out = obuf;
char *C_opp = obuf;
#endif
void
C_flush() {
void C_flush()
{
#ifdef INCORE
static unsigned int bufsiz;
@@ -83,9 +83,7 @@ C_flush() {
#define Xputbyte(c) put(c)
#endif
void
C_putbyte(c)
int c;
void C_putbyte(int c)
{
Xputbyte(c);
}
@@ -95,15 +93,11 @@ C_putbyte(c)
#endif
/*ARGSUSED*/
void
C_init(w, p)
arith w, p;
void C_init(arith w, arith p)
{
}
int
C_open(nm)
char *nm;
int C_open(char *nm)
{
/* Open file "nm" for output
*/
@@ -116,8 +110,7 @@ C_open(nm)
return 1;
}
void
C_close()
void C_close()
{
/* Finish the code-generation.
*/
@@ -151,8 +144,7 @@ C_close()
C_ofp = 0;
}
int
C_busy()
int C_busy()
{
return C_ofp != 0; /* true if code is being generated */
}
@@ -166,32 +158,25 @@ C_busy()
names.
*/
void
C_magic()
void C_magic()
{
}
/*** the readable code generating routines ***/
static
wrs(s)
register char *s;
static void wrs(char *s)
{
while (*s) {
C_putbyte(*s++);
}
}
void
C_pt_dnam(s)
char *s;
void C_pt_dnam(char *s)
{
wrs(s);
}
void
C_pt_ilb(l)
label l;
void C_pt_ilb(label l)
{
char buf[16];
@@ -202,17 +187,14 @@ C_pt_ilb(l)
extern char em_mnem[][4];
extern char em_pseu[][4];
void
C_pt_op(x)
void C_pt_op(int x)
{
C_putbyte(' ');
wrs(em_mnem[x - sp_fmnem]);
C_putbyte(' ');
}
void
C_pt_cst(l)
arith l;
void C_pt_cst(arith l)
{
char buf[16];
@@ -220,10 +202,7 @@ C_pt_cst(l)
wrs(buf);
}
void
C_pt_scon(x, y)
char *x;
arith y;
void C_pt_scon(char *x, arith y)
{
char xbuf[1024];
register char *p;
@@ -240,17 +219,14 @@ C_pt_scon(x, y)
C_putbyte('\'');
}
void
C_pt_ps(x)
void C_pt_ps(int x)
{
C_putbyte(' ');
wrs(em_pseu[x - sp_fpseu]);
C_putbyte(' ');
}
void
C_pt_dlb(l)
label l;
void C_pt_dlb(label l)
{
char buf[16];
@@ -258,10 +234,7 @@ C_pt_dlb(l)
wrs(buf);
}
void
C_pt_doff(l, v)
label l;
arith v;
void C_pt_doff(label l, arith v)
{
char buf[16];
@@ -272,10 +245,7 @@ C_pt_doff(l, v)
}
}
void
C_pt_noff(s, v)
char *s;
arith v;
void C_pt_noff(char *s, arith v)
{
char buf[16];
@@ -286,17 +256,13 @@ C_pt_noff(s, v)
}
}
void
C_pt_pnam(s)
char *s;
void C_pt_pnam(char *s)
{
C_putbyte('$');
wrs(s);
}
void
C_pt_dfilb(l)
label l;
void C_pt_dfilb(label l)
{
char buf[16];
@@ -304,11 +270,7 @@ C_pt_dfilb(l)
wrs(buf);
}
void
C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
int sp;
char *v;
arith sz;
void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
{
int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F';
@@ -317,18 +279,18 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_cst(sz);
}
void
C_pt_nl() {
void C_pt_nl()
{
C_putbyte('\n');
}
void
C_pt_comma() {
void C_pt_comma()
{
C_putbyte(',');
}
void
C_pt_ccend() {
void C_pt_ccend()
{
C_putbyte('?');
}
@@ -346,8 +308,7 @@ C_pt_ccend() {
names.
*/
void
C_magic()
void C_magic()
{
put16(sp_magic);
}
@@ -356,9 +317,7 @@ C_magic()
#define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF)
#define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */
void
C_pt_ilb(l)
register label l;
void C_pt_ilb(label l)
{
if (fit8u(l)) {
put8(sp_ilb1);
@@ -370,9 +329,7 @@ C_pt_ilb(l)
}
}
void
C_pt_dlb(l)
register label l;
void C_pt_dlb(label l)
{
if (fit8u(l)) {
put8(sp_dlb1);
@@ -384,9 +341,7 @@ C_pt_dlb(l)
}
}
void
C_pt_cst(l)
register arith l;
void C_pt_cst(arith l)
{
if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) {
/* we can convert 'l' to an int because its value
@@ -405,10 +360,7 @@ C_pt_cst(l)
}
}
void
C_pt_doff(l, v)
label l;
arith v;
void C_pt_doff(label l, arith v)
{
if (v == 0) {
C_pt_dlb(l);
@@ -420,9 +372,7 @@ C_pt_doff(l, v)
}
}
void
C_pt_str(s)
register char *s;
void C_pt_str(char *s)
{
register int len;
@@ -432,18 +382,13 @@ C_pt_str(s)
}
}
void
C_pt_dnam(s)
char *s;
void C_pt_dnam(char *s)
{
put8(sp_dnam);
C_pt_str(s);
}
void
C_pt_noff(s, v)
char *s;
arith v;
void C_pt_noff(char *s, arith v)
{
if (v == 0) {
C_pt_dnam(s);
@@ -455,19 +400,13 @@ C_pt_noff(s, v)
}
}
void
C_pt_pnam(s)
char *s;
void C_pt_pnam(char *s)
{
put8(sp_pnam);
C_pt_str(s);
}
void
C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
int sp;
char *v;
arith sz;
void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
{
/* how 'bout signextension int --> long ??? */
put8(sp);
@@ -475,10 +414,7 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */
C_pt_str(v);
}
void
C_pt_scon(b, n)
register char *b;
register arith n;
void C_pt_scon(char *b, arith n)
{
put8(sp_scon);
C_pt_cst(n);

View File

@@ -193,9 +193,7 @@ static flt_arith r_big_10pow[] = { /* representation of 10 ** -(28*i) */
#define BIGSZ (sizeof(big_10pow)/sizeof(big_10pow[0]))
#define SMALLSZ (sizeof(s10pow)/sizeof(s10pow[0]))
static
add_exponent(e, exp)
register flt_arith *e;
static void add_exponent(flt_arith *e, int exp)
{
int neg = exp < 0;
int divsz, modsz;
@@ -218,10 +216,7 @@ add_exponent(e, exp)
flt_status = status;
}
void
flt_str2flt(s, e)
register char *s;
register flt_arith *e;
void flt_str2flt(char *s, flt_arith *e)
{
register int c;
int dotseen = 0;
@@ -291,10 +286,7 @@ flt_str2flt(s, e)
#define NDIG 18
static char *
flt_ecvt(e, decpt, sign)
register flt_arith *e;
int *decpt, *sign;
static char *flt_ecvt(flt_arith *e, int *decpt, int *sign)
{
/* Like ecvt(), but for extended precision */
@@ -420,12 +412,8 @@ flt_ecvt(e, decpt, sign)
return buf;
}
void
flt_flt2str(e, buf, bufsize)
flt_arith *e;
char *buf;
void flt_flt2str(flt_arith *e, char *buf, int bufsize)
{
int sign, dp;
register int i;
register char *s1;

View File

@@ -8,10 +8,7 @@
#include <system.h>
#include "print.h"
extern char *long2str();
static int
integral(c)
static int integral(int c)
{
switch (c) {
case 'b':
@@ -35,10 +32,7 @@ integral(c)
%[uxbo] = unsigned int
%d = int
$ */
int
_format(buf, fmt, argp)
char *buf, *fmt;
register va_list argp;
int _format(char *buf, char *fmt, va_list argp)
{
register char *pf = fmt;
register char *pb = buf;
@@ -75,7 +69,7 @@ _format(buf, fmt, argp)
else
if (*pf == 'l') {
/* alignment ??? */
if (base = integral(*++pf)) {
if ((base = integral(*++pf))) {
arg = long2str(va_arg(argp,long), base);
}
else {
@@ -84,7 +78,7 @@ _format(buf, fmt, argp)
}
}
else
if (base = integral(*pf)) {
if ((base = integral(*pf))) {
arg = long2str((long)va_arg(argp,int), base);
}
else
@@ -98,7 +92,7 @@ _format(buf, fmt, argp)
while (npad-- > 0)
*pb++ = pad;
while (*pb++ = *arg++);
while (((*pb++) = (*arg++)));
pb--;
pf++;
}

View File

@@ -20,4 +20,6 @@ _PROTOTYPE(void doprnt, (File *f, char *fmt, va_list ap));
_PROTOTYPE(int _format, (char *buf, char *fmt, va_list ap));
_PROTOTYPE(char *sprint, (char *buf, char *fmt, ...));
char *long2str(long val, int base);
#endif /* __PRINT_INCLUDED__ */

View File

@@ -31,9 +31,7 @@ static int listtype = 0; /* indicates pseudo when generating code for
The argument must be of a type allowed by "typset".
Return a pointer to the next argument.
*/
PRIVATE int
checkarg(arg, typset)
register struct e_arg *arg;
PRIVATE int checkarg(struct e_arg *arg, int typset)
{
if (((!typset) && arg->ema_argtype) ||
@@ -53,14 +51,16 @@ checkarg(arg, typset)
return 1;
}
#else /* not CHECKING */
#define checkarg(arg, x) 1
PRIVATE int checkarg(struct e_arg *arg, int typset)
{
return 1;
}
//#define checkarg(arg, x) (1)
#endif /* CHECKING */
/* EM_doinstr: An EM instruction
*/
PRIVATE void
EM_doinstr(p)
register struct e_instr *p;
PRIVATE void EM_doinstr(struct e_instr *p)
{
register int parametertype; /* parametertype of the instruction */
@@ -94,11 +94,8 @@ EM_doinstr(p)
#include "C_mnem.h"
}
PRIVATE void
EM_dopseudo(p)
register struct e_instr *p;
PRIVATE void EM_dopseudo(struct e_instr *p)
{
switch(p->em_opcode) {
case ps_exc: {
C_exc(p->em_exc1, p->em_exc2);
@@ -326,9 +323,7 @@ EM_dopseudo(p)
}
}
PRIVATE void
EM_docon(p)
register struct e_instr *p;
PRIVATE void EM_docon(struct e_instr *p)
{
checkarg(&(p->em_arg), val_ptyp);
switch(p->em_argtype) {
@@ -365,9 +360,7 @@ EM_docon(p)
}
}
PRIVATE void
EM_dostartmes(p)
register struct e_instr *p;
PRIVATE void EM_dostartmes(struct e_instr *p)
{
if (listtype) {
@@ -379,9 +372,7 @@ EM_dostartmes(p)
listtype = ps_mes;
}
EXPORT int
EM_mkcalls(line)
register struct e_instr *line;
EXPORT int EM_mkcalls(struct e_instr *line)
{
#ifdef CHECKING

View File

@@ -11,7 +11,8 @@
#include <ctype.h>
#include <string.h>
/* #define XXX_YYY /* only for early debugging */
/* only for early debugging */
/* #define XXX_YYY */
#ifdef XXX_YYY
#define out(str) (sys_write(STDOUT, str, strlen(str)))
@@ -31,9 +32,7 @@ static int argnum; /* Number of arguments */
/* inithash, pre_hash, hash: Simple hashtable mechanism
*/
PRIVATE int
hash(s)
register char *s;
PRIVATE int hash(char *s)
{
register int h = 0;
@@ -44,9 +43,7 @@ hash(s)
return h;
}
PRIVATE void
pre_hash(i, s)
char *s;
PRIVATE void pre_hash(int i, char *s)
{
register int h;
@@ -67,8 +64,7 @@ pre_hash(i, s)
extern char em_mnem[][4];
extern char em_pseu[][4];
PRIVATE void
inithash()
PRIVATE void inithash()
{
register int i;
@@ -86,8 +82,7 @@ inithash()
/* nospace: skip until we find a non-space character. Also skip
comments.
*/
PRIVATE int
nospace()
PRIVATE int nospace()
{
register int c;
@@ -104,9 +99,7 @@ nospace()
/* syntax: Put an error message in EM_error and skip to the end of the line
*/
PRIVATE void
syntax(s)
char *s;
PRIVATE void syntax(char *s)
{
register int c;
@@ -118,8 +111,7 @@ syntax(s)
/* checkeol: check that we have a complete line (except maybe for spaces)
*/
PRIVATE void
checkeol()
PRIVATE void checkeol()
{
if (nospace() != '\n') {
@@ -130,8 +122,7 @@ checkeol()
/* getescape: read a '\' escape sequence
*/
PRIVATE int
getescape()
PRIVATE int getescape()
{
register int c, j, r;
@@ -163,8 +154,7 @@ getescape()
/* getname: Read a string of characters representing an identifier
*/
PRIVATE struct string *
getname()
PRIVATE struct string * getname()
{
register char *p;
register struct string *s;
@@ -202,8 +192,7 @@ getname()
/* getstring: read a string of characters between quotes
*/
PRIVATE struct string *
getstring()
PRIVATE struct string *getstring()
{
register char *p;
struct string *s;
@@ -252,11 +241,9 @@ getstring()
return s;
}
PRIVATE void gettyp();
PRIVATE void gettyp(int typset, struct e_arg *ap);
PRIVATE int
offsetted(argtyp, ap)
arith *ap;
PRIVATE int offsetted(int argtyp, arith *ap)
{
register int c;
@@ -274,10 +261,7 @@ offsetted(argtyp, ap)
return argtyp;
}
PRIVATE int
getnumber(c, ap)
register int c;
register struct e_arg *ap;
PRIVATE int getnumber(int c, struct e_arg *ap)
{
char str[256 + 1];
register char *p = str;
@@ -365,12 +349,9 @@ getnumber(c, ap)
return sp_cst4;
}
PRIVATE int getexpr();
PRIVATE int getexpr(int c, struct e_arg *ap);
PRIVATE int
getfactor(c, ap)
register int c;
register struct e_arg *ap;
PRIVATE int getfactor(int c, struct e_arg *ap)
{
if (c == '(') {
if (getexpr(nospace(), ap) != sp_cst4) {
@@ -385,10 +366,7 @@ getfactor(c, ap)
return getnumber(c, ap);
}
PRIVATE int
getterm(c, ap)
register int c;
register struct e_arg *ap;
PRIVATE int getterm(int c, struct e_arg *ap)
{
arith left;
@@ -413,10 +391,7 @@ getterm(c, ap)
return sp_cst4;
}
PRIVATE int
getexpr(c, ap)
register int c;
register struct e_arg *ap;
PRIVATE int getexpr(int c, struct e_arg *ap)
{
arith left;
@@ -440,8 +415,7 @@ getexpr(c, ap)
return sp_cst4;
}
PRIVATE int
get15u()
PRIVATE int get15u()
{
struct e_arg dummy;
@@ -452,9 +426,7 @@ get15u()
return (int) (dummy.ema_cst);
}
PRIVATE void
gettyp(typset, ap)
register struct e_arg *ap;
PRIVATE void gettyp(int typset, struct e_arg *ap)
{
register int c, t;
register int argtyp;
@@ -499,7 +471,7 @@ gettyp(typset, ap)
out("string\n");
ungetbyte(c);
s = getstring(0);
s = getstring();
ap->ema_string = s->str;
ap->ema_szoroff = s->length;
ap->ema_argtype = str_ptyp;
@@ -528,9 +500,7 @@ gettyp(typset, ap)
}
}
PRIVATE void
getarg(typset, ap)
struct e_arg *ap;
PRIVATE void getarg(int typset, struct e_arg *ap)
{
register int c;
@@ -550,9 +520,7 @@ getarg(typset, ap)
/* getmnem: We found the start of either an instruction or a pseudo.
get the rest of it
*/
PRIVATE void
getmnem(c, p)
register struct e_instr *p;
PRIVATE void getmnem(int c, struct e_instr *p)
{
register int h;
int i;
@@ -592,8 +560,7 @@ getmnem(c, p)
}
}
PRIVATE void
line_line()
PRIVATE void line_line()
{
static char filebuf[256 + 1];
char *btscpy();
@@ -606,11 +573,8 @@ line_line()
EM_filename = filebuf;
}
PRIVATE void
getlabel(c, p)
register struct e_instr *p;
PRIVATE void getlabel(int c, struct e_instr *p)
{
ungetbyte(c);
gettyp(lab_ptyp|ptyp(sp_cst2), &(p->em_arg));
switch(p->em_argtype) {
@@ -629,9 +593,7 @@ getlabel(c, p)
checkeol();
}
PRIVATE void
gethead(p)
register struct e_instr *p;
PRIVATE void gethead(struct e_instr *p)
{
register int c;

View File

@@ -14,10 +14,7 @@
#define MAXWIDTH 32
char *
long2str(val, base)
register long val;
register base;
char *long2str(long val, int base)
{
static char numbuf[MAXWIDTH];
static char vec[] = "0123456789ABCDEF";