BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / pascal / src / put.c
index 41b2c1b..551bdb4 100644 (file)
@@ -1,6 +1,39 @@
-/* Copyright (c) 1979 Regents of the University of California */
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 
-static char sccsid[] = "@(#)put.c 1.11 %G%";
+#ifndef lint
+static char sccsid[] = "@(#)put.c      5.4 (Berkeley) 4/16/91";
+#endif /* not lint */
 
 #include "whoami.h"
 #include "opcode.h"
 
 #include "whoami.h"
 #include "opcode.h"
@@ -8,9 +41,10 @@ static char sccsid[] = "@(#)put.c 1.11 %G%";
 #include "objfmt.h"
 #ifdef PC
 #   include    "pc.h"
 #include "objfmt.h"
 #ifdef PC
 #   include    "pc.h"
-#endif PC
-
-short  *obufp  = obuf;
+#   include    "align.h"
+#else
+    short      *obufp  = obuf;
+#endif
 
 /*
  * If DEBUG is defined, include the table
 
 /*
  * If DEBUG is defined, include the table
@@ -20,19 +54,24 @@ short       *obufp  = obuf;
 #include "OPnames.h"
 #endif
 
 #include "OPnames.h"
 #endif
 
+char showit[] = "'x'";
+
 #ifdef OBJ
 /*
  * Put is responsible for the interpreter equivalent of code
  * generation.  Since the interpreter is specifically designed
  * for Pascal, little work is required here.
 #ifdef OBJ
 /*
  * Put is responsible for the interpreter equivalent of code
  * generation.  Since the interpreter is specifically designed
  * for Pascal, little work is required here.
+ *
+ * FIXME, this should be converted to use <varargs.h> or <stdarg.h>.
  */
  */
