*.bak
*.o
-c0
-c1
+ccom
cvopt
HOSTCC=cc
INSTALL=install
-CFLAGS = -O
-LDC0FLAGS= -i
-LDC1FLAGS= -n
+CFLAGS=-Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result
+#CFLAGS = -O
+#LDC0FLAGS= -i
+#LDC1FLAGS= -n
DESTDIR =
LIB=/lib
-all: c0 c1 cvopt
-c0: c00.o c01.o c02.o c03.o c04.o c05.o
- ${CC} ${LDC0FLAGS} ${CFLAGS} -o c0 c00.o c01.o c02.o c03.o c04.o c05.o
+all: ccom cvopt
+#c0 c1 cvopt
-c00.o c01.o c02.o c03.o c04.o c05.o: c0.h
+ccom: ccom.o c00.o c01.o c02.o c03.o c04.o c05.o c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
+ ${CC} ${CFLAGS} -o ccom ccom.o c00.o c01.o c02.o c03.o c04.o c05.o c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
-c1: c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
- ${CC} ${LDC1FLAGS} ${CFLAGS} -o c1 c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
+ccom.o: c0.h c1.h ccom.h
-c10.o c11.o c12.o c13.o: c1.h
+#c0: c00.o c01.o c02.o c03.o c04.o c05.o
+# ${CC} ${LDC0FLAGS} ${CFLAGS} -o c0 c00.o c01.o c02.o c03.o c04.o c05.o
+
+c00.o c01.o c02.o c03.o c04.o c05.o: c0.h ccom.h
+
+#c1: c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
+# ${CC} ${LDC1FLAGS} ${CFLAGS} -o c1 c10.o c11.o c12.o c13.o fp.o fp_atof.o table.o
+
+c10.o c11.o c12.o c13.o: c1.h ccom.h
table.o: optable cvopt
./cvopt < optable > junk.c
#ifndef _C0_H
#define _C0_H 1
-#include <stdio.h>
#include "ccom.h"
/*
extern int nerror;
extern struct nmlist *paraml;
extern struct nmlist *parame;
+#if 0
extern int strflg;
+#endif
extern int mosflg;
extern int initflg;
+#if 0
extern char sbuf[BUFSIZ];
extern FILE *sbufp;
+#endif
extern int regvar;
extern int bitoffs;
extern struct tnode0 funcblk0;
#define FINIT 040
#define FLABL 0100
+extern struct kwtab {
+ char *kwname;
+ int kwval;
+} kwtab[];
+
#ifndef __P
#ifdef __STDC__
#define __P(args) args
int line = 1;
struct tnode0 funcblk0 = { NAME };
-struct kwtab {
- char *kwname;
- int kwval;
-} kwtab[] = {
+struct kwtab kwtab[] = {
{"int", INT},
{"char", CHAR},
{"float", FLOAT},
union tree0 **cp0 = cmst;
int Wflag; /* print warning messages */
+#if 0
int main(argc, argv) int argc; char *argv[]; {
register unsigned i;
register struct kwtab *ip;
blkend();
exit(nerror!=0);
}
+#endif
/*
* Look up the identifier in symbuf in the symbol table.
nchstr = 0;
if (lab) {
+#if 1
+ temp_fi = 1;
+#else
strflg++;
+#endif
outcode("BNB", LABEL, lab, BDATA);
max = 10000;
} else
outcode("10");
}
outcode("0");
+#if 1
+ temp_fi = 0;
+#else
strflg = 0;
+#endif
}
void cntstr() {
register char *np;
int n;
+#if 1
+ bufp = temp_fp[temp_fi];
+#else
bufp = stdout;
if (strflg)
bufp = sbufp;
+#endif
_va_start(ap, s);
for (;;) switch(*s++) {
case 'B':
int nerror;
struct nmlist *paraml;
struct nmlist *parame;
+#if 0
int strflg;
+#endif
int mosflg;
int initflg;
+#if 0
char sbuf[BUFSIZ];
FILE *sbufp;
+#endif
int regvar;
int bitoffs;
char cvntab[];
#ifndef _C1_H
#define _C1_H 1
-#include <stdio.h>
#include <setjmp.h>
#include "ccom.h"
int nreg = 3;
int isn1 = 10000;
+#if 0
int main(argc, argv) int argc; char *argv[]; {
char buf1[BUFSIZ],
buf2[BUFSIZ];
werror1("possibly too much data");
exit(nerror!=0);
}
+#endif
/*
* Given a tree1, a code table, and a
int geti() {
register int i;
+#if 1
+ i = fgetc(temp_fp[temp_fi]) & 0xff;
+ i |= (fgetc(temp_fp[temp_fi]) & 0xff) << 8;
+#else
i = getchar() & 0xff;
i |= (getchar() & 0xff) << 8;
+#endif
return(i);
}
static void outname(s) register char *s; {
register int c;
+#if 1
+ while ((c = fgetc(temp_fp[temp_fi])) != 0 && c != EOF)
+#else
while (c = getchar())
+#endif
*s++ = c;
*s++ = '\0';
}
union tree1 *unoptim(tree1) register union tree1 *tree1; {
register union tree1 *subtre, *p;
-#ifndef pdp11
- _LONG temp_long;
- uint16_t temp[2];
-#endif
if (tree1==NULL)
return(NULL);
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "c0.h"
+#include "c1.h"
+
+/* new merged main program for C compiler pass [01], makes own tempfiles */
+int temp_fi;
+FILE *temp_fp[2];
+char buf0[BUFSIZ];
+char buf1[BUFSIZ];
+char buf2[BUFSIZ];
+
+int main(argc, argv) int argc; char **argv; {
+ register unsigned i;
+ register struct kwtab *ip;
+ char temp_name[16];
+ int fd;
+
+ if (argc >= 2 && strcmp(argv[1], "-") != 0 && freopen(argv[1], "r", stdin) == 0) {
+ error0("Can't find %s", argv[1]);
+ exit(1);
+ }
+ 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)) {
+ error0("Can't create temp: %s", temp_name);
+ exit(1);
+ }
+ }
+ setbuf(stdin, buf0);
+ setbuf(temp_fp[0], buf1);
+ setbuf(temp_fp[1], buf2);
+
+ /*
+ * The hash table locations of the keywords
+ * are marked; if an identifier hashes to one of
+ * these locations, it is looked up in in the keyword
+ * table first.
+ */
+ for (ip=kwtab; ip->kwname; ip++) {
+ i = hash(ip->kwname);
+ kwhash[i/LNBPW] |= 1 << (i%LNBPW);
+ }
+ coremax = locbase = /*sbrk(0);*/ funcbase = curbase = sbrk(0);
+ temp_fi = 0;
+ while(!eof)
+ extdef();
+ outcode("B", EOFC);
+ temp_fi = 1;
+ outcode("B", EOFC);
+ blkend();
+ if (nerror)
+ exit(1);
+ fclose(stdin);
+
+ if (argc >= 3 && strcmp(argv[2], "-") != 0 && freopen(argv[2], "w", stdin) == 0) {
+ error0("Can't create %s", argv[2]);
+ exit(1);
+ }
+ setbuf(stdout, buf0);
+
+ /*funcbase = curbase = coremax = sbrk(0);*/
+ temp_fi = 0;
+ rewind(temp_fp[0]);
+ getree();
+ /*
+ * If any floating-point instructions
+ * were used, generate a reference that
+ * pulls in the floating-point part of printf.
+ */
+ if (nfloat)
+ printf(".globl fltused\n");
+ /*
+ * tack on the string file.
+ */
+ printf(".globl\n.data\n");
+ temp_fi = 1;
+ rewind(temp_fp[1]);
+ getree();
+ if (totspace >= (_UNSIGNED_INT)56000)
+ werror1("possibly too much data");
+ exit(nerror!=0);
+}
#ifndef _CCOM_H_
#define _CCOM_H_
+#include <stdio.h>
+
#ifdef pdp11
typedef int _INT;
typedef long _LONG;
#define PCVOK 040000 /* pass 0 only */
#define CNVRT 01000 /* pass 1 only */
+extern int temp_fi;
+extern FILE *temp_fp[2];
+
#endif
}
static int32_t moviffp11(val, fac) int32_t val; _DOUBLE *fac; {
- int32_t i, qdouble, leni;
+ int32_t i;
int32_t exp, sign;
- qdouble = FPS & FPS_D;
fac->l = val;
fac->h = 0;
if (fac->l) {
#!/bin/sh
-make CFLAGS=-g LDC0FLAGS= LDC1FLAGS= "$@"
+ROOT="`pwd |sed -e 's/\/lib\/ccom$//'`"
+HOSTCC="cc -g -I$ROOT/cross/usr/include -L$ROOT/cross/usr/lib/ -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+INSTALL="$ROOT/scripts/install.sh --strip-program=/bin/true"
+MANROFF="nroff -man"
+mkdir --parents "$ROOT/cross/lib"
+make CC="$HOSTCC" MANROFF="$MANROFF" LDC0FLAGS= LDC1FLAGS= PURFLAG= && \
+make INSTALL="$INSTALL" DESTDIR="$ROOT/cross" install