Tidy up C compiler by introducing _(UNSIGNED_)(INT|LONG) types to handle host differe...
authorNick Downing <downing.nick@gmail.com>
Thu, 5 Jan 2017 11:06:33 +0000 (22:06 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 5 Jan 2017 11:06:33 +0000 (22:06 +1100)
22 files changed:
bin/cc/Makefile
bin/cc/n.sh
bin/ld/Makefile
bin/ld/n.sh
games/Makefile
lib/c2/Makefile
lib/ccom/Makefile
lib/ccom/c0.h
lib/ccom/c01.c
lib/ccom/c04.c
lib/ccom/c05.c
lib/ccom/c1.h
lib/ccom/c10.c
lib/ccom/c11.c
lib/ccom/c12.c
lib/ccom/n.sh
lib/cpp/Makefile
lib/cpp/n.sh
n.sh
ucb/strcompact/Makefile
ucb/strcompact/n.sh
ucb/strcompact/strcompact.c

index 5138f2d..f27fa7d 100644 (file)
@@ -2,7 +2,7 @@
 # makefile for cc
 #
 
-CFLAGS=-DCROSSDIR="\"${CROSSDIR}\"" -DSTAGEDIR="\"${STAGEDIR}\""
+CFLAGS=-DCROSSDIR="${CROSSDIR}" -DSTAGEDIR="${STAGEDIR}"
 SEPFLAG=-i
 
 all: cc
index bc05bc0..c1003ac 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/bin\/cc$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
-make CC="$CC" CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" SEPFLAG= && \
+make CC="$CC" CROSSDIR="\\\"$ROOT/cross\\\"" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 71a7224..0eff576 100644 (file)
@@ -8,7 +8,7 @@ OBJS=ld.o ../../lib/libc/pdp/gen/nsym.o
 MAN=ld.0
 MANSRC=ld.1
 
-CFLAGS=-O -I../ar -DSTAGEDIR="\"${STAGEDIR}\"" -DNUM_VM_PAGES=20
+CFLAGS=-O -I../ar -DSTAGEDIR="${STAGEDIR}" -DNUM_VM_PAGES=20
 SEPFLAG=-i
 
 all:   ld ld.0
index 9952878..630bd46 100755 (executable)
@@ -3,5 +3,5 @@ ROOT="`pwd |sed -e 's/\/bin\/ld$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/bin"
 mkdir --parents "$ROOT/cross/usr/man/cat1"
-make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib" && \
+make CC="$CC" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib" && \
 make DESTDIR="$ROOT/cross" install
index fb80a85..af6e5cd 100644 (file)
@@ -92,104 +92,6 @@ worms:
 
 # DO NOT DELETE THIS LINE -- make depend uses it
 
-arithmetic: arithmetic.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-arithmetic: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-banner: banner.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-bcd: bcd.c
-cfscores: cfscores.c /home/nick/src/211bsd.git/stage/usr/include/pwd.h
-factor: factor.c
-fish: fish.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-morse: morse.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-morse: /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-number: number.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-ppt: ppt.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-wump: wump.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-canfield: canfield.c /home/nick/src/211bsd.git/stage/usr/include/curses.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/select.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
-primes: primes.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-primes: /home/nick/src/211bsd.git/stage/usr/include/math.h
-rain: rain.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-worm: worm.c /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/curses.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-worms: worms.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-arithmetic: arithmetic.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-arithmetic: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-banner: banner.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-bcd: bcd.c
-cfscores: cfscores.c /home/nick/src/211bsd.git/stage/usr/include/pwd.h
-factor: factor.c
-fish: fish.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-morse: morse.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-morse: /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-number: number.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-ppt: ppt.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-wump: wump.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-wump: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-canfield: canfield.c /home/nick/src/211bsd.git/stage/usr/include/curses.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/select.h
-canfield: /home/nick/src/211bsd.git/stage/usr/include/sys/types.h
-primes: primes.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-primes: /home/nick/src/211bsd.git/stage/usr/include/math.h
-rain: rain.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-rain: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-worm: worm.c /home/nick/src/211bsd.git/stage/usr/include/ctype.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/curses.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-worm: /home/nick/src/211bsd.git/stage/usr/include/signal.h
-worms: worms.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sgtty.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ioctl.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ttychars.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/sys/ttydev.h
-worms: /home/nick/src/211bsd.git/stage/usr/include/signal.h
 arithmetic: arithmetic.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
 arithmetic: /home/nick/src/211bsd.git/stage/usr/include/signal.h
 banner: banner.c /home/nick/src/211bsd.git/stage/usr/include/stdio.h
index abc8f7c..0c701f4 100644 (file)
@@ -5,7 +5,7 @@ DESTDIR=
 LIB=   /lib
 
 c2: c20.o c21.o
-       cc ${CFLAGS} ${SEPFLAG} -o c2 c20.o c21.o
+       ${CC} ${CFLAGS} ${SEPFLAG} -o c2 c20.o c21.o
 
 c20.o c21.o: c2.h
 
index 118a554..8234ebf 100644 (file)
@@ -2,7 +2,7 @@ CFLAGS = -O
 LDC0FLAGS= -i
 LDC1FLAGS= -n
 # this is used for cvopt:
-PURFLAG=-n
+#PURFLAG=-n
 
 DESTDIR =
 LIB=/lib
@@ -22,17 +22,19 @@ table.o: optable cvopt
        ./cvopt < optable > junk.c
        ${CC} -S junk.c
        sed 's/\.data/\.text/' < junk.s > junk.i
-       as -o table.o junk.i
+       ${AS} -o table.o junk.i
        rm -f junk.i junk.c junk.s
 
+# for cross compiling, to access the host compiler we use cc not ${CC}
 cvopt: cvopt.c
-       ${CC} ${PURFLAG} -s -O -o cvopt cvopt.c
+       cc ${PURFLAG} -s -O -o cvopt cvopt.c
 
 install: c0 c1
        -mv ${DESTDIR}${LIB}/c0 ${DESTDIR}${LIB}/oc0
        -mv ${DESTDIR}${LIB}/c1 ${DESTDIR}${LIB}/oc1
        install -s c0 ${DESTDIR}${LIB}/c0
-       install -s c1 ${DESTDIR}${LIB}/c1
+#      install -s c1 ${DESTDIR}${LIB}/c1
+       install c1 ${DESTDIR}${LIB}/c1
 
 restore:
        mv ${DESTDIR}${LIB}/oc0 ${DESTDIR}${LIB}/c0
index b31ecc7..9afc3fd 100644 (file)
@@ -5,10 +5,22 @@
 #ifndef _C0_H
 #define _C0_H 1
 
-#include <stdint.h>
 #include <stdio.h>
 #include "krcompat.h"
 
+#ifdef pdp11
+#define _INT int
+#define _LONG long
+#define _UNSIGNED_INT unsigned int
+#define _UNSIGNED_LONG unsigned long
+#else
+#include <stdint.h>
+#define _INT int16_t
+#define _LONG int32_t
+#define _UNSIGNED_INT uint16_t
+#define _UNSIGNED_LONG uint32_t
+#endif
+
 /*
  * This parameter is the _only_ one which affects the recognized length
  * of symbols.  Symbol names are dynamically allocated and null terminated
@@ -24,7 +36,6 @@
 
 #define        MAXCPS  32      /* # chars per symbol */
 
-#define        LTYPE   long    /* change to int if no long consts */
 #define        MAXINT  077777  /* Largest positive short integer */
 #define        MAXUINT 0177777 /* largest unsigned integer */
 #define        HSHSIZ  300     /* # entries in hash table for names */
@@ -50,6 +61,7 @@ int   STAUTO;
 #define MAXPATHLEN 1024
 #endif
 
+
 /*
  * # bytes in primitive types
  */
@@ -203,7 +215,7 @@ extern struct nmlist *funcsym;
 extern int proflg;
 extern struct nmlist *csym;
 extern int cval;
-extern LTYPE lcval;
+extern _LONG lcval;
 extern int nchstr;
 extern int nerror;
 extern struct nmlist *paraml;
index ff10e7b..4e287b8 100644 (file)
@@ -577,10 +577,10 @@ union tree *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str *
        register union tree *p;
 
  /*fprintf(stderr, "block(%d, %d, {%d, %d}, {%d, %d})\n", op, t,
-   (op == NAME) ? -2 : (p1 ? (int)(int16_t)p1->t.op : -1),
-   (op == NAME) ? -2 : (p1 ? (int)(int16_t)p1->t.type : -1),
-   (op == FSEL) ? -3 : (p2 ? (int)(int16_t)p2->t.op : -1),
-   (op == FSEL) ? -3 : (p2 ? (int)(int16_t)p2->t.type : -1));*/
+   (op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.op : -1),
+   (op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.type : -1),
+   (op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.op : -1),
+   (op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.type : -1));*/
        p = (union tree *)Tblock(sizeof(struct tnode));
        p->t.op = op;
        p->t.type = t;
