#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
* 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");
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);
}
}
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,
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,
*/
if ((c = *string++) & 0200) {
c &= 0177;
- putchar('\t');
+ fputc('\t', temp_fp[temp_fi]) /*putchar('\t')*/;
}
switch (c) {
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);
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;
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;
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) {
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 */
case ASPLUS:
case INCBEF:
case INCAFT:
- printf("adc");
+ fprintf(temp_fp[temp_fi], /*printf(*/"adc");
break;
case MINUS:
case NEG:
case DECBEF:
case DECAFT:
- printf("sbc");
+ fprintf(temp_fp[temp_fi], /*printf(*/"sbc");
break;
case ASSIGN:
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:
* 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;
/*
return(reg);
goto loop;
}
- putchar(c);
+ fputc(c, temp_fp[temp_fi]) /*putchar(c)*/;
goto loop;
}
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++;
_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;
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;
#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,
} 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:
}
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);
}
#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;
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:
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");
}
pbase(p);
case OFFS:
- printf("(r%d)", p->n.regno);
+ fprintf(temp_fp[temp_fi], /*printf(*/"(r%d)", p->n.regno);
return;
case EXTERN:
return;
case REG:
- printf("r%d", p->n.nloc);
+ fprintf(temp_fp[temp_fi], /*printf(*/"r%d", p->n.nloc);
return;
}
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;
}
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; {
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);
}
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++;
/* 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 */
}
}
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) {
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; {
op = maprel[op-EQUAL];
}
if (isfloat(tree1))
- printf("cfcc\n");
+ fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n");
branch1(lbl, op, !cond);
}
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; {
}
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;
}
void label1(l) int l; {
- printf("L%d:", l);
+ fprintf(temp_fp[temp_fi], /*printf(*/"L%d:", l);
}
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; {
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; {
n = -n;
sign = "-";
}
- printf("%s%o", sign, n);
+ fprintf(temp_fp[temp_fi], /*printf(*/"%s%o", sign, n);
}
/*
*/
#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 */
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);
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;
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;
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;
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;
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;
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:
}
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;
#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;
*s++ = c;
*s++ = '\0';
}
+#endif
void strasg(atp) union tree1 *atp; {
register union tree1 *tp;
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) {
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);