+/*VARARGS*/
 put(a)
 {
        register int *p, i;
        register char *cp;
        register short *sp;
        register long *lp;
 put(a)
 {
        register int *p, i;
        register char *cp;
        register short *sp;
        register long *lp;
-       int n, subop, suboppr, op, oldlc, w;
+       int n, subop, suboppr, op, oldlc;
        char *string;
        static int casewrd;
 
        char *string;
        static int casewrd;
 
@@ -44,8 +83,8 @@ put(a)
         * relational operators could be used
         * etc.
         */
         * relational operators could be used
         * etc.
         */
-       oldlc = lc;
-       if (cgenflg < 0)
+       oldlc = (int) lc; /* its either this or change put to return a char * */
+       if ( !CGENNING )
                /*
                 * code disabled - do nothing
                 */
                /*
                 * code disabled - do nothing
                 */
@@ -67,29 +106,52 @@ put(a)
                        break;
                case O_AS:
                        switch(p[1]) {
                        break;
                case O_AS:
                        switch(p[1]) {
+                       case 0:
+                               break;
                        case 2:
                                op = O_AS2;
                        case 2:
                                op = O_AS2;
+                               n = 1;
                                break;
                        case 4:
                                op = O_AS4;
                                break;
                        case 4:
                                op = O_AS4;
+                               n = 1;
                                break;
                        case 8:
                                op = O_AS8;
                                break;
                        case 8:
                                op = O_AS8;
+                               n = 1;
                                break;
                        default:
                                goto pack;
                        }
                                break;
                        default:
                                goto pack;
                        }
-                       n = 1;
 #                      ifdef DEBUG
                                cp = otext[op];
 #                      endif DEBUG
                        break;
 #                      ifdef DEBUG
                                cp = otext[op];
 #                      endif DEBUG
                        break;
+               case O_FOR1U:
+               case O_FOR2U:
+               case O_FOR4U:
+               case O_FOR1D:
+               case O_FOR2D:
+               case O_FOR4D:
+                       /* relative addressing */
+                       p[1] -= ( unsigned ) lc + sizeof(short);
+                       /* try to pack the jump */
+                       if (p[1] <= 127 && p[1] >= -128) {
+                               suboppr = subop = p[1];
+                               p++;
+                               n--;
+                       } else {
+                               /* have to allow for extra displacement */
+                               p[1] -= sizeof(short);
+                       }
+                       break;
                case O_CONG:
                case O_LVCON:
                case O_CON:
                case O_LINO:
                case O_NEW:
                case O_DISPOSE:
                case O_CONG:
                case O_LVCON:
                case O_CON:
                case O_LINO:
                case O_NEW:
                case O_DISPOSE:
+               case O_DFDISP:
                case O_IND:
                case O_OFF:
                case O_INX2:
                case O_IND:
                case O_OFF:
                case O_INX2:
@@ -124,7 +186,7 @@ put(a)
                case O_CON2:
                case O_CON24:
                pack:
                case O_CON2:
                case O_CON24:
                pack:
-                       if (p[1] < 128 && p[1] >= -128) {
+                       if (p[1] <= 127 && p[1] >= -128) {
                                suboppr = subop = p[1];
                                p++;
                                n--;
                                suboppr = subop = p[1];
                                p++;
                                n--;
@@ -144,11 +206,11 @@ put(a)
                        break;
                case O_CON8:
                    {
                        break;
                case O_CON8:
                    {
-                       short   *sp = &p[1];
+                       short   *sp = (short *) (&p[1]);
 
 #ifdef DEBUG
                        if ( opt( 'k' ) )
 
 #ifdef DEBUG
                        if ( opt( 'k' ) )
-                           printf ( ")#%5d\tCON8\t%22.14e\n" ,
+                           printf ( "%5d\tCON8\t%22.14e\n" ,
                                        lc - HEADER_BYTES ,
                                        * ( ( double * ) &p[1] ) );
 #endif
                                        lc - HEADER_BYTES ,
                                        * ( ( double * ) &p[1] ) );
 #endif
@@ -181,16 +243,9 @@ put(a)
                        /* relative addressing */
                        p[1] -= ( unsigned ) lc + sizeof(short);
                        break;
                        /* relative addressing */
                        p[1] -= ( unsigned ) lc + sizeof(short);
                        break;
-               case O_FOR1U:
-               case O_FOR2U:
-               case O_FOR1D:
-               case O_FOR2D:
-                       /* relative addressing */
-                       p[3] -= ( unsigned ) lc + 3 * sizeof(short);
-                       break;
                case O_CONC:
 #ifdef DEBUG
                case O_CONC:
 #ifdef DEBUG
-                       (string = "'x'")[1] = p[1];
+                       (string = showit)[1] = p[1];
 #endif
                        suboppr = 0;
                        op = O_CON1;
 #endif
                        suboppr = 0;
                        op = O_CON1;
@@ -201,7 +256,7 @@ put(a)
                        goto around;
                case O_CONC4:
 #ifdef DEBUG
                        goto around;
                case O_CONC4:
 #ifdef DEBUG
-                       (string = "'x'")[1] = p[1];
+                       (string = showit)[1] = p[1];
 #endif
                        suboppr = 0;
                        op = O_CON14;
 #endif
                        suboppr = 0;
                        op = O_CON14;
@@ -225,7 +280,7 @@ around:
                case O_CASE1:
 #ifdef DEBUG
                        if (opt('k'))
                case O_CASE1:
 #ifdef DEBUG
                        if (opt('k'))
-                               printf(")#%5d\tCASE1\t%d\n"
+                               printf("%5d\tCASE1\t%d\n"
                                        , lc - HEADER_BYTES, p[1]);
 #endif
                        /*
                                        , lc - HEADER_BYTES, p[1]);
 #endif
                        /*
@@ -252,33 +307,30 @@ around:
                case O_CASE2:
 #ifdef DEBUG
                        if (opt('k'))
                case O_CASE2:
 #ifdef DEBUG
                        if (opt('k'))
-                               printf(")#%5d\tCASE2\t%d\n"
+                               printf("%5d\tCASE2\t%d\n"
                                        , lc - HEADER_BYTES , p[1]);
 #endif
                        word(p[1]);
                        return (oldlc);
                                        , lc - HEADER_BYTES , p[1]);
 #endif
                        word(p[1]);
                        return (oldlc);
-               case O_FCALL:
-                       lp = (long *)&p[1];
-                       if (*lp == 0)
-                               goto longgen;
-                       /* and fall through */
                case O_PUSH:
                        lp = (long *)&p[1];
                        if (*lp == 0)
                                return (oldlc);
                case O_PUSH:
                        lp = (long *)&p[1];
                        if (*lp == 0)
                                return (oldlc);
-                       if (*lp < 128 && *lp >= -128) {
+                       /* and fall through */
+               case O_RANG4:
+               case O_RANG24:
+               case O_RSNG4:
+               case O_RSNG24:
+               case O_SUCC4:
+               case O_PRED4:
+                       /* sub opcode optimization */
+                       lp = (long *)&p[1];
+                       if (*lp < 128 && *lp >= -128 && *lp != 0) {
                                suboppr = subop = *lp;
                                suboppr = subop = *lp;
-                               p++;
+                               p += (sizeof(long) / sizeof(int));
                                n--;
                                n--;
-                               break;
                        }
                        goto longgen;
                        }
                        goto longgen;
-               case O_FOR4U:
-               case O_FOR4D:
-                       /* relative addressing */
-                       p[1 + 2 * (sizeof(long) / sizeof(int))] -=
-                           (unsigned)lc + (sizeof(short) + 2 * sizeof(long));
-                       goto longgen;
                case O_TRA4:
                case O_CALL:
                case O_FSAV:
                case O_TRA4:
                case O_CALL:
                case O_FSAV:
@@ -327,26 +379,26 @@ around:
                case O_NODUMP:
                case O_CON4:
                case O_CASE4:
                case O_NODUMP:
                case O_CON4:
                case O_CASE4:
-               case O_RANG4:
-               case O_RANG24:
-               case O_RSNG4:
-               case O_RSNG24:
-               case O_SUCC4:
-               case O_PRED4:
                longgen:
                        n = (n << 1) - 1;
                longgen:
                        n = (n << 1) - 1;
-                       if ( op == O_LRV || op == O_FOR4U || op == O_FOR4D)
+                       if ( op == O_LRV ) {
                                n--;
                                n--;
+#                              if defined(ADDR32) && !defined(DEC11)
+                                   p[n / 2] <<= 16;
+#                              endif
+                       }
 #ifdef DEBUG
                        if (opt('k')) {
 #ifdef DEBUG
                        if (opt('k')) {
-                               printf(")#%5d\t%s", lc - HEADER_BYTES, cp+1);
+                               printf("%5d\t%s", lc - HEADER_BYTES, cp+1);
                                if (suboppr)
                                        printf(":%d", suboppr);
                                for ( i = 2, lp = (long *)&p[1]; i < n 
                                    ; i += sizeof ( long )/sizeof ( short ) )
                                        printf( "\t%D " , *lp ++ );
                                if (suboppr)
                                        printf(":%d", suboppr);
                                for ( i = 2, lp = (long *)&p[1]; i < n 
                                    ; i += sizeof ( long )/sizeof ( short ) )
                                        printf( "\t%D " , *lp ++ );
-                               if (i == n) 
-                                       printf( "\t%d ", p[i - 1] );
+                               if (i == n) {
+                                       sp = (short *)lp;
+                                       printf( "\t%d ", *sp );
+                               }
                                pchr ( '\n' );
                        }
 #endif
                                pchr ( '\n' );
                        }
 #endif
@@ -362,7 +414,7 @@ around:
        }
 #ifdef DEBUG
        if (opt('k')) {
        }
 #ifdef DEBUG
        if (opt('k')) {
-               printf(")#%5d\t%s", lc - HEADER_BYTES, cp+1);
+               printf("%5d\t%s", lc - HEADER_BYTES, cp+1);
                if (suboppr)
                        printf(":%d", suboppr);
                if (string)
                if (suboppr)
                        printf(":%d", suboppr);
                if (string)
@@ -397,11 +449,14 @@ listnames(ap)
        register struct nl *ap;
 {
        struct nl *next;
        register struct nl *ap;
 {
        struct nl *next;
-       register int oldlc, len;
+#ifdef OBJ
+       register int oldlc;
+#endif
+       register int len;
        register unsigned w;
        register char *strptr;
 
        register unsigned w;
        register char *strptr;
 
-       if (cgenflg < 0)
+       if ( !CGENNING )
                /* code is off - do nothing */
                return(NIL);
        if (ap->class != TYPE)
                /* code is off - do nothing */
                return(NIL);
        if (ap->class != TYPE)
@@ -411,21 +466,21 @@ listnames(ap)
                return( ap -> value[ NL_ELABEL ] );
        }
 #      ifdef OBJ
                return( ap -> value[ NL_ELABEL ] );
        }
 #      ifdef OBJ
-           oldlc = lc;
-           put(2, O_TRA, lc);
-           ap->value[ NL_ELABEL ] = lc;
+           oldlc = (int) lc; /* same problem as put */
+           (void) put(2, O_TRA, lc);
+           ap->value[ NL_ELABEL ] = (int) lc;
 #      endif OBJ
 #      ifdef PC
 #      endif OBJ
 #      ifdef PC
-           putprintf( "        .data" , 0 );
-           putprintf( "        .align 1" , 0 );
-           ap -> value[ NL_ELABEL ] = getlab();
-           putlab( ap -> value[ NL_ELABEL ] );
+           putprintf(" .data", 0);
+           aligndot(A_STRUCT);
+           ap -> value[ NL_ELABEL ] = (int) getlab();
+           (void) putlab((char *) ap -> value[ NL_ELABEL ] );
 #      endif PC
        /* number of scalars */
        next = ap->type;
        len = next->range[1]-next->range[0]+1;
 #      ifdef OBJ
 #      endif PC
        /* number of scalars */
        next = ap->type;
        len = next->range[1]-next->range[0]+1;
 #      ifdef OBJ
-           put(2, O_CASE2, len);
+           (void) put(2, O_CASE2, len);
 #      endif OBJ
 #      ifdef PC
            putprintf( "        .word %d" , 0 , len );
 #      endif OBJ
 #      ifdef PC
            putprintf( "        .word %d" , 0 , len );
@@ -433,7 +488,7 @@ listnames(ap)
        /* offsets of each scalar name */
        len = (len+1)*sizeof(short);
 #      ifdef OBJ
        /* offsets of each scalar name */
        len = (len+1)*sizeof(short);
 #      ifdef OBJ
-           put(2, O_CASE2, len);
+           (void) put(2, O_CASE2, len);
 #      endif OBJ
 #      ifdef PC
            putprintf( "        .word %d" , 0 , len );
 #      endif OBJ
 #      ifdef PC
            putprintf( "        .word %d" , 0 , len );
@@ -444,7 +499,7 @@ listnames(ap)
                        continue;
                len++;
 #              ifdef OBJ
                        continue;
                len++;
 #              ifdef OBJ
-                   put(2, O_CASE2, len);
+                   (void) put(2, O_CASE2, len);
 #              endif OBJ
 #              ifdef PC
                    putprintf( "        .word %d" , 0 , len );
 #              endif OBJ
 #              ifdef PC
                    putprintf( "        .word %d" , 0 , len );
@@ -468,10 +523,10 @@ listnames(ap)
 #                  endif DEC11
                    if (!*strptr++)
                            strptr = getnext(next, &next);
 #                  endif DEC11
                    if (!*strptr++)
                            strptr = getnext(next, &next);
-                   word(w);
+                   word((int) w);
            } while (next);
            /* jump over the mess */
            } while (next);
            /* jump over the mess */
-           patch(oldlc);
+           patch((PTR_DCL) oldlc);
 #      endif OBJ
 #      ifdef PC
            while ( next ) {
 #      endif OBJ
 #      ifdef PC
            while ( next ) {
@@ -490,6 +545,7 @@ listnames(ap)
        return( ap -> value[ NL_ELABEL ] );
 }
 
        return( ap -> value[ NL_ELABEL ] );
 }
 
+char *
 getnext(next, new)
 
        struct nl *next, **new;
 getnext(next, new)
 
        struct nl *next, **new;
@@ -498,11 +554,11 @@ getnext(next, new)
                next = next->chain;
                *new = next;
        }
                next = next->chain;
                *new = next;
        }
-       if (next == NIL)
+       if (next == NLNIL)
                return("");
 #ifdef OBJ
                return("");
 #ifdef OBJ
-       if (opt('k') && cgenflg >= 0)
-               printf(")#%5d\t\t\"%s\"\n", lc-HEADER_BYTES, next->symbol);
+       if (opt('k') && CGENNING )
+               printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, next->symbol);
 #endif OBJ
        return(next->symbol);
 }
 #endif OBJ
        return(next->symbol);
 }