@@ -766,10 +766,10 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
                        if (v2==1)
                                break;
                        if (v2<0) {
-                               v1 = (uint16_t)v1 >= (uint16_t)v2;
+                               v1 = (_UNSIGNED_INT)v1 >= (_UNSIGNED_INT)v2;
                                break;
                        }
-                       v1 = (uint16_t)v1 / v2;
+                       v1 = (_UNSIGNED_INT)v1 / v2;
                        break;
                }
                v1 /= v2;
@@ -784,11 +784,11 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
                                break;
                        }
                        if (v2<0) {
-                               if ((uint16_t)v1 >= (uint16_t)v2)
+                               if ((_UNSIGNED_INT)v1 >= (_UNSIGNED_INT)v2)
                                        v1 -= v2;
                                break;
                        }
-                       v1 = (uint16_t)v1 % v2;
+                       v1 = (_UNSIGNED_INT)v1 % v2;
                        break;
                }
                v1 %= v2;
@@ -820,7 +820,7 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
 
        case RSHIFT:
                if (unsignf) {
-                       v1 = (uint16_t)v1 >> v2;
+                       v1 = (_UNSIGNED_INT)v1 >> v2;
                        break;
                }
                v1 >>= v2;
@@ -851,19 +851,19 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
                break;
 
        case LESSP:
-               v1 = (uint16_t)v1<v2;
+               v1 = (_UNSIGNED_INT)v1<v2;
                break;
 
        case GREATP:
-               v1 = (uint16_t)v1>v2;
+               v1 = (_UNSIGNED_INT)v1>v2;
                break;
 
        case LESSEQP:
-               v1 = (uint16_t)v1<=v2;
+               v1 = (_UNSIGNED_INT)v1<=v2;
                break;
 
        case GREATQP:
-               v1 = (uint16_t)v1>=v2;
+               v1 = (_UNSIGNED_INT)v1>=v2;
                break;
 
        divchk:
index 99818f0..1feb70c 100644 (file)
@@ -77,8 +77,8 @@ void treeout(tp, isstruct) register union tree *tp; int isstruct; {
                break;
 
        case LCON:
-               outcode("BNNN", tp->l.op, tp->l.type, (uint16_t)(tp->l.lvalue>>16),
-                  (uint16_t)tp->l.lvalue);
+               outcode("BNNN", tp->l.op, tp->l.type, (_UNSIGNED_INT)(tp->l.lvalue>>16),
+                  (_UNSIGNED_INT)tp->l.lvalue);
                break;
 
        case CON:
@@ -214,7 +214,7 @@ int length(cs) union tree *cs; {
                return(0);
        }
        n *= elsz;
-       if (n >= (uint16_t)50000)
+       if (n >= (_UNSIGNED_INT)50000)
                werror("very large data structure");
        return(n);
 }
index 0b9ae94..5cf663b 100644 (file)
@@ -228,7 +228,7 @@ struct      nmlist  *funcsym;
 int    proflg;
 struct nmlist  *csym;
 int    cval;
-LTYPE  lcval;
+_LONG  lcval;
 int    nchstr;
 int    nerror;
 struct nmlist *paraml;
index 6d7d5e6..49a20d5 100644 (file)
@@ -5,12 +5,23 @@
 #ifndef _C1_H
 #define _C1_H 1
 
-#include <stdint.h>
 #include <stdio.h>
 #include <setjmp.h>
 #include "krcompat.h"
 
-#define        LTYPE   long    /* change to int for no long consts */
+#ifdef pdp11
+#define _INT int
+#define _LONG long
+#define _UNSIGNED_INT unsigned int
+#define _UNSIGNED_LONG unsigned long
+#else
+#include <stdint.h>
+#define _INT int16_t
+#define _LONG int32_t
+#define _UNSIGNED_INT uint16_t
+#define _UNSIGNED_LONG uint32_t
+#endif
+
 #ifndef NULL
 #define        NULL    0
 #endif
