Make proper one-pass compiler by redirecting c0 outcode() into c1 getree()
authorNick Downing <downing.nick@gmail.com>
Thu, 9 Feb 2017 15:29:05 +0000 (02:29 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 9 Feb 2017 15:29:05 +0000 (02:29 +1100)
Makefile
c00.c
c01.c
c04.c
c10.c
c11.c
c12.c
ccom.c
ccom.h

index c750e85..4a23ab3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 HOSTCC=cc
 INSTALL=install
-CFLAGS=-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
+CFLAGS=-g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
 #CFLAGS = -O
 #LDC0FLAGS= -i
 #LDC1FLAGS= -n
diff --git a/c00.c b/c00.c
index 75a2010..09d3c3e 100644 (file)
--- a/c00.c
+++ b/c00.c
@@ -441,6 +441,7 @@ int subseq(c, a, b) int c; int a; int b; {
  * lab.
  */
 void putstr(lab, max) int lab; register int max; {
+ int flag = 0;
        register int c;
 
        nchstr = 0;
@@ -450,23 +451,34 @@ void putstr(lab, max) int lab; register int max; {
 #else
                strflg++;
 #endif
-               outcode("BNB", LABEL, lab, BDATA);
+               outcode("BN", LABEL, lab);
                max = 10000;
-       } else
-               outcode("B", BDATA);
+       }
+ /*    outcode("B", BDATA);*/
        while ((c = mapch('"')) >= 0) {
                if (nchstr < max) {
                        nchstr++;
                        if (nchstr%15 == 0)
-                               outcode("0B", BDATA);
-                       outcode("1N", c & 0377);
+ /*                            outcode("0B", BDATA);*/
+  fprintf(temp_fp[temp_fi], "\n.byte ");
+ else if (flag)
+  fputc(',', temp_fp[temp_fi]);
+ /*                    outcode("1N", c & 0377);*/
+ fprintf(temp_fp[temp_fi], "%o", c & 0377);
+ flag = 1;
                }
        }
        if (nchstr < max) {
                nchstr++;
-               outcode("10");
+ /*            outcode("10");*/
+ if (flag)
+  fputc(',', temp_fp[temp_fi]);
+ fputc('0', temp_fp[temp_fi]);
+ flag = 1;
        }
-       outcode("0");
+ /*    outcode("0");*/
+ if (flag)
+  fputc('\n', temp_fp[temp_fi]);
 #if 1
        temp_fi = 0;
 #else
diff --git a/c01.c b/c01.c
index ac3278d..aba6a32 100644 (file)
--- a/c01.c
+++ b/c01.c
@@ -7,10 +7,10 @@
 #include <unistd.h>
 #ifdef __STDC__
 #include <stdarg.h>
-#define _va_start(ap, arg) va_start(ap, arg)
+#define _va_start(argp, arg) va_start(argp, arg)
 #else
 #include <varargs.h>
-#define _va_start(ap, arg) va_start(ap)
+#define _va_start(argp, arg) va_start(argp)
 #endif
 #include "c0.h"
 
@@ -544,16 +544,16 @@ void werror0(char *s, ...)
 void werror0(s, va_alist) char *s; va_dcl
 #endif
 {
-       va_list ap;
+       va_list argp;
 
        if (Wflag)
                return;
        if (filename[0])
                fprintf(stderr, "%s:", filename);
        fprintf(stderr, "%d: warning: ", line);
-       _va_start(ap, s);
-       vfprintf(stderr, s, ap);
-       va_end(ap);
+       _va_start(argp, s);
+       vfprintf(stderr, s, argp);
+       va_end(argp);
        fprintf(stderr, "\n");
 }
 
@@ -563,15 +563,15 @@ void error0(char *s, ...)
 void error0(s, va_alist) char *s; va_dcl
 #endif
 {
-       va_list ap;
+       va_list argp;
 
        nerror++;
        if (filename[0])
                fprintf(stderr, "%s:", filename);
        fprintf(stderr, "%d: ", line);
-       _va_start(ap, s);
-       vfprintf(stderr, s, ap);
-       va_end(ap);
+       _va_start(argp, s);
+       vfprintf(stderr, s, argp);
+       va_end(argp);
        fprintf(stderr, "\n");
 }
 
diff --git a/c04.c b/c04.c
index 4f1e68b..0fb5853 100644 (file)
--- a/c04.c
+++ b/c04.c
@@ -5,10 +5,10 @@
 #include <stdlib.h>
 #ifdef __STDC__
 #include <stdarg.h>
-#define _va_start(ap, arg) va_start(ap, arg)
+#define _va_start(argp, arg) va_start(argp, arg)
 #else
 #include <varargs.h>
-#define _va_start(ap, arg) va_start(ap)
+#define _va_start(argp, arg) va_start(argp)
 #endif
 #include "c0.h"
 
@@ -76,11 +76,18 @@ void treeout(tp, isstruct) register union tree0 *tp; int isstruct; {
                hp = &tp->t.tr1->n;
                if (hp->hclass==TYPEDEF)
                        error0("Illegal use of type name");
+#if 1
+ if (hp->hclass==EXTERN)
+  outcode("BNNS", NAME, EXTERN, tp->t.type, hp->name);
+ else
+  outcode("BNNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->t.type, hp->hoffset);
+#else
                outcode("BNN", NAME, hp->hclass==0?STATIC:hp->hclass, tp->t.type);
                if (hp->hclass==EXTERN)
                        outcode("S", hp->name);
                else
                        outcode("N", hp->hoffset);
+#endif
                break;
 
        case LCON:
@@ -341,6 +348,7 @@ void doret() {
  *   1: number 1
  *   0: number 0
  */
+#if 0
 #ifdef __STDC__
 void outcode(char *s, ...)
 #else
@@ -360,7 +368,7 @@ void outcode(s, va_alist) char *s; va_dcl
        if (strflg)
                bufp = sbufp;
 #endif
-       _va_start(ap, s);
+       _va_start(argp, s);
        for (;;) switch(*s++) {
        case 'B':
                ni = va_arg(ap, int);
@@ -402,7 +410,7 @@ void outcode(s, va_alist) char *s; va_dcl
                continue;
 
        case '\0':
-               va_end(ap);
+               va_end(argp);
                if (ferror(bufp)) {
                        error0("Write error0 on temp");
                        exit(1);
@@ -413,6 +421,7 @@ void outcode(s, va_alist) char *s; va_dcl
                error0("Botch in outcode");
        }
 }
+#endif
 
 unsigned int hash(sp) register char *sp; {
        register unsigned int h;
diff --git a/c10.c b/c10.c
index f45ec5b..8ce4976 100644 (file)
--- a/c10.c
+++ b/c10.c
@@ -14,7 +14,7 @@ static        char    sccsid[] = "@(#)c10.c   2.1 (2.11BSD GTE) 10/4/94";
 #include "c1.h"
 
 #ifdef DEBUG
-#define        dbprint(op)     printf("        / %s", opntab[op])
+#define        dbprint(op)     fprintf(temp_fp[temp_fi], /*printf(*/"  / %s", opntab[op])
 #else
 #define        dbprint(op)     /* */
 #endif
@@ -64,11 +64,11 @@ int main(argc, argv) int argc; char *argv[]; {
         * pulls in the floating-point part of printf.
         */
        if (nfloat)
-               printf(".globl  fltused\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".globl    fltused\n");
        /*
         * tack on the string file.
         */
-       printf(".globl\n.data\n");
+       fprintf(temp_fp[temp_fi], /*printf(*/".globl\n.data\n");
        if (*argv[2] != '-') {
                if (freopen(argv[2], "r", stdin)==NULL) {
                        error1("Missing temp file");
@@ -404,15 +404,15 @@ again:
                        dbprint(tree1->t.op);
                        if (table==sptab || table==lsptab) {
                                if (tree1->t.type==LONG || tree1->t.type==UNLONG){
-                                       printf("mov\tr%d,-(sp)\n",r+1);
+                                       fprintf(temp_fp[temp_fi], /*printf(*/"mov\tr%d,-(sp)\n",r+1);
                                        nstack++;
                                }
-                               printf("mov%s   r%d,%s(sp)\n", modf=='f'?"f":"", r,
+                               fprintf(temp_fp[temp_fi], /*printf(*/"mov%s     r%d,%s(sp)\n", modf=='f'?"f":"", r,
                                        table==sptab? "-":"");
                                nstack++;
                        }
                        if (table==cctab || table==cregtab)
-                               printf("tst%s   r%d\n", modf=='f'?"f":"", r);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"tst%s     r%d\n", modf=='f'?"f":"", r);
                        return(r);
                }
        }
@@ -572,13 +572,13 @@ int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table;
        if (p1->t.op==FCON && p1->f.value>0) {
 #ifdef pdp11
 /* nonportable */
-               printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
+               fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
                        ((_UNSIGNED_INT *)&(p1->f.fvalue))[0],
                        ((_UNSIGNED_INT *)&(p1->f.fvalue))[1],
                        ((_UNSIGNED_INT *)&(p1->f.fvalue))[2],
                        ((_UNSIGNED_INT *)&(p1->f.fvalue))[3] );
 #else
-               printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
+               fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
                        (int)(p1->f.fvalue.h >> 16) & 0xffff,
                        (int)p1->f.fvalue.h & 0xffff,
                        (int)(p1->f.fvalue.l >> 16) & 0xffff,
@@ -592,13 +592,13 @@ int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table;
                if (p2->t.op==FCON && p2->f.value>0) {
 #ifdef pdp11
 /* nonportable */
-                       printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
+                       fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
                                ((_UNSIGNED_INT *)&(p2->f.fvalue))[0],
                                ((_UNSIGNED_INT *)&(p2->f.fvalue))[1],
                                ((_UNSIGNED_INT *)&(p2->f.fvalue))[2],
                                ((_UNSIGNED_INT *)&(p2->f.fvalue))[3] );
 #else
-                       printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
+                       fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
                                (int)(p2->f.fvalue.h >> 16) & 0xffff,
                                (int)p2->f.fvalue.h & 0xffff,
                                (int)(p2->f.fvalue.l >> 16) & 0xffff,
@@ -613,7 +613,7 @@ loop:
         */
        if ((c = *string++) & 0200) {
                c &= 0177;
-               putchar('\t');
+               fputc('\t', temp_fp[temp_fi]) /*putchar('\t')*/;
        }
        switch (c) {
 
@@ -627,7 +627,7 @@ loop:
                                reg--;
                if (table==regtab && (opdope1[tree1->t.op]&ASSGOP)) {
                        if (tree1->t.tr1->t.type==CHAR)
-                               printf("movb    r%d,r%d\n", reg, reg);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"movb      r%d,r%d\n", reg, reg);
                }
                return(reg);
 
@@ -681,17 +681,17 @@ loop:
                p = p2;
        pbyte:
                if (p->t.type==CHAR || p->t.type==UNCHAR)
-                       putchar('b');
+                       fputc('b', temp_fp[temp_fi]) /*putchar('b')*/;
        pb1:
                if (isfloat(p))
-                       putchar('f');
+                       fputc('f', temp_fp[temp_fi]) /*putchar('f')*/;
                goto loop;
 
        /* BE */
        case 'L':
                if (p1->t.type==CHAR || p2->t.type==CHAR
                 || p1->t.type==UNCHAR || p2->t.type==UNCHAR)
-                       putchar('b');
+                       fputc('b', temp_fp[temp_fi]) /*putchar('b')*/;
                p = tree1;
                goto pb1;
 
@@ -793,20 +793,20 @@ loop:
                        else
                                longjmp(jmpbuf, 1);
                }
-               printf("r%d", r);
+               fprintf(temp_fp[temp_fi], /*printf(*/"r%d", r);
                goto loop;
 
        case '-':               /* check -(sp) */
                if (*string=='(') {
                        nstack++;
                        if (table!=lsptab)
-                               putchar('-');
+                               fputc('-', temp_fp[temp_fi]) /*putchar('-')*/;
                        goto loop;
                }
                break;
 
        case ')':               /* check (sp)+ */
-               putchar(')');
+               fputc(')', temp_fp[temp_fi]) /*putchar(')')*/;
                if (*string=='+')
                        nstack--;
                goto loop;
@@ -823,7 +823,7 @@ loop:
        nmbr:
                if(collcon(p)) {
                        if (p->t.op==STAR) {
-                               printf("*");
+                               fprintf(temp_fp[temp_fi], /*printf(*/"*");
                                p = p->t.tr1;
                        }
                        if ((p = p->t.tr2)->t.op == CON) {
@@ -840,12 +840,12 @@ loop:
        case 'T':
                c = reg-1;
                if (uns(p1) || uns(p2)) {
-                       printf("clr     r%d\n", c);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"clr       r%d\n", c);
                        goto loop;
                }
                if (dcalc(p1, 5)>12 && !match(p1, cctab, 10, 0))
-                       printf("tst     r%d\n", reg);
-               printf("sxt     r%d\n", c);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"tst       r%d\n", reg);
+               fprintf(temp_fp[temp_fi], /*printf(*/"sxt       r%d\n", c);
                goto loop;
 
        case 'V':       /* adc sbc, clr, or sxt as required for longs */
@@ -854,7 +854,7 @@ loop:
                case ASPLUS:
                case INCBEF:
                case INCAFT:
-                       printf("adc");
+                       fprintf(temp_fp[temp_fi], /*printf(*/"adc");
                        break;
 
                case MINUS:
@@ -862,7 +862,7 @@ loop:
                case NEG:
                case DECBEF:
                case DECAFT:
-                       printf("sbc");
+                       fprintf(temp_fp[temp_fi], /*printf(*/"sbc");
                        break;
 
                case ASSIGN:
@@ -876,9 +876,9 @@ loop:
                lcasev:
                        if (p->t.type!=LONG && p->t.type!=UNLONG) {
                                if (uns(p) || uns(tree1->t.tr2))
-                                       printf("clr");
+                                       fprintf(temp_fp[temp_fi], /*printf(*/"clr");
                                else
-                                       printf("sxt");
+                                       fprintf(temp_fp[temp_fi], /*printf(*/"sxt");
                                goto loop;
                        }
                default:
@@ -891,7 +891,7 @@ loop:
         * Mask used in field assignments
         */
        case 'Z':
-               printf("$%o", UNS(tree1->F.mask));
+               fprintf(temp_fp[temp_fi], /*printf(*/"$%o", UNS(tree1->F.mask));
                goto loop;
 
        /*
@@ -904,7 +904,7 @@ loop:
                        return(reg);
                goto loop;
        }
-       putchar(c);
+       fputc(c, temp_fp[temp_fi]) /*putchar(c)*/;
        goto loop;
 }
 
@@ -1198,12 +1198,12 @@ int comarg(tree1, flagp) register union tree1 *tree1; int *flagp; {
                size >>= 1;
                if (size <= 5) {
                        for (i=0; i<size; i++)
-                               printf("mov     -(r%d),-(sp)\n", retval);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"mov       -(r%d),-(sp)\n", retval);
                } else {
                        if (retval!=0)
-                               printf("mov     r%d,r0\n", retval);
-                       printf("mov     $%o,r1\n", UNS(size));
-                       printf("L%d:mov -(r0),-(sp)\ndec\tr1\njne\tL%d\n", isn1, isn1);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"mov       r%d,r0\n", retval);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"mov       $%o,r1\n", UNS(size));
+                       fprintf(temp_fp[temp_fi], /*printf(*/"L%d:mov   -(r0),-(sp)\ndec\tr1\njne\tL%d\n", isn1, isn1);
                        isn1++;
                }
                nstack++;
@@ -1237,7 +1237,7 @@ void doinit(type, tree1) register int type; register union tree1 *tree1; {
        _LONG lval;
 
        if (type==CHAR || type==UNCHAR) {
-               printf(".byte ");
+               fprintf(temp_fp[temp_fi], /*printf(*/".byte ");
                if (tree1->t.type&XTYPE)
                        goto illinit;
                type = INT;
@@ -1266,10 +1266,10 @@ void doinit(type, tree1) register int type; register union tree1 *tree1; {
                        tree1->c.value = lval;
                }
                if (tree1->t.op == CON)
-                       printf("%o\n", UNS(tree1->c.value));
+                       fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(tree1->c.value));
                else if (tree1->t.op==AMPER) {
                        pname(tree1->t.tr1, 0);
-                       putchar('\n');
+                       fputc('\n', temp_fp[temp_fi]) /*putchar('\n')*/;
                } else
                        goto illinit;
                return;
@@ -1304,25 +1304,25 @@ void doinit(type, tree1) register int type; register union tree1 *tree1; {
 #ifdef pdp11
                        sfval = fval;
 /*nonportable*/
-                       printf("%o; %o\n",
+                       fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n",
                                ((_UNSIGNED_INT *)&sfval)[0],
                                ((_UNSIGNED_INT *)&sfval)[1]);
 #else
                        sfval = fp_double_to_float(fval);
-                       printf("%o; %o\n",
+                       fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n",
                                (int)(sfval.h >> 16) & 0xffff,
                                (int)sfval.h & 0xffff);
 #endif
                } else {
 #ifdef pdp11
 /* nonportable */
-                       printf("%o; %o; %o; %o\n",
+                       fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o; %o; %o\n",
                                ((_UNSIGNED_INT *)&fval)[0],
                                ((_UNSIGNED_INT *)&fval)[1],
                                ((_UNSIGNED_INT *)&fval)[2],
                                ((_UNSIGNED_INT *)&fval)[3]);
 #else
-                       printf("%o; %o; %o; %o\n",
+                       fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o; %o; %o\n",
                                (int)(fval.h >> 16) & 0xffff,
                                (int)fval.h & 0xffff,
                                (int)(fval.l >> 16) & 0xffff,
@@ -1356,7 +1356,7 @@ void doinit(type, tree1) register int type; register union tree1 *tree1; {
                } else
                        goto illinit;
 /* nonportable */
-               printf("%o; %o\n", UNS((lval>>16)), UNS(lval));
+               fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n", UNS((lval>>16)), UNS(lval));
                return;
        }
 illinit:
@@ -1375,11 +1375,11 @@ void movreg(r0, r1, tree1) int r0; int r1; union tree1 *tree1; {
                }
                s = "mov        r%d,r%d\nmov    r%d,r%d\n";
                if (r0 < r1)
-                       printf(s, r0+1,r1+1,r0,r1);
+                       fprintf(temp_fp[temp_fi], /*printf(*/s, r0+1,r1+1,r0,r1);
                else
-                       printf(s, r0,r1,r0+1,r1+1);
+                       fprintf(temp_fp[temp_fi], /*printf(*/s, r0,r1,r0+1,r1+1);
                return;
        }
        c = isfloat(tree1);
-       printf("mov%.1s r%d,r%d\n", &c, r0, r1);
+       fprintf(temp_fp[temp_fi], /*printf(*/"mov%.1s   r%d,r%d\n", &c, r0, r1);
 }
diff --git a/c11.c b/c11.c
index b618f81..d6a6da3 100644 (file)
--- a/c11.c
+++ b/c11.c
@@ -7,14 +7,16 @@
 #include <string.h>
 #ifdef __STDC__
 #include <stdarg.h>
-#define _va_start(ap, arg) va_start(ap, arg)
+#define _va_start(argp, arg) va_start(argp, arg)
 #else
 #include <varargs.h>
-#define _va_start(ap, arg) va_start(ap)
+#define _va_start(argp, arg) va_start(argp)
 #endif
+#include "c0.h" /* for outcode() prototype as getree() changed to outcode() */
 #include "c1.h"
 
-static void outname __P((char *s));
+/*static void outname __P((char *s));*/
+static void outname __P((char *buf, char *str));
 
 int degree(t) register union tree1 *t; {
        register union tree1 *t1;
@@ -46,18 +48,18 @@ loop:
        switch(p->t.op) {
 
        case LCON:
-               printf("$%o", flag<=10? UNS(p->l.lvalue>>16):
+               fprintf(temp_fp[temp_fi], /*printf(*/"$%o", flag<=10? UNS(p->l.lvalue>>16):
                   UNS(p->l.lvalue));
                return;
 
        case SFCON:
        case CON:
-               printf("$");
+               fprintf(temp_fp[temp_fi], /*printf(*/"$");
                psoct(p->c.value);
                return;
 
        case FCON:
-               printf("L%d", (p->c.value>0? p->c.value: -p->c.value));
+               fprintf(temp_fp[temp_fi], /*printf(*/"L%d", (p->c.value>0? p->c.value: -p->c.value));
                return;
 
        case NAME:
@@ -67,7 +69,7 @@ loop:
                if (i) {
                        psoct(i);
                        if (p->n.class!=OFFS)
-                               putchar('+');
+                               fputc('+', temp_fp[temp_fi]) /*putchar('+')*/;
                        if (p->n.class==REG)
                                error1("Illegal use of register");
                }
@@ -78,7 +80,7 @@ loop:
                        pbase(p);
 
                case OFFS:
-                       printf("(r%d)", p->n.regno);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"(r%d)", p->n.regno);
                        return;
 
                case EXTERN:
@@ -87,7 +89,7 @@ loop:
                        return;
 
                case REG:
-                       printf("r%d", p->n.nloc);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"r%d", p->n.nloc);
                        return;
 
                }
@@ -95,23 +97,23 @@ loop:
                return;
 
        case AMPER:
-               putchar('$');
+               fputc('$', temp_fp[temp_fi]) /*putchar('$')*/;
                p = p->t.tr1;
                if (p->t.op==NAME && p->n.class==REG)
                        error1("Illegal use of register");
                goto loop;
 
        case AUTOI:
-               printf("(r%d)%s", p->n.nloc, flag==1?"":"+");
+               fprintf(temp_fp[temp_fi], /*printf(*/"(r%d)%s", p->n.nloc, flag==1?"":"+");
                return;
 
        case AUTOD:
-               printf("%s(r%d)", flag==2?"":"-", p->n.nloc);
+               fprintf(temp_fp[temp_fi], /*printf(*/"%s(r%d)", flag==2?"":"-", p->n.nloc);
                return;
 
        case STAR:
                p = p->t.tr1;
-               putchar('*');
+               fputc('*', temp_fp[temp_fi]) /*putchar('*')*/;
                goto loop;
 
        }
@@ -121,9 +123,9 @@ loop:
 void pbase(p) register union tree1 *p; {
 
        if (p->n.class==SOFFS || p->n.class==STATIC)
-               printf("L%d", p->n.nloc);
+               fprintf(temp_fp[temp_fi], /*printf(*/"L%d", p->n.nloc);
        else
-               printf("%s", p->x.name);
+               fprintf(temp_fp[temp_fi], /*printf(*/"%s", p->x.name);
 }
 
 int xdcalc(p, nrleft) register union tree1 *p; int nrleft; {
@@ -221,11 +223,11 @@ int prins(op, c, itable, lbl) int op; int c; struct instab *itable; int lbl; {
                        if (!ip)
                                break;
                        if (ip != jmijne) {
-                               printf(ip, lbl);
+                               fprintf(temp_fp[temp_fi], /*printf(*/ip, lbl);
                        }
                        else {
                                skip = isn1++;
-                               printf(ip, skip);
+                               fprintf(temp_fp[temp_fi], /*printf(*/ip, skip);
                        }
                        return(skip);
                }
@@ -360,7 +362,7 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab
        fp = afp;
        lp = alp;
        if (fp==lp) {
-               printf("jbr     L%d\n", deflab);
+               fprintf(temp_fp[temp_fi], /*printf(*/"jbr       L%d\n", deflab);
                return;
        }
        isn1++;
@@ -372,26 +374,26 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab
        /* direct switch */
        if (range>0 && range <= 3*ncase) {
                if (fp->swval)
-                       printf("sub     $%o,r0\n", UNS(fp->swval));
-               printf(dirsw, UNS(range), deflab, isn1, isn1);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"sub       $%o,r0\n", UNS(fp->swval));
+               fprintf(temp_fp[temp_fi], /*printf(*/dirsw, UNS(range), deflab, isn1, isn1);
                isn1++;
                for (i=fp->swval; ; i++) {
                        if (i==fp->swval) {
-                               printf("L%d\n", fp->swlab);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"L%d\n", fp->swlab);
                                if (fp==lp)
                                        break;
                                fp++;
                        } else
-                               printf("L%d\n", deflab);
+                               fprintf(temp_fp[temp_fi], /*printf(*/"L%d\n", deflab);
                }
-               printf(".text\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".text\n");
                return;
        }
        /* simple switch */
        if (ncase<10) {
                for (fp = afp; fp<=lp; fp++)
                        breq(fp->swval, fp->swlab);
-               printf("jbr     L%d\n", deflab);
+               fprintf(temp_fp[temp_fi], /*printf(*/"jbr       L%d\n", deflab);
                return;
        }
        /* hash switch */
@@ -413,13 +415,13 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab
                }
        }
        i = isn1++;
-       printf(hashsw, UNS(tabs), i, i);
+       fprintf(temp_fp[temp_fi], /*printf(*/hashsw, UNS(tabs), i, i);
        isn1++;
        for (i=0; i<tabs; i++)
-               printf("L%d\n", isn1+i);
-       printf(".text\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"L%d\n", isn1+i);
+       fprintf(temp_fp[temp_fi], /*printf(*/".text\n");
        for (i=0; i<tabs; i++) {
-               printf("L%d:", isn1++);
+               fprintf(temp_fp[temp_fi], /*printf(*/"L%d:", isn1++);
                for (swp=fp; swp<=lp; swp++) {
                        /* lrem(0, swp->swval, tabs) */
                        if ((_UNSIGNED_INT)swp->swval%tabs == i) {
@@ -427,16 +429,16 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab
                                breq((int)((_UNSIGNED_INT)swp->swval/tabs), swp->swlab);
                        }
                }
-               printf("jbr     L%d\n", deflab);
+               fprintf(temp_fp[temp_fi], /*printf(*/"jbr       L%d\n", deflab);
        }
 }
 
 void breq(v, l) int v; int l; {
        if (v==0)
-               printf("tst     r0\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"tst       r0\n");
        else
-               printf("cmp     r0,$%o\n", UNS(v));
-       printf("jeq     L%d\n", l);
+               fprintf(temp_fp[temp_fi], /*printf(*/"cmp       r0,$%o\n", UNS(v));
+       fprintf(temp_fp[temp_fi], /*printf(*/"jeq       L%d\n", l);
 }
 
 int sort(afp, alp) struct swtab *afp; struct swtab *alp; {
@@ -619,7 +621,7 @@ again:
                        op = maprel[op-EQUAL];
        }
        if (isfloat(tree1))
-               printf("cfcc\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n");
        branch1(lbl, op, !cond);
 }
 
@@ -630,13 +632,13 @@ void branch1(lbl, aop, c) int lbl; int aop; int c; {
        if(op = aop) {
                skip = prins(op, c, branchtab, lbl);
        } else {
-               printf("jbr");
+               fprintf(temp_fp[temp_fi], /*printf(*/"jbr");
                skip = 0;
        }
        if (skip)
-               printf("\tL%d\nL%d:", lbl, skip);
+               fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\nL%d:", lbl, skip);
        else
-               printf("\tL%d\n", lbl);
+               fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\n", lbl);
 }
 
 void longrel(atree, lbl, cond, reg) union tree1 *atree; int lbl; int cond; int reg; {
@@ -671,7 +673,7 @@ void longrel(atree, lbl, cond, reg) union tree1 *atree; int lbl; int cond; int r
        }
        if (cexpr(tree1, cctab, reg) < 0) {
                reg = rcexpr1(tree1, regtab, reg);
-               printf("ashc    $0,r%d\n", reg);
+               fprintf(temp_fp[temp_fi], /*printf(*/"ashc      $0,r%d\n", reg);
                branch1(xlab1, op, 0);
        }
        xlab1 = xl1;
@@ -740,7 +742,7 @@ int xlongrel(f) int f; {
 }
 
 void label1(l) int l; {
-       printf("L%d:", l);
+       fprintf(temp_fp[temp_fi], /*printf(*/"L%d:", l);
 }
 
 void popstk(a) int a; {
@@ -750,14 +752,14 @@ void popstk(a) int a; {
                return;
 
        case 2:
-               printf("tst     (sp)+\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"tst       (sp)+\n");
                return;
 
        case 4:
-               printf("cmp     (sp)+,(sp)+\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"cmp       (sp)+,(sp)+\n");
                return;
        }
-       printf("add     $%o,sp\n", UNS(a));
+       fprintf(temp_fp[temp_fi], /*printf(*/"add       $%o,sp\n", UNS(a));
 }
 
 void werror1(s) char *s; {
@@ -771,14 +773,15 @@ void error1(char *s, ...)
 void error1(s, va_alist) char *s; va_dcl
 #endif
 {
-       va_list ap;
+       va_list argp;
 
        nerror++;
        fprintf(stderr, "%d: ", line);
-       _va_start(ap, s);
-       vfprintf(stderr, s, ap);
-       va_end(ap);
+       _va_start(argp, s);
+       vfprintf(stderr, s, argp);
+       va_end(argp);
        putc('\n', stderr);
+ abort();
 }      
 
 void psoct(an) int an; {
@@ -790,7 +793,7 @@ void psoct(an) int an; {
                n = -n;
                sign = "-";
        }
-       printf("%s%o", sign, n);
+       fprintf(temp_fp[temp_fi], /*printf(*/"%s%o", sign, n);
 }
 
 /*
@@ -798,7 +801,19 @@ void psoct(an) int an; {
  */
 #define        STKS    100
 void getree() {
-       union tree1 *expstack[STKS], **sp;
+ int c;
+ while ((c = fgetc(temp_fp[temp_fi])) != 0 && c != EOF)
+  putchar(c);
+}
+#ifdef __STDC__
+void outcode(char *fmt, ...)
+#else
+void outcode(fmt, va_alist) char *fmt; va_dcl
+#endif
+{
+ va_list argp;
+ /*    union tree1 *expstack[STKS], **sp;*/
+ static union tree1 *expstack[STKS], **sp = expstack;
        register union tree1 *tp;
        register int t, op;
        char s[80];             /* big for asm() stuff & long variable names */
@@ -806,136 +821,142 @@ void getree() {
        long outloc;
        int lbl, cond, lbl2, lbl3;
 
-       curbase = funcbase;
-       sp = expstack;
-       for (;;) {
+ /*    curbase = funcbase;
+       sp = expstack;*/
+ /*    for (;;) {*/
+ _va_start(argp, fmt);
+ for (; *fmt; ++fmt)
+  if (*fmt == 'B') {
                if (sp >= &expstack[STKS])
                        error1("Stack overflow botch");
-               op = geti();
-               if ((op&0177400) != 0177000) {
+               op = va_arg(argp, int) /*geti()*/;
+ /*fprintf(stderr, "%d %d\n", op, (int)(sp - expstack));*/
+ /*            if ((op&0177400) != 0177000) {
                        error1("Intermediate file error1");
                        exit(1);
-               }
+               }*/
                lbl = 0;
                switch(op &= 0377) {
 
        case SINIT:
-               printf("%o\n", UNS(geti()));
+               fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(va_arg(argp, int) /*geti()*/));
                break;
 
        case EOFC:
+ va_end(argp);
                return;
 
        case BDATA:
-               if (geti() == 1) {
-                       printf(".byte ");
+               if (va_arg(argp, int) /*geti()*/ == 1) {
+                       fprintf(temp_fp[temp_fi], /*printf(*/".byte ");
                        for (;;)  {
-                               printf("%o", UNS(geti()));
-                               if (geti() != 1)
+                               fprintf(temp_fp[temp_fi], /*printf(*/"%o", UNS(va_arg(argp, int) /*geti()*/));
+                               if (va_arg(argp, int) /*geti()*/ != 1)
                                        break;
-                               printf(",");
+                               fprintf(temp_fp[temp_fi], /*printf(*/",");
                        }
-                       printf("\n");
+                       fprintf(temp_fp[temp_fi], /*printf(*/"\n");
                }
                break;
 
        case PROG:
-               printf(".text\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".text\n");
                break;
 
        case DATA:
-               printf(".data\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".data\n");
                break;
 
        case BSS:
-               printf(".bss\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".bss\n");
                break;
 
        case SYMDEF:
-               outname(s);
-               printf(".globl\t%s\n", s);
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/".globl\t%s\n", s);
                sfuncr.nloc = 0;
                break;
 
        case RETRN:
-               printf("jmp\tcret\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"jmp\tcret\n");
                break;
 
        case CSPACE:
-               outname(s);
-               printf(".comm\t%s,%o\n", s, UNS(geti()));
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/".comm\t%s,%o\n", s, UNS(va_arg(argp, int) /*geti()*/));
                break;
 
        case SSPACE:
-               printf(".=.+%o\n", UNS(t=geti()));
+               fprintf(temp_fp[temp_fi], /*printf(*/".=.+%o\n", UNS(t=va_arg(argp, int) /*geti()*/));
                totspace += (_UNSIGNED_INT)t;
                break;
 
        case EVEN:
-               printf(".even\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/".even\n");
                break;
 
        case SAVE:
-               printf("jsr     r5,csv\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"jsr       r5,csv\n");
                break;
 
        case SETSTK:
-               t = geti();
+               t = va_arg(argp, int) /*geti()*/;
                if (t==2)
-                       printf("tst     -(sp)\n");
+                       fprintf(temp_fp[temp_fi], /*printf(*/"tst       -(sp)\n");
                else if (t != 0)
-                       printf("sub     $%o,sp\n", UNS(t));
+                       fprintf(temp_fp[temp_fi], /*printf(*/"sub       $%o,sp\n", UNS(t));
                break;
 
        case PROFIL:
-               t = geti();
-               outname(s);
-               printf("mov     $L%d,r0\njsr    pc,mcount\n", t);
-               printf(".data\nL%d:%s+1\n.text\n", t, s);
+               t = va_arg(argp, int) /*geti()*/;
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"mov       $L%d,r0\njsr    pc,mcount\n", t);
+               fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%s+1\n.text\n", t, s);
                break;
 
        case ASSEM:
-               outname(s);
-               printf("%s\n", s);
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"%s\n", s);
                break;
 
        case SNAME:
-               outname(s);
-               printf("~%s=L%d\n", s+1, geti());
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"~%s=L%d\n", s+1, va_arg(argp, int) /*geti()*/);
                break;
 
        case ANAME:
-               outname(s);
-               printf("~%s=%o\n", s+1, UNS(geti()));
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"~%s=%o\n", s+1, UNS(va_arg(argp, int) /*geti()*/));
                break;
 
        case RNAME:
-               outname(s);
-               printf("~%s=r%d\n", s+1, geti());
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"~%s=r%d\n", s+1, va_arg(argp, int) /*geti()*/);
                break;
 
        case SWIT:
-               t = geti();
-               line = geti();
-               curbase = funcbase;
-               while(swp=(struct swtab *)getblk(sizeof(*swp)), swp->swlab = geti())
-                       swp->swval = geti();
+               t = va_arg(argp, int) /*geti()*/;
+               line = va_arg(argp, int) /*geti()*/;
+ /*            curbase = funcbase;*/
+ funcbase = locbase;
+               while(swp=(struct swtab *)getblk(sizeof(*swp)), swp->swlab = va_arg(argp, int) /*geti()*/)
+                       swp->swval = va_arg(argp, int) /*geti()*/;
                pswitch1((struct swtab *)funcbase, swp, t);
                break;
 
        case C3BRANCH:          /* for fortran [sic] */
-               lbl = geti();
-               lbl2 = geti();
-               lbl3 = geti();
+               lbl = va_arg(argp, int) /*geti()*/;
+               lbl2 = va_arg(argp, int) /*geti()*/;
+               lbl3 = va_arg(argp, int) /*geti()*/;
                goto xpr;
 
        case CBRANCH:
-               lbl = geti();
-               cond = geti();
+               lbl = va_arg(argp, int) /*geti()*/;
+               cond = va_arg(argp, int) /*geti()*/;
 
        case EXPR:
        xpr:
-               line = geti();
+               line = va_arg(argp, int) /*geti()*/;
                if (sp != &expstack[1]) {
                        error1("Expression input botch");
                        exit(1);
@@ -958,30 +979,30 @@ void getree() {
                else {
                        if (tp->t.type==LONG || tp->t.type==UNLONG) {
                                rcexpr1(tnode1(RFORCE, tp->t.type, tp, TNULL1), efftab, 0);
-                               printf("ashc    $0,r0\n");
+                               fprintf(temp_fp[temp_fi], /*printf(*/"ashc      $0,r0\n");
                        } else {
                                rcexpr1(tp, cctab, 0);
                                if (isfloat(tp))
-                                       printf("cfcc\n");
+                                       fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n");
                        }
-                       printf("jgt     L%d\n", lbl3);
-                       printf("jlt     L%d\njbr        L%d\n", lbl, lbl2);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"jgt       L%d\n", lbl3);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"jlt       L%d\njbr        L%d\n", lbl, lbl2);
                }
-               curbase = funcbase;
+ /*            curbase = funcbase;*/
                break;
 
        case NAME:
-               t = geti();
+               t = va_arg(argp, int) /*geti()*/;
                if (t==EXTERN) {
                        tp = getblk(sizeof(struct xtname));
-                       tp->t.type = geti();
-                       outname(s);
+                       tp->t.type = va_arg(argp, int) /*geti()*/;
+                       outname(s/*)*/, va_arg(argp, char *));
                        tp->x.name = (char *)getblk(strlen(s) + 1);
                        strcpy(tp->x.name, s);
                } else {
                        tp = getblk(sizeof(struct tname));
-                       tp->t.type = geti();
-                       tp->n.nloc = geti();
+                       tp->t.type = va_arg(argp, int) /*geti()*/;
+                       tp->n.nloc = va_arg(argp, int) /*geti()*/;
                }
                tp->t.op = NAME;
                tp->n.class = t;
@@ -991,14 +1012,14 @@ void getree() {
                break;
 
        case CON:
-               t = geti();
-               *sp++ = tconst(geti(), t);
+               t = va_arg(argp, int) /*geti()*/;
+               *sp++ = tconst(va_arg(argp, int) /*geti()*/, t);
                break;
 
        case LCON:
-               geti(); /* ignore type, assume long */
-               t = geti();
-               op = geti();
+               va_arg(argp, int) /*geti()*/;   /* ignore type, assume long */
+               t = va_arg(argp, int) /*geti()*/;
+               op = va_arg(argp, int) /*geti()*/;
                if (t==0 && op>=0 || t == -1 && op<0) {
                        *sp++ = tnode1(ITOL, LONG, tconst(op, INT), TNULL1);
                        break;
@@ -1011,8 +1032,8 @@ void getree() {
                break;
 
        case FCON:
-               t = geti();
-               outname(s);
+               t = va_arg(argp, int) /*geti()*/;
+               outname(s/*)*/, va_arg(argp, char *));
                tp = getblk(sizeof(struct ftconst));
                tp->t.op = FCON;
                tp->t.type = t;
@@ -1026,9 +1047,9 @@ void getree() {
                break;
 
        case FSEL:
-               tp = tnode1(FSEL, geti(), *--sp, TNULL1);
-               t = geti();
-               tp->t.tr2 = tnode1(COMMA, INT, tconst(geti(), INT), tconst(t, INT));
+               tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL1);
+               t = va_arg(argp, int) /*geti()*/;
+               tp->t.tr2 = tnode1(COMMA, INT, tconst(va_arg(argp, int) /*geti()*/, INT), tconst(t, INT));
                if (tp->t.tr2->t.tr1->c.value==16)
                        tp = paint(tp->t.tr1, tp->t.type);
                *sp++ = tp;
@@ -1037,8 +1058,8 @@ void getree() {
        case STRASG:
                tp = getblk(sizeof(struct fasgn));
                tp->t.op = STRASG;
-               tp->t.type = geti();
-               tp->F.mask = geti();
+               tp->t.type = va_arg(argp, int) /*geti()*/;
+               tp->F.mask = va_arg(argp, int) /*geti()*/;
                tp->t.tr1 = *--sp;
                tp->t.tr2 = NULL;
                *sp++ = tp;
@@ -1049,25 +1070,25 @@ void getree() {
                break;
 
        case LABEL:
-               label1(geti());
+               label1(va_arg(argp, int) /*geti()*/);
                break;
 
        case NLABEL:
-               outname(s);
-               printf("%s:\n", s);
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"%s:\n", s);
                break;
 
        case RLABEL:
-               outname(s);
-               printf("%s:\n~~%s:\n", s, s+1);
+               outname(s/*)*/, va_arg(argp, char *));
+               fprintf(temp_fp[temp_fi], /*printf(*/"%s:\n~~%s:\n", s, s+1);
                break;
 
        case BRANCH:
-               branch1(geti(), 0, 0);
+               branch1(va_arg(argp, int) /*geti()*/, 0, 0);
                break;
 
        case SETREG:
-               nreg = geti()-1;
+               nreg = va_arg(argp, int) /*geti()*/-1;
                break;
 
        default:
@@ -1078,17 +1099,19 @@ void getree() {
                        }
                        tp = *--sp;
 #if 1
-                       sp[-1] = tnode1(op, geti(), sp[-1], tp);
+                       sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], tp);
 #else
-                       *sp++ = tnode1(op, geti(), *--sp, tp);
+                       *sp++ = tnode1(op, va_arg(argp, int) /*geti()*/, *--sp, tp);
 #endif
                } else
-                       sp[-1] = tnode1(op, geti(), sp[-1], TNULL1);
+                       sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL1);
                break;
        }
        }
+ va_end(argp);
 }
 
+#if 0
 int geti() {
        register int i;
 
@@ -1101,7 +1124,15 @@ int geti() {
 #endif
        return(i);
 }
+#endif
 
+#if 1
+static void outname(buf, str) char *buf; char *str; {
+ if (*str)
+  *buf++ = '_';
+ strcpy(buf, str);
+}
+#else
 static void outname(s) register char *s; {
        register int c;
 
@@ -1113,6 +1144,7 @@ static void outname(s) register char *s; {
                *s++ = c;
        *s++ = '\0';
 }
+#endif
 
 void strasg(atp) union tree1 *atp; {
        register union tree1 *tp;
@@ -1128,12 +1160,12 @@ void strasg(atp) union tree1 *atp; {
                if (tp->t.op==RFORCE) { /* function return */
                        if (sfuncr.nloc==0) {
                                sfuncr.nloc = isn1++;
-                               printf(".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc,
+                               fprintf(temp_fp[temp_fi], /*printf(*/".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc,
                                        UNS(nwords*sizeof(_INT)));
                        }
                        atp->t.tr1 = tnode1(ASSIGN, STRUCT, (union tree1 *)&sfuncr, tp->t.tr1);
                        strasg(atp);
-                       printf("mov     $L%d,r0\n", sfuncr.nloc);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"mov       $L%d,r0\n", sfuncr.nloc);
                        return;
                }
                if (tp->t.op==CALL) {
@@ -1162,16 +1194,16 @@ void strasg(atp) union tree1 *atp; {
                rcexpr1(tp, efftab, 0);
                if (nwords < 7) {
                        for (i=0; i<nwords; i++)
-                               printf("mov     (r1)+,(r0)+\n");
+                               fprintf(temp_fp[temp_fi], /*printf(*/"mov       (r1)+,(r0)+\n");
                        return;
                }
                if (nreg<=1)
-                       printf("mov     r2,-(sp)\n");
-               printf("mov     $%o,r2\n", UNS(nwords));
-               printf("L%d:mov (r1)+,(r0)+\ndec\tr2\njne\tL%d\n", isn1, isn1);
+                       fprintf(temp_fp[temp_fi], /*printf(*/"mov       r2,-(sp)\n");
+               fprintf(temp_fp[temp_fi], /*printf(*/"mov       $%o,r2\n", UNS(nwords));
+               fprintf(temp_fp[temp_fi], /*printf(*/"L%d:mov   (r1)+,(r0)+\ndec\tr2\njne\tL%d\n", isn1, isn1);
                isn1++;
                if (nreg<=1)
-                       printf("mov     (sp)+,r2\n");
+                       fprintf(temp_fp[temp_fi], /*printf(*/"mov       (sp)+,r2\n");
                return;
        }
        rcexpr1(tp, efftab, 0);
diff --git a/c12.c b/c12.c
index 27e733c..f57613c 100644 (file)
--- a/c12.c
+++ b/c12.c
@@ -4,6 +4,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include "c0.h" /* for Tblock() which replaces getblk() in single pass mode */
 #include "c1.h"
 
 /*
@@ -1149,6 +1150,9 @@ union tree1 *tconst(val, type) int val; int type; {
 }
 
 union tree1 *getblk(size) int size; {
+#if 1
+ return (union tree1 *)Tblock(size);
+#else
        register union tree1 *p;
 
        if (size&01)
@@ -1166,6 +1170,7 @@ union tree1 *getblk(size) int size; {
                coremax += 1024;
        }
        return(p);
+#endif
 }
 
 int islong(t) int t; {
diff --git a/ccom.c b/ccom.c
index 7f62edf..5e51b9d 100644 (file)
--- a/ccom.c
+++ b/ccom.c
@@ -24,7 +24,7 @@ int main(argc, argv) int argc; char **argv; {
        for (i = 0; i < 2; ++i) {
                strcpy(temp_name, "/tmp/ccomXXXXXX");
                fd = mkstemp(temp_name);
-               if (fd == -1 || (temp_fp[i] = fdopen(fd, "w+")) == 0 || unlink(temp_name)) {
+               if (fd == -1 || (temp_fp[i] = fdopen(fd, "w+")) == 0 /*|| unlink(temp_name)*/) {
                        error0("Can't create temp: %s", temp_name);
                        exit(1);
                }
diff --git a/ccom.h b/ccom.h
index 42baf3b..617b00d 100644 (file)
--- a/ccom.h
+++ b/ccom.h
@@ -239,77 +239,17 @@ struct swtab {
 #define        STATIC  13
 #define        REG     14
 #define        STRTAG  15
-#define ARG    16              /* pass 0 only */
+#define ARG    16
 #define        ARG1    17              /* pass 0 only */
 #define        AREG    18              /* pass 0 only */
 #define        DEFXTRN 20              /* pass 0 only */
 #define        MOU     21              /* pass 0 only */
 #define        ENUMTAG 22              /* pass 0 only */
 #define        ENUMCON 24              /* pass 0 only */
-#define        ARG     16              /* pass 1 only */
 #define        OFFS    20              /* pass 1 only */
 #define        XOFFS   21              /* pass 1 only */
 #define        SOFFS   22              /* pass 1 only */
 
-/*
-  keywords
-*/
-#define        GOTO    20
-#define        RETURN  21
-#define        IF      22
-#define        WHILE   23
-#define        ELSE    24
-#define        SWITCH  25
-#define        CASE    26
-#define        BREAK   27
-#define        CONTIN  28
-#define        DO      29
-#define        DEFAULT 30
-#define        FOR     31
-#define        ENUM    32
-#define        ASM     33
-
-/*
-  characters
-*/
-#define        BSLASH  117
-#define        SHARP   118
-#define        INSERT  119
-#define        PERIOD  120
-#define        SQUOTE  121
-#define        DQUOTE  122
-#define        LETTER  123
-#define        DIGIT   124
-#define        NEWLN   125
-#define        SPACE   126
-#define        UNKN    127
-
-/*
- * Special operators in intermediate code
- */
-#define        BDATA   200
-#define        WDATA   201             /* pass 0 only */
-#define        PROG    202
-#define        DATA    203
-#define        BSS     204
-#define        CSPACE  205
-#define        SSPACE  206
-#define        SYMDEF  207
-#define        SAVE    208
-#define        RETRN   209
-#define        EVEN    210
-#define        PROFIL  212
-#define        SWIT    213
-#define        EXPR    214
-#define        SNAME   215
-#define        RNAME   216
-#define        ANAME   217
-#define        SETSTK  219
-#define        SINIT   220
-#define        GLOBAL  221             /* pass 1 only */
-#define        C3BRANCH        222             /* pass 1 only */
-#define        ASSEM   223
-
 /*
   Flag bits
 */