@@ -518,16 +574,16 @@ putspace(n)
 {
        register i;
 
 {
        register i;
 
-       if (cgenflg < 0)
+       if ( !CGENNING )
                /*
                 * code disabled - do nothing
                 */
                /*
                 * code disabled - do nothing
                 */
-               return(lc);
+               return;
 #ifdef DEBUG
        if (opt('k'))
 #ifdef DEBUG
        if (opt('k'))
-               printf(")#%5d\t.=.+%d\n", lc - HEADER_BYTES, n);
+               printf("%5d\t.=.+%d\n", lc - HEADER_BYTES, n);
 #endif
 #endif
-       for (i = even(n); i > 0; i -= 2)
+       for (i = n; i > 0; i -= 2)
                word(0);
 }
 
                word(0);
 }
 
@@ -540,14 +596,14 @@ putstr(sptr, padding)
        register char *strptr = sptr;
        register int pad = padding;
 
        register char *strptr = sptr;
        register int pad = padding;
 
-       if (cgenflg < 0)
+       if ( !CGENNING )
                /*
                 * code disabled - do nothing
                 */
                /*
                 * code disabled - do nothing
                 */
-               return(lc);
+               return;
 #ifdef DEBUG
        if (opt('k'))
 #ifdef DEBUG
        if (opt('k'))