@@ -58,7 +69,7 @@ struct        xtname {
 struct tconst {
        int     op;
        int     type;
-       int16_t value;
+       _INT    value;
 };
 
 /*
@@ -67,11 +78,7 @@ struct       tconst {
 struct lconst {
        int     op;
        int     type;
-#if pdp11
-       LTYPE   lvalue;
-#else
-       uint16_t lvalue[2];
-#endif
+       _LONG   lvalue;
 };
 
 /*
@@ -528,7 +535,7 @@ union tree *acommute PARAMS((register union tree *tree));
 int sideeffects PARAMS((register union tree *tp));
 void distrib PARAMS((struct acl *list));
 void squash PARAMS((union tree **p, union tree **maxp));
-void _const PARAMS((int op, register int16_t *vp, int v, int type));
+void _const PARAMS((int op, register _INT *vp, _INT v, int type));
 union tree *lconst PARAMS((int op, register union tree *lp, register union tree *rp));
 void insert PARAMS((int op, register union tree *tree, register struct acl *list));
 union tree *tnode PARAMS((int op, int type, union tree *tr1, union tree *tr2));
@@ -538,7 +545,7 @@ int islong PARAMS((int t));
 union tree *isconstant PARAMS((register union tree *t));
 union tree *hardlongs PARAMS((register union tree *t));
 int uns PARAMS((union tree *tp));
-/* c13.c */
+#ifndef pdp11
 /* pdp11_atof.c */
 void pdp11_atof PARAMS((char *p));
 /* pdp11_fp.c */
@@ -562,5 +569,6 @@ void pdp11_divf PARAMS((int ac, uint16_t *va, int dstspec));
 int32_t fpnotrap PARAMS((int32_t code));
 /* pdp11_ldexp.c */
 void pdp11_ldexp PARAMS((uint16_t *value, int exp));
+#endif
 
 #endif
index 78ed26a..4f90a9a 100644 (file)
@@ -75,7 +75,7 @@ int main(argc, argv) int argc; char *argv[]; {
                setbuf(stdin,buf1);     /* sbrk problems */
                getree();
        }
-       if (totspace >= (uint16_t)56000)
+       if (totspace >= (_UNSIGNED_INT)56000)
                werror("possibly too much data");
        exit(nerror!=0);
 }
@@ -567,37 +567,39 @@ int cexpr(tree, table, areg) register union tree *tree; struct table *table; int
        string = opt->tabstring;
        p1 = tree->t.tr1;
        if (p1->t.op==FCON && p1->f.value>0) {
-#if 1
+#ifdef pdp11
+/* nonportable */
                printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
-                       p1->f.fvalue[0], p1->f.fvalue[1],
-                       p1->f.fvalue[2], p1->f.fvalue[3]);
-               p1->f.value = -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
-/* nonportable */
                printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p1->f.value,
-                       ((uint16_t *)&(p1->f.fvalue))[0],
-                       ((uint16_t *)&(p1->f.fvalue))[1],
-                       ((uint16_t *)&(p1->f.fvalue))[2],
-                       ((uint16_t *)&(p1->f.fvalue))[3]);
-/* this did not cause problems because c.value is overlaid on f.value */
-               p1->c.value = -p1->c.value;
+                       p1->f.fvalue[0],
+                       p1->f.fvalue[1],
+                       p1->f.fvalue[2],
+                       p1->f.fvalue[3] );
 #endif