-               printf(")#%5d\t\t\"%s\"\n", lc-HEADER_BYTES, strptr);
+               printf("%5d\t\t\"%s\"\n", lc-HEADER_BYTES, strptr);
 #endif
        if (pad == 0) {
                do      {
 #endif
        if (pad == 0) {
                do      {
@@ -562,7 +618,7 @@ putstr(sptr, padding)
 #                              else
                                    w |= *++strptr;
 #                              endif DEC11
 #                              else
                                    w |= *++strptr;
 #                              endif DEC11
-                       word(w);
+                       word((int) w);
                } while (*strptr++);
        } else {
 #              ifdef DEC11
                } while (*strptr++);
        } else {
 #              ifdef DEC11
@@ -572,10 +628,10 @@ putstr(sptr, padding)
                                    if (*++strptr)
                                            w |= *strptr << 8;
                                    else {
                                    if (*++strptr)
                                            w |= *strptr << 8;
                                    else {
-                                           w |= ' \0';
+                                           w |= ' ' << 8;
                                            pad--;
                                    }
                                            pad--;
                                    }
-                                   word(w);
+                                   word((int) w);
                            }
                    } while (*strptr++);
 #              else
                            }
                    } while (*strptr++);
 #              else
@@ -593,14 +649,18 @@ putstr(sptr, padding)
                    } while (*strptr++);
 #              endif DEC11
                while (pad > 1) {
                    } while (*strptr++);
 #              endif DEC11
                while (pad > 1) {
-                       word('  ');
+#                      ifdef DEC11
+                           word(' ' | (' ' << 8));
+#                      else
+                           word((' ' << 8) | ' ');
+#                      endif DEC11
                        pad -= 2;
                }
                if (pad == 1)
 #                      ifdef DEC11
                            word(' ');
 #                      else
                        pad -= 2;
                }
                if (pad == 1)
 #                      ifdef DEC11
                            word(' ');
 #                      else
-                           word(' \0');
+                           word(' ' << 8);
 #                      endif DEC11
                else
                        word(0);
 #                      endif DEC11
                else
                        word(0);
@@ -608,6 +668,7 @@ putstr(sptr, padding)
 }
 #endif OBJ
 
 }
 #endif OBJ
 
+#ifndef PC
 lenstr(sptr, padding)
 
        char *sptr;
 lenstr(sptr, padding)
 
        char *sptr;
@@ -623,6 +684,7 @@ lenstr(sptr, padding)
        } while (*strptr++);
        return((++cnt) & ~1);
 }
        } while (*strptr++);
        return((++cnt) & ~1);
 }
+#endif
 \f
 /*
  * Patch repairs the branch
 \f
 /*
  * Patch repairs the branch
@@ -633,61 +695,64 @@ lenstr(sptr, padding)
  *     lets here it for two pass assemblers.
  */
 patch(loc)
  *     lets here it for two pass assemblers.
  */
 patch(loc)
+    PTR_DCL loc;
 {
 
 #      ifdef OBJ
            patchfil(loc, (long)(lc-loc-2), 1);
 #      endif OBJ
 #      ifdef PC
 {
 
 #      ifdef OBJ
            patchfil(loc, (long)(lc-loc-2), 1);
 #      endif OBJ
 #      ifdef PC
-           putlab( loc );
+           (void) putlab((char *) loc );
 #      endif PC
 }
 
 #ifdef OBJ
 patch4(loc)
 #      endif PC
 }
 
 #ifdef OBJ
 patch4(loc)