+               p1->f/*c*/.value = -p1->f/*c*/.value;
        }
        p2 = 0;
        if (opdope[tree->t.op]&BINARY) {
                p2 = tree->t.tr2;
                if (p2->t.op==FCON && p2->f.value>0) {
-#if 1
+#ifdef pdp11
+/* nonportable */
                        printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
-                               p2->f.fvalue[0], p2->f.fvalue[1],
-                               p2->f.fvalue[2], p2->f.fvalue[3]);
+                               ((_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
-/* nonportable */
                        printf(".data\nL%d:%o;%o;%o;%o\n.text\n", p2->f.value,
-                               ((uint16_t *)&(p2->f.fvalue))[0],
-                               ((uint16_t *)&(p2->f.fvalue))[1],
-                               ((uint16_t *)&(p2->f.fvalue))[2],
-                               ((uint16_t *)&(p2->f.fvalue))[3]);
+                               p2->f.fvalue[0],
+                               p2->f.fvalue[1],
+                               p2->f.fvalue[2],
+                               p2->f.fvalue[3] );
 #endif
                        p2->f.value = -p2->f.value;
                }
@@ -1174,11 +1176,11 @@ int comarg(tree, flagp) register union tree *tree; int *flagp; {
                size = tree->F.mask;
                tree = tree->t.tr1;
                tree = strfunc(tree);
-               if (size <= sizeof(int16_t)) {
+               if (size <= sizeof(_INT)) {
                        paint(tree, INT);
                        goto normal;
                }
-               if (size <= sizeof(int32_t)) {
+               if (size <= sizeof(_LONG)) {
                        paint(tree, LONG);
                        goto normal;
                }
@@ -1227,16 +1229,15 @@ union tree *strfunc(tp) register union tree *tp; {
  * Compile an initializing expression
  */
 void doinit(type, tree) register int type; register union tree *tree; {
-#if 1
-       uint16_t sfval[2];
-       uint16_t fval[4];
-       uint16_t lval[2];
-       int16_t sign;
-#else
+#ifdef pdp11
        float sfval;
        double fval;
-       int32_t lval;
+#else
+       uint16_t temp[2];
+       uint16_t sfval[2];
+       uint16_t fval[4];
 #endif
+       _LONG lval;
 
        if (type==CHAR || type==UNCHAR) {
                printf(".byte ");
@@ -1253,39 +1254,23 @@ void doinit(type, tree) register int type; register union tree *tree; {
                        if (tree->t.tr1->t.op!=FCON && tree->t.tr1->t.op!=SFCON)
                                goto illinit;
                        tree = tree->t.tr1;
-#if 1
 #ifdef pdp11
-                       tree->c.value = *(double *)tree->f.fvalue;
+                       tree->c.value = tree->f.fvalue;
 #else
                        /* movf 6(r3),r0 */
                        pdp11_ldf(0, tree->f.fvalue, 063);
                        /* movfi r0, 4(r3) */
-                       pdp11_movfi(0, (uint16_t *)&tree->c.value, 063);
-#endif
-#else
-                       tree->c.value = tree->f.fvalue;
+                       pdp11_movfi(0, temp, 063);
+                       tree->c.value = (int16_t)temp[0];
 #endif
                        tree->t.op = CON;
                } else if (tree->t.op==LTOI) {
                        if (tree->t.tr1->t.op!=LCON)
                                goto illinit;
                        tree = tree->t.tr1;
-#if 1
-#ifdef pdp11
-                       *(int32_t *)lval = *(int32_t *)tree->l.lvalue;
-#else
-                       lval[0] = tree->l.lvalue[0];
-                       lval[1] = tree->l.lvalue[1];
-#endif
-#else
                        lval = tree->l.lvalue;
-#endif
                        tree->t.op = CON;
-#if 1
-                       tree->c.value = lval[1];
-#else
                        tree->c.value = lval;
-#endif
                }
                if (tree->t.op == CON)
                        printf("%o\n", UNS(tree->c.value));
@@ -1300,82 +1285,76 @@ void doinit(type, tree) register int type; register union tree *tree; {
        case FLOAT:
                if (tree->t.op==ITOF) {
                        if (tree->t.tr1->t.op==CON) {
-#if 1 /* note: this should be changed to respect the signedness of the int */
+/* note: this should be changed to respect the signedness of the int */
 #ifdef pdp11
-                               *(double *)fval = tree->t.tr1->c.value;
+                               fval = tree->t.tr1->c.value;
 #else
                                /* movif 4(r0),r0 */
-                               pdp11_movif(0, (uint16_t *)&tree->t.tr1->c.value,
-                                       060);
-#endif
-#else
-                               fval = tree->t.tr1->c.value;
+                               temp[0] = (uint16_t)tree->t.tr1->c.value;
+                               pdp11_movif(0, temp, 060);
+                               /* movf r0,-24(r5) */
+                               pdp11_stf(0, fval, 065);
 #endif
                        } else
                                goto illinit;
                } else if (tree->t.op==FCON || tree->t.op==SFCON) {
-#if 1
 #ifdef pdp11
-                       *(double *)fval = *(double *)tree->f.fvalue;
+                       fval = tree->f.fvalue;
 #else
                        /* movf 6(r3),r0 */
                        pdp11_ldf(0, tree->f.fvalue, 063);
-#endif
-#else
-                       fval = tree->f.fvalue;
+                       /* movf r0,-24(r5) */
+                       pdp11_stf(0, fval, 065);
 #endif
                } else if (tree->t.op==LTOF) {
                        if (tree->t.tr1->t.op!=LCON)
                                goto illinit;
-#if 1 /* note: this should be changed to respect the signedness of the long */
+/* note: this should be changed to respect the signedness of the long */
 #ifdef pdp11
-                       *(double *)fval = *(long *)tree->t.tr1->l.lvalue;
+                       fval = tree->t.tr1->l.lvalue;
 #else
                        /* setl */
                        pdp11_setl();
                        /* movif 4(r0),r0 */
-                       pdp11_movif(0, tree->t.tr1->l.lvalue, 060);
+                       temp[0] = (uint16_t)((tree->t.tr1->l.lvalue >> 16) & 0xffff);
+                       temp[1] = (uint16_t)(tree->t.tr1->l.lvalue & 0xffff);
+                       pdp11_movif(0, temp, 060);
                        /* seti */
                        pdp11_seti();
-#endif
-#else
-                       fval = tree->t.tr1->l.lvalue;
+                       /* movf r0,-24(r5) */
+                       pdp11_stf(0, fval, 065);
 #endif
                } else
                        goto illinit;
-#if 1
-#ifndef PDP11
-               /* movf r0,-24(r5) */
-               pdp11_stf(0, fval, 065);
-#endif
-#endif
+               /* note: value is still in emulated r0 and used again below */
                if (type==FLOAT) {
-#if 1
 #ifdef pdp11
-                       *(float *)sfval = *(double *)fval;
+                       sfval = fval;
+/*nonportable*/
+                       printf("%o; %o\n",
+                               ((_UNSIGNED_INT *)&sfval)[0],
+                               ((_UNSIGNED_INT *)&sfval)[1]);
 #else
                        /* movfo r0,-14(r5) */
                        pdp11_stcfo(0, sfval, 065);
-#endif
-                       printf("%o; %o\n", sfval[0], sfval[1]);
-#else
-                       sfval = fval;
-/*nonportable*/
                        printf("%o; %o\n",
-                               ((uint16_t *)&sfval)[0],
-                               ((uint16_t *)&sfval)[1]);
+                               sfval[0],
+                               sfval[1]);
 #endif
                } else {
-#if 1
+#ifdef pdp11
+/* nonportable */
                        printf("%o; %o; %o; %o\n",
-                               fval[0], fval[1], fval[2], fval[3]);
+                               ((_UNSIGNED_INT *)&fval)[0],
+                               ((_UNSIGNED_INT *)&fval)[1],
+                               ((_UNSIGNED_INT *)&fval)[2],
+                               ((_UNSIGNED_INT *)&fval)[3]);
 #else
-/* nonportable */
                        printf("%o; %o; %o; %o\n",
-                               ((uint16_t *)&fval)[0],
-                               ((uint16_t *)&fval)[1],
-                               ((uint16_t *)&fval)[2],
-                               ((uint16_t *)&fval)[3]);
+                               fval[0],
+                               fval[1],
+                               fval[2],
+                               fval[3]);
 #endif
                }
                return;
@@ -1388,63 +1367,32 @@ void doinit(type, tree) register int type; register union tree *tree; {
                                tree->t.op = FCON;
                        if (tree->t.op!= FCON)
                                goto illinit;
-#if 1
 #ifdef pdp11
-                       *(int32_t *)lval = *(double *)tree->f.fvalue;
+                       lval = tree->f.fvalue;
 #else
                        /* movf 6(r3),r0 */
                        pdp11_ldf(0, tree->f.fvalue, 063);
                        /* setl */
                        pdp11_setl();
                        /* movfi r0,-30(r5) */
-                       pdp11_movfi(0, lval, 065);
+                       pdp11_movfi(0, temp, 065);
+                       lval = ((temp[0] & 0xffffL) << 16) | (temp[1] & 0xffffL);
                        /* seti */
                        pdp11_seti();
-#endif
-#else
-                       lval = tree->f.fvalue;
 #endif
                } else if (tree->t.op==ITOL) {
                        if (tree->t.tr1->t.op != CON)
                                goto illinit;
-#if 1
-#ifdef pdp11
-                       if (uns(tree->t.tr1))
-                               *(int32_t *)lval = (uint16_t)
-                                       tree->t.tr1->c.value;
-                       else
-                               *(int32_t *)lval = tree->t.tr1->c.value;
-#else
-                       sign = uns(tree->t.tr1) ?
-                               0 : (tree->t.tr1->c.value < 0);
-                       lval[1] = tree->t.tr1->c.value;
-                       lval[0] = -sign;
-#endif
-#else
                        if (uns(tree->t.tr1))
-                               lval = (uint16_t)tree->t.tr1->c.value;
+                               lval = (_UNSIGNED_INT)tree->t.tr1->c.value;
                        else
                                lval = tree->t.tr1->c.value;
-#endif
                } else if (tree->t.op==LCON) {
-#if 1
-#ifdef pdp11
-                       *(int32_t *)lval = *(int32_t *)tree->l.lvalue;
-#else
-                       lval[0] = tree->l.lvalue[0];
-                       lval[1] = tree->l.lvalue[1];
-#endif
-#else
                        lval = tree->l.lvalue;
-#endif
                } else
                        goto illinit;
 /* nonportable */
-#if 1
-               printf("%o; %o\n", lval[0], lval[1]);
-#else
                printf("%o; %o\n", UNS((lval>>16)), UNS(lval));
-#endif
                return;
        }
 illinit:
index c017d5c..9252e0d 100644 (file)
@@ -39,12 +39,8 @@ loop:
        switch(p->t.op) {
 
        case LCON:
-#if 1
-               printf("$%o", p->l.lvalue[(flag<=10) ? 0 : 1]);
-#else
                printf("$%o", flag<=10? UNS(p->l.lvalue>>16):
                   UNS(p->l.lvalue));
-#endif
                return;
 
        case SFCON:
@@ -399,7 +395,7 @@ void pswitch(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab;
                        poctab[j] = 0;
                for (swp=fp; swp<=lp; swp++)
                        /* lrem(0, swp->swval, i) */
-                       poctab[(uint16_t)swp->swval%i]++;
+                       poctab[(_UNSIGNED_INT)swp->swval%i]++;
                worst = 0;
                for (j=0; j<i; j++)
                        if (poctab[j]>worst)
@@ -419,9 +415,9 @@ void pswitch(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab;
                printf("L%d:", isn++);
                for (swp=fp; swp<=lp; swp++) {
                        /* lrem(0, swp->swval, tabs) */
-                       if ((uint16_t)swp->swval%tabs == i) {
+                       if ((_UNSIGNED_INT)swp->swval%tabs == i) {
                                /* ldiv(0, swp->swval, tabs) */
-                               breq((int)((uint16_t)swp->swval/tabs), swp->swlab);
+                               breq((int)((_UNSIGNED_INT)swp->swval/tabs), swp->swlab);
                        }
                }
                printf("jbr     L%d\n", deflab);
@@ -865,7 +861,7 @@ void getree() {
 
        case SSPACE:
                printf(".=.+%o\n", UNS(t=geti()));
-               totspace += (uint16_t)t;
+               totspace += (_UNSIGNED_INT)t;
                break;
 
        case EVEN:
@@ -1003,12 +999,7 @@ void getree() {
                tp = getblk(sizeof(struct lconst));
                tp->t.op = LCON;
                tp->t.type = LONG;
-#if 1
-               tp->l.lvalue[0] = t;
-               tp->l.lvalue[1] = op;
-#else
-               tp->l.lvalue = ((int32_t)t<<16) + UNS(op); /* nonportable */
-#endif
+               tp->l.lvalue = ((_LONG)t<<16) + UNS(op); /* nonportable */
                *sp++ = tp;
                break;
 
@@ -1020,7 +1011,7 @@ void getree() {
                tp->t.type = t;
                tp->f.value = isn++;
 #ifdef pdp11
-               *(long *)tp->f.fvalue = atof(s);
+               tp->f.fvalue = atof(s);
 #else
                pdp11_atof(s);
                /* movf r0,6(r4) */
@@ -1094,7 +1085,7 @@ void getree() {
 }
 
 int geti() {
-       register int16_t i;
+       register int i;
 
        i = getchar() & 0xff;
        i |= (getchar() & 0xff) << 8;
@@ -1113,7 +1104,7 @@ void strasg(atp) union tree *atp; {
        register union tree *tp;
        register int nwords, i;
 
-       nwords = atp->F.mask/sizeof(int16_t);
+       nwords = atp->F.mask/sizeof(_INT);
        tp = atp->t.tr1;
        while (tp->t.op == SEQNC) {
                rcexpr(tp->t.tr1, efftab, 0);
@@ -1124,7 +1115,7 @@ void strasg(atp) union tree *atp; {
                        if (sfuncr.nloc==0) {
                                sfuncr.nloc = isn++;
                                printf(".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc,
-                                       UNS(nwords*sizeof(int16_t)));
+                                       UNS(nwords*sizeof(_INT)));
                        }
                        atp->t.tr1 = tnode(ASSIGN, STRUCT, (union tree *)&sfuncr, tp->t.tr1);
                        strasg(atp);
@@ -1141,7 +1132,7 @@ void strasg(atp) union tree *atp; {
        tp->t.tr2 = strfunc(tp->t.tr2);
        if (nwords==1)
                paint(tp, INT);
-       else if (nwords==sizeof(int16_t))
+       else if (nwords==sizeof(_INT))
                paint(tp, LONG);
        else {
                if (tp->t.tr1->t.op!=NAME && tp->t.tr1->t.op!=STAR
@@ -1181,7 +1172,7 @@ int decref(t) register int t; {
                error("Illegal indirection");
                return(t);
        }
-       return(((uint16_t)t>>TYLEN) & ~TYPE | t&TYPE);
+       return(((_UNSIGNED_INT)t>>TYLEN) & ~TYPE | t&TYPE);
 }
 
 /*
index 27d7c93..011cd7c 100644 (file)
@@ -10,9 +10,8 @@ union tree *optim(tree) register union tree *tree; {
        register int op, dope;
        int d1, d2;
        union tree *t;
-#if 0
-/* nonportable */
-       union { double dv; int16_t iv[4];} fp11;
+#ifdef pdp11
+       union { double dv; _INT iv[4];} fp11;
 #endif
 
        if (tree==NULL)
@@ -27,15 +26,7 @@ union tree *optim(tree) register union tree *tree; {
        dope = opdope[op];
        if ((dope&LEAF) != 0) {
                if (op==FCON) {
-#if 1
-                       if (tree->f.fvalue[1]==0
-                        && tree->f.fvalue[2]==0
-                        && tree->f.fvalue[3]==0) {
-                               tree->t.op = SFCON;
-                               tree->f.value = tree->f.fvalue[0];
-                       }
-#else
-/* nonportable */
+#ifdef pdp11
                        fp11.dv = tree->f.fvalue;
                        if (fp11.iv[1]==0
                         && fp11.iv[2]==0
@@ -43,6 +34,14 @@ union tree *optim(tree) register union tree *tree; {
                                tree->t.op = SFCON;
                                tree->f.value = fp11.iv[0];
                        }
+#else
+                       if (tree->f.fvalue[1]==0
+                        && tree->f.fvalue[2]==0
+                        && tree->f.fvalue[3]==0) {
+                               tree->t.op = SFCON;
+                               /* I am 99% sure this is wrong (can only affect label numbering): */
+                               tree->f.value = tree->f.fvalue[0];
+                       }
 #endif
                }
                return(tree);
@@ -76,18 +75,11 @@ union tree *optim(tree) register union tree *tree; {
 
        case MINUS:
                if ((t = isconstant(tree->t.tr2)) && (!uns(t) || tree->t.type!=LONG)
-                && (t->t.type!=INT || t->c.value!=(int16_t)0100000)) {
+                && (t->t.type!=INT || t->c.value!=(_INT)0100000)) {
                        tree->t.op = PLUS;
                        if (t->t.type==DOUBLE) {
-#if 1
-                               if (t->f.value)
-                                       t->f.value ^= 0100000;
-#else
-/* this did not cause problems because f.value is overlaid on c.value */
-/* this should have been checking for f.value == 0 to preserve clean zeros */
                                /* PDP-11 FP representation */
-                               t->c.value ^= 0100000;
-#endif
+                               abort(); /* I am 99% sure this is wrong: t->c.value ^= 0100000; */
                        } else
                                t->c.value = -t->c.value;
                }
@@ -315,11 +307,9 @@ union tree *optim(tree) register union tree *tree; {
 
 union tree *unoptim(tree) register union tree *tree; {
        register union tree *subtre, *p;
-#if 1
-#ifndef PDP11
-       int16_t sign;
+#ifndef pdp11
+       _LONG temp_long;
        uint16_t temp[2];
-#endif
 #endif
 
        if (tree==NULL)
@@ -344,17 +334,7 @@ union tree *unoptim(tree) register union tree *tree; {
                        subtre = getblk(sizeof(struct lconst));
                        subtre->t.op = LCON;
                        subtre->t.type = LONG;
-#if 1
-#ifdef pdp11
-                       *(int32_t *)subtre->l.lvalue = tree->t.tr1->c.value;
-#else
-                       sign = (tree->t.tr1->c.value < 0);
-                       subtre->l.lvalue[1] = tree->t.tr1->c.value;
-                       subtre->l.lvalue[0] = -sign;
-#endif
-#else
                        subtre->l.lvalue = tree->t.tr1->c.value;
-#endif
                        return(subtre);
                }
                break;
@@ -372,23 +352,20 @@ union tree *unoptim(tree) register union tree *tree; {
                        tree = getblk(sizeof(struct ftconst));
                        tree->t.op = FCON;
                        tree->t.type = DOUBLE;
-                       tree->c.value = isn++;
-#if 1
+                       tree->f/*c*/.value = isn++;
 #ifdef pdp11
-                       *(double *)tree->f.fvalue =
-                               *(int32_t *)subtre->l.lvalue;
+                       tree->f.fvalue = subtre->l.lvalue;
 #else
                        /* setl */
                        pdp11_setl();
                        /* movif 4(r3),r0 */
-                       pdp11_movif(0, subtre->l.lvalue, 063);
+                       temp[0] = (uint16_t)((subtre->l.lvalue >> 16) & 0xffff);
+                       temp[1] = (uint16_t)(subtre->l.lvalue & 0xffff);
+                       pdp11_movif(0, temp, 063);
                        /* seti */
                        pdp11_seti();
                        /* movf r0,6(r4) */
                        pdp11_stf(0, tree->f.fvalue, 064);
-#endif
-#else
-                       tree->f.fvalue = subtre->l.lvalue;
 #endif
                        return(optim(tree));
                }
@@ -402,17 +379,18 @@ union tree *unoptim(tree) register union tree *tree; {
                        tree->t.op = FCON;
                        tree->t.type = DOUBLE;
                        tree->f.value = isn++;
-#if 1
 #ifdef pdp11
                        if (uns(subtre))
-                               *(double *)tree->f.fvalue =
-                                       (uint16_t)subtre->c.value;
+                               tree->f.fvalue = (_UNSIGNED_INT)subtre->c.value;
                        else
-                               *(double *)tree->f.fvalue = subtre->c.value;
+                               tree->f.fvalue = subtre->c.value;
 #else
-                       sign = uns(subtre) ? 0 : (subtre->c.value < 0);
-                       temp[1] = subtre->c.value;
-                       temp[0] = -sign;
+                       if (uns(subtre))
+                               temp_long = (_UNSIGNED_INT)subtre->c.value;
+                       else
+                               temp_long = subtre->c.value;
+                       temp[0] = (uint16_t)((temp_long >> 16) & 0xffff);
+                       temp[1] = (uint16_t)(temp_long & 0xffff);
                        /* setl */
                        pdp11_setl();
                        /* movif (sp)+,r0 */
@@ -421,12 +399,6 @@ union tree *unoptim(tree) register union tree *tree; {
                        pdp11_seti();
                        /* movf r0,6(r4) */
                        pdp11_stf(0, tree->f.fvalue, 064);
-#endif
-#else
-                       if (uns(subtre))
-                               tree->f.fvalue = (uint16_t)subtre->c.value;
-                       else
-                               tree->f.fvalue = subtre->c.value;
 #endif
                        return(optim(tree));
                }
@@ -459,15 +431,7 @@ union tree *unoptim(tree) register union tree *tree; {
                case LCON:
                        subtre->t.op = CON;
                        subtre->t.type = tree->t.type;
-#if 1
-#ifdef pdp11
-                       subtre->c.value = *(int32_t *)subtre->l.lvalue;
-#else
-                       subtre->c.value = subtre->l.lvalue[1];
-#endif
-#else
                        subtre->c.value = subtre->l.lvalue;
-#endif
                        return(subtre);
 
                case NAME:
@@ -601,17 +565,7 @@ union tree *unoptim(tree) register union tree *tree; {
                        return(paint(subtre, tree->t.type));
                }
                if (subtre->t.op==LCON) {
-#if 1
-#ifdef pdp11
-                       *(int32_t *)subtre->l.lvalue =
-                               ~*(int32_t *)subtre->l.lvalue;
-#else
-                       subtre->l.lvalue[0] = ~subtre->l.lvalue[0];
-                       subtre->l.lvalue[1] = ~subtre->l.lvalue[1];
-#endif
-#else
                        subtre->l.lvalue = ~subtre->l.lvalue;
-#endif
                        return(subtre);
                }
                if (subtre->t.op==ITOL) {
@@ -619,30 +573,12 @@ union tree *unoptim(tree) register union tree *tree; {
                                tree = getblk(sizeof(struct lconst));
                                tree->t.op = LCON;
                                tree->t.type = LONG;
-#if 1
-#ifdef pdp11
-                               if (uns(subtre->t.tr1)) {
-                                       *(int32_t *)tree->l.lvalue =
-                                               ~(int32_t)(uint16_t)
-                                               subtre->t.tr1->c.value;
-                               } else {
-                                       *(int32_t *)tree->l.lvalue =
-                                               ~subtre->t.tr1->c.value;
-                               }
-#else
-                               sign = uns(subtre->t.tr1) ?
-                                       0 : (subtre->t.tr1->c.value < 0);
-                               tree->l.lvalue[1] = ~subtre->t.tr1->c.value;
-                               tree->l.lvalue[0] = ~-sign;
-#endif
-#else
                                if (uns(subtre->t.tr1))
-                                       tree->l.lvalue = ~(int32_t)(uint16_t)
+                                       tree->l.lvalue = ~(_LONG)(_UNSIGNED_INT)
                                                subtre->t.tr1->c.value;
                                else
                                        tree->l.lvalue =
                                                ~subtre->t.tr1->c.value;
-#endif
                                return(tree);
                        }
                        if (uns(subtre->t.tr1))
@@ -664,83 +600,37 @@ union tree *unoptim(tree) register union tree *tree; {
                        return(paint(subtre, tree->t.type));
                }
                if (subtre->t.op==LCON) {
-#if 1
-#ifdef pdp11
-                       *(int32_t *)subtre->l.lvalue =
-                               -*(int32_t *)subtre->l.lvalue;
-#else
-                       subtre->l.lvalue[1] = -subtre->l.lvalue[1];
-                       subtre->l.lvalue[0] = ~subtre->l.lvalue[0];
-                       if (subtre->l.lvalue[1] == 0)
-                               subtre->l.lvalue[0]++;
-#endif
-#else
                        subtre->l.lvalue = -subtre->l.lvalue;
-#endif
                        return(subtre);
                }
                if (subtre->t.op==ITOL && subtre->t.tr1->t.op==CON) {
                        tree = getblk(sizeof(struct lconst));
                        tree->t.op = LCON;
                        tree->t.type = LONG;
-#if 1
-#ifdef pdp11
-                       if (uns(subtre->t.tr1)) {
-                               *(int32_t *)tree->l.lvalue =
-                                       -(int32_t)(uint16_t)
-                                       subtre->t.tr1->c.value;
-                       } else {
-                               *(int32_t *)tree->l.lvalue =
-                                       -subtre->t.tr1->c.value;
-                       }
-#else
-                       sign = uns(subtre->t.tr1) ?
-                               0 : (subtre->t.tr1->c.value < 0);
-                       tree->l.lvalue[1] = -subtre->t.tr1->c.value;
-                       tree->l.lvalue[0] = ~-sign;
-                       if (tree->l.lvalue[1] == 0)
-                               tree->l.lvalue[0]++;
-#endif
-#else
                        if (uns(subtre->t.tr1))
-                               tree->l.lvalue = -(int32_t)(uint16_t)
+                               tree->l.lvalue = -(_LONG)(_UNSIGNED_INT)
                                        subtre->t.tr1->c.value;
                        else
                                tree->l.lvalue = -subtre->t.tr1->c.value;
-#endif
                        return(tree);
                }
                /*
                 * PDP-11 FP negation
                 */
                if (subtre->t.op==SFCON) {
-#if 1
-                       if (subtre->f.value)
-                               subtre->f.value ^= 0100000;
+                       abort(); /* I am 99% sure this is wrong: subtre->c.value ^= 0100000; */
 #ifdef pdp11
-                       *(double *)subtre->f.fvalue =
-                               -*(double *)subtre->f.fvalue;
+                       subtre->f.fvalue = -subtre->f.fvalue;
 #else
                        pdp11_negf(subtre->f.fvalue, 065);
-#endif
-#else
-/* this did not cause problems because f.value is overlaid on c.value */
-/* this should have been checking for f.value == 0 to preserve clean zeros */
-                       subtre->c.value ^= 0100000;
-                       subtre->f.fvalue = -subtre->f.fvalue;
 #endif
                        return(subtre);
                }
                if (subtre->t.op==FCON) {
-#if 1
 #ifdef pdp11
-                       *(double *)subtre->f.fvalue =
-                               -*(double *)subtre->f.fvalue;
+                       subtre->f.fvalue = -subtre->f.fvalue;
 #else
                        pdp11_negf(subtre->f.fvalue, 065);
-#endif
-#else
-                       subtre->f.fvalue = -subtre->f.fvalue;
 #endif
                        return(subtre);
                }
@@ -842,12 +732,7 @@ union tree *acommute(tree) register union tree *tree; {
        if (op==PLUS || op==OR) {
                /* toss out "+0" */
                if (acl.nextl>0 && ((t1 = isconstant(*t2)) && t1->c.value==0
-#if 1
-                || (*t2)->t.op==LCON
-                && ((*t2)->l.lvalue[0]==0 && (*t2)->l.lvalue[1]==0))) {
-#else
                 || (*t2)->t.op==LCON && (*t2)->l.lvalue==0)) {
-#endif
                        acl.nextl--;
                        t2--;
                }
@@ -1028,11 +913,11 @@ void squash(p, maxp) union tree **p; union tree **maxp; {
                *np = *(np+1);
 }
 
-void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; int type; {
+void _const(op, vp, v, type) int op; register _INT *vp; register _INT v; int type; {
        switch (op) {
 
        case PTOI:
-               (*vp) /= (uint16_t)v;
+               (*vp) /= (_UNSIGNED_INT)v;
                return;
 
        case PLUS:
@@ -1064,14 +949,14 @@ void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; i
                        if (op==UDIV || op==DIVIDE) {
                                if (v==1)
                                        return;
-                               *vp = *(uint16_t *)vp >= (uint16_t)v;
+                               *vp = *(_UNSIGNED_INT *)vp >= (_UNSIGNED_INT)v;
                                return;
                        } else {
                                if (v==1) {
                                        *vp = 0;
                                        return;
                                }
-                               if (*(uint16_t *)vp >= (uint16_t)v)
+                               if (*(_UNSIGNED_INT *)vp >= (_UNSIGNED_INT)v)
                                        *vp -= v;
                                return;
                        }
@@ -1086,9 +971,9 @@ void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; i
                                        *vp %= v;
                        else
                                if (op==DIVIDE || op==UDIV)
-                                       *(uint16_t *)vp /= (uint16_t)v;
+                                       *(_UNSIGNED_INT *)vp /= (_UNSIGNED_INT)v;
                                else
-                                       *(uint16_t *)vp %= (uint16_t)v;
+                                       *(_UNSIGNED_INT *)vp %= (_UNSIGNED_INT)v;
                        return;
 
        case RSHIFT:
@@ -1100,7 +985,7 @@ void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; i
                if (type==INT)
                        *vp >>= v;
                else
-                       *(uint16_t *)vp >>= (uint16_t)v;
+                       *(_UNSIGNED_INT *)vp >>= (_UNSIGNED_INT)v;
                return;
 
        case ULSH:
@@ -1115,7 +1000,7 @@ void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; i
                if (type==INT)
                        *vp <<= v;
                else
-                       *(uint16_t *)vp <<= (uint16_t)v;
+                       *(_UNSIGNED_INT *)vp <<= (_UNSIGNED_INT)v;
                return;
 
        case ANDN:
@@ -1126,42 +1011,24 @@ void _const(op, vp, v, type) int op; register int16_t *vp; register int16_t v; i
 }
 
 union tree *lconst(op, lp, rp) int op; register union tree *lp; register union tree *rp; {
-       uint32_t l, r;
+       _UNSIGNED_LONG l, r;
 
        if (lp->t.op==LCON)
-#if 1
-#ifdef pdp11
-               l = *(int32_t *)lp->l.lvalue;
-#else
-               l = ((int32_t)lp->l.lvalue[0] << 16) |
-                       (int32_t)lp->l.lvalue[1];
-#endif
-#else
                l = lp->l.lvalue;
-#endif
        else if (lp->t.op==ITOL && lp->t.tr1->t.op==CON) {
                if (lp->t.tr1->t.type==INT)
                        l = lp->t.tr1->c.value;
                else
-                       l = (uint16_t)lp->t.tr1->c.value;
+                       l = (_UNSIGNED_INT)lp->t.tr1->c.value;
        } else
                return(0);
        if (rp->t.op==LCON)
-#if 1
-#ifdef pdp11
-               r = *(int32_t *)rp->l.lvalue;
-#else
-               r = ((int32_t)rp->l.lvalue[0] << 16) |
-                       (int32_t)rp->l.lvalue[1];
-#endif
-#else
                r = rp->l.lvalue;
-#endif
        else if (rp->t.op==ITOL && rp->t.tr1->t.op==CON) {
                if (rp->t.tr1->t.type==INT)
                        r = rp->t.tr1->c.value;
                else
-                       r = (uint16_t)rp->t.tr1->c.value;
+                       r = (_UNSIGNED_INT)rp->t.tr1->c.value;
        } else
                return(0);
        switch (op) {
@@ -1222,19 +1089,6 @@ union tree *lconst(op, lp, rp) int op; register union tree *lp; register union t
        default:
                return(0);
        }
-#if 1
-       if (lp->t.op!=LCON) {
-               lp = getblk(sizeof(struct lconst));
-               lp->t.op = LCON;
-               lp->t.type = LONG;
-       }
-#ifdef pdp11
-       *(int32_t *)lp->l.lvalue = l;
-#else
-       lp->l.lvalue[0] = (uint16_t)((l >> 16) & 0177777);
-       lp->l.lvalue[1] = (uint16_t)(l & 0177777);
-#endif
-#else
        if (lp->t.op==LCON) {
                lp->l.lvalue = l;
                return(lp);
@@ -1243,7 +1097,6 @@ union tree *lconst(op, lp, rp) int op; register union tree *lp; register union t
        lp->t.op = LCON;
        lp->t.type = LONG;
        lp->l.lvalue = l;
-#endif
        return(lp);
 }
 
index f923d8b..f6aa47d 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 ROOT="`pwd |sed -e 's/\/lib\/ccom$//'`"
-CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
+CC="cc -g -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/lib"
 make CC="$CC" LDC0FLAGS= LDC1FLAGS= PURFLAG= && \
 make DESTDIR="$ROOT/cross" install
index 998bed4..48350f9 100644 (file)
@@ -1,7 +1,7 @@
 #      Makefile        1.3     (2.11BSD) 96/7/11
 #
 
-CFLAGS=-O -DSTAGEDIR="\"${STAGEDIR}\"" -DFLEXNAMES -DTARGET_unix -DTARGET_pdp11 -DTARGET_BSD2_11
+CFLAGS=-O -DSTAGEDIR="${STAGEDIR}" -DFLEXNAMES -DTARGET_unix -DTARGET_pdp11 -DTARGET_BSD2_11
 SEPFLAG=-i
 
 cpp:   cpp.o y.tab.o
index 41a1255..46726a8 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/lib\/cpp$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/lib"
-make CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= && \
+make CC="$CC" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG= && \
 make DESTDIR="$ROOT/cross" install
diff --git a/n.sh b/n.sh
index c596376..3ee2276 100755 (executable)
--- a/n.sh
+++ b/n.sh
@@ -25,13 +25,13 @@ make -C usr.lib/libvmf DESTDIR="$ROOT/cross" install
 make -C bin CC="$CC" SEPFLAG= size
 make -C bin/ar CC="$CC" SEPFLAG=
 make -C bin/as CC="$CC" SEPFLAG=
-make -C bin/cc CC="$CC" CROSSDIR="$ROOT/cross" STAGEDIR="$ROOT/stage" SEPFLAG=
-make -C bin/ld CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib"
+make -C bin/cc CC="$CC" CROSSDIR="\\\"$ROOT/cross\\\"" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG=
+make -C bin/ld CC="$CC" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG= LDFLAGS="-L$ROOT/cross/usr/lib"
 make -C bin/nm CC="$CC" SEPFLAG=
 make -C lib/c2 CC="$CC" SEPFLAG=
 make -C lib/ccom CC="$CC" LDC0FLAGS= LDC1FLAGS= PURFLAG=
-make -C lib/cpp CC="$CC" STAGEDIR="$ROOT/stage" SEPFLAG=
-make -C ucb/strcompact CC="$CC" SEPFLAG= CROSSDIR="$ROOT/cross" LOCALE="LC_ALL=C "
+make -C lib/cpp CC="$CC" STAGEDIR="\\\"$ROOT/stage\\\"" SEPFLAG=
+make -C ucb/strcompact CC="$CC" SEPFLAG= CROSSDIR="\\\"$ROOT/cross\\\"" LOCALESTR="\\\"LC_ALL=C \\\""
 make -C ucb/symcompact CC="$CC" SEPFLAG=
 make -C ucb/symdump CC="$CC" SEPFLAG=
 make -C ucb/symorder CC="$CC" SEPFLAG=
index ec8dd53..72f1651 100644 (file)
@@ -6,7 +6,7 @@
 SRCS=strcompact.c ../../lib/libc/pdp/gen/nsym.c
 OBJS=strcompact.o ../../lib/libc/pdp/gen/nsym.o
 
-CFLAGS=-O -DCROSSDIR="\"${CROSSDIR}\"" -DLOCALE="\"${LOCALE}\""
+CFLAGS=-O -DCROSSDIR="${CROSSDIR}" -DLOCALESTR="${LOCALESTR}"
 SEPFLAG=-i
 
 all:   strcompact
index fc1b2fd..d478489 100755 (executable)
@@ -2,5 +2,5 @@
 ROOT="`pwd |sed -e 's/\/ucb\/strcompact$//'`"
 CC="cc -Iinclude -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-format -Wno-maybe-uninitialized -Wno-parentheses -Wno-unused-result"
 mkdir --parents "$ROOT/cross/usr/ucb"
-make CC="$CC" SEPFLAG= CROSSDIR="$ROOT/cross" LOCALE="LC_ALL=C " && \
+make CC="$CC" SEPFLAG= CROSSDIR="\\\"$ROOT/cross\\\"" LOCALESTR="\\\"LC_ALL=C \\\"" && \
 make DESTDIR="$ROOT/cross" install
index 4bd89e1..08d48cb 100644 (file)
@@ -47,7 +47,7 @@
 #endif
 
        char    *Pgm;
-       char    *Sort = LOCALE "/usr/bin/sort";
+       char    *Sort = LOCALESTR "/usr/bin/sort";
        char    *Symdump = CROSSDIR "/usr/ucb/symdump";
 static char    strfn[32], symfn[32];