+PTR_DCL loc;
 {
        patchfil(loc, (long)(lc - HEADER_BYTES), 2);
 }
 
 /*
 {
        patchfil(loc, (long)(lc - HEADER_BYTES), 2);
 }
 
 /*
- * Patchfil makes loc+2 have value
+ * Patchfil makes loc+2 have jmploc
  * as its contents.
  */
  * as its contents.
  */
-patchfil(loc, value, words)
+patchfil(loc, jmploc, words)
        PTR_DCL loc;
        PTR_DCL loc;
-       long value;
+       long jmploc;
        int words;
 {
        register i;
        int words;
 {
        register i;
-       int val;
+       extern long lseek();
+       short val;
 
 
-       if (cgenflg < 0)
+       if ( !CGENNING )
                return;
        if (loc > (unsigned) lc)
                panic("patchfil");
 #ifdef DEBUG
        if (opt('k'))
                return;
        if (loc > (unsigned) lc)
                panic("patchfil");
 #ifdef DEBUG
        if (opt('k'))
-               printf(")#\tpatch %u %D\n", loc - HEADER_BYTES, value);
+               printf("\tpatch %u %D\n", loc - HEADER_BYTES, jmploc);
 #endif
 #endif
-       val = value;
+       val = jmploc;
        do {
 #              ifndef DEC11
                    if (words > 1)
        do {
 #              ifndef DEC11
                    if (words > 1)
-                           val = value >> 16;
+                           val = jmploc >> 16;
                    else
                    else
-                           val = value;
+                           val = jmploc;
 #              endif DEC11
                i = ((unsigned) loc + 2 - ((unsigned) lc & ~01777))/2;
 #              endif DEC11
                i = ((unsigned) loc + 2 - ((unsigned) lc & ~01777))/2;
-               if (i >= 0 && i < 1024)
+               if (i >= 0 && i < 1024) {
                        obuf[i] = val;
                        obuf[i] = val;
-               else {
-                       lseek(ofil, (long) loc+2, 0);
-                       write(ofil, &val, 2);
-                       lseek(ofil, (long) 0, 2);
+               else {
+                       (void) lseek(ofil, (long) loc+2, 0);
+                       write(ofil, (char *) (&val), 2);
+                       (void) lseek(ofil, (long) 0, 2);
                }
                loc += 2;
 #              ifdef DEC11
                }
                loc += 2;
 #              ifdef DEC11
-                   val = value >> 16;
+                   val = jmploc >> 16;
 #              endif DEC11
        } while (--words);
 }
 #              endif DEC11
        } while (--words);
 }
@@ -715,7 +780,7 @@ pflush()
        register i;
 
        i = (obufp - ( ( short * ) obuf ) ) * 2;
        register i;
 
        i = (obufp - ( ( short * ) obuf ) ) * 2;
-       if (i != 0 && write(ofil, obuf, i) != i)
+       if (i != 0 && write(ofil, (char *) obuf, i) != i)
                perror(obj), pexit(DIED);
        obufp = obuf;
 }
                perror(obj), pexit(DIED);
        obufp = obuf;
 }
@@ -726,6 +791,7 @@ pflush()
  * included here for the eventual code generator.
  *     for PC, thank you!
  */
  * included here for the eventual code generator.
  *     for PC, thank you!
  */
+char *
 getlab()
 {
 #      ifdef OBJ
 getlab()
 {
 #      ifdef OBJ
@@ -735,7 +801,7 @@ getlab()
 #      ifdef PC
            static long lastlabel;
 
 #      ifdef PC
            static long lastlabel;
 
-           return ( ++lastlabel );
+           return ( (char *) ++lastlabel );
 #      endif PC
 }
 
 #      endif PC
 }
 
@@ -743,12 +809,13 @@ getlab()
  * Putlab - lay down a label.
  *     for PC, just print the label name with a colon after it.
  */
  * Putlab - lay down a label.
  *     for PC, just print the label name with a colon after it.
  */
+char *
 putlab(l)
 putlab(l)
-       int l;
+       char *l;
 {
 
 #      ifdef PC
 {
 
 #      ifdef PC
-           putprintf( PREFIXFORMAT , 1 , LABELPREFIX , l );
+           putprintf( PREFIXFORMAT , 1 , (int) LABELPREFIX , (int) l );
            putprintf( ":" , 0 );
 #      endif PC
        return (l);
            putprintf( ":" , 0 );
 #      endif PC
        return (l);