bye bye fixed names (eg, FLEXNAMES is not set)
[unix-history] / usr / src / old / as.vax / asparse.c
index 6fff6a4..a9d57ef 100644 (file)
@@ -1,10 +1,15 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asparse.c 4.6 %G%";
+/*
+ *     Copyright (c) 1982 Regents of the University of California
+ */
+#ifndef lint
+static char sccsid[] = "@(#)asparse.c 4.16 %G%";
+#endif not lint
+
 #include <stdio.h>
 #include "as.h"
 #include <stdio.h>
 #include "as.h"
-#include "asexpr.h"
 #include "asscan.h"
 #include "assyms.h"
 #include "asscan.h"
 #include "assyms.h"
+#include "asexpr.h"
 
 int    lgensym[10];
 char   genref[10];
 
 int    lgensym[10];
 char   genref[10];
@@ -24,8 +29,10 @@ int  droppedLP;              /*one is analyzing an expression beginning with*/
                                /*a left parenthesis, which has already been*/
                                /*shifted. (Used to parse (<expr>)(rn)*/
 
                                /*a left parenthesis, which has already been*/
                                /*shifted. (Used to parse (<expr>)(rn)*/
 
-char   yytext[NCPS+2];         /*the lexical image*/
+char   yytext[NCPName+2];      /*the lexical image*/
 int    yylval;                 /*the lexical value; sloppy typing*/
 int    yylval;                 /*the lexical value; sloppy typing*/
+struct Opcode          yyopcode;       /* lexical value for an opcode */
+Bignum yybignum;               /* lexical value for a big number */
 /*
  *     Expression and argument managers
  */
 /*
  *     Expression and argument managers
  */
@@ -37,49 +44,52 @@ struct      arg     arglist[NARG];  /*building up operands in instructions*/
  */
 char   tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
 
  */
 char   tokensets[(LASTTOKEN) - (FIRSTTOKEN) + 1];
 
-static char    UDotsname[32];  /*name of the assembly source*/
+static char    UDotsname[64];  /*name of the assembly source*/
 
 
-int    yyparse()
+yyparse()
 {
 {
-       register        struct  exp     *locxp;
-                       /*
-                        *      loc1xp and ptrloc1xp are used in the
-                        *      expression lookahead
-                        */
-                       struct  exp     *loc1xp;        /*must be non register*/
-                       struct  exp     **ptrloc1xp = & loc1xp;
-                       struct  exp     *pval;          /*hacking expr:expr*/
-
-       register        struct  symtab  *np;
-       register        int             argcnt;
-
-       register        int             val;            /*what yylex gives*/
-       register        int             auxval;         /*saves val*/
-
-       register        struct  arg     *ap;            /*first free argument*/
-
-                       struct  symtab  *p;
-       register        struct  symtab  *stpt;
-
-                       struct  strdesc *stringp;       /*handles string lists*/
-
-                       int             regno;          /*handles arguments*/
-                       int             *ptrregno = &regno;
-                       int             sawmul;         /*saw * */
-                       int             sawindex;       /*saw [rn]*/
-                       int             sawsize;
-                       int             seg_type;       /*the kind of segment: data or text*/
-                       int             seg_number;     /*the segment number*/
-                       int             space_value;    /*how much .space needs*/
-                       int             fill_rep;       /*how many reps for .fill */
-                       int             fill_size;      /*how many bytes for .fill */
-
-                       int             field_width;    /*how wide a field is to be*/
-                       int             field_value;    /*the value to stuff in a field*/
-                       char            *stabname;      /*name of stab dealing with*/
-                       ptrall          stabstart;      /*where the stab starts in the buffer*/
-                       int             reloc_how;      /* how to relocate expressions */
-
+       reg     struct  exp     *locxp;
+               /*
+                *      loc1xp and ptrloc1xp are used in the
+                *      expression lookahead
+                */
+               struct  exp     *loc1xp;        /*must be non register*/
+               struct  exp     **ptrloc1xp = & loc1xp;
+               struct  exp     *pval;          /*hacking expr:expr*/
+
+       reg     struct  symtab  *np;
+       reg     int             argcnt;
+
+       reg     inttoktype      val;            /*what yylex gives*/
+       reg     inttoktype      auxval;         /*saves val*/
+
+       reg     struct  arg     *ap;            /*first free argument*/
+
+       reg     struct  symtab  *p;
+       reg     struct  symtab  *stpt;
+
+               struct  strdesc *stringp;       /*handles string lists*/
+
+               int     regno;          /*handles arguments*/
+               int     *ptrregno = &regno;
+               int     sawmul;         /*saw * */
+               int     sawindex;       /*saw [rn]*/
+               int     sawsize;
+               int     seg_type;       /*the kind of segment: data or text*/
+               int     seg_number;     /*the segment number*/
+               int     space_value;    /*how much .space needs*/
+               int     fill_rep;       /*how many reps for .fill */
+               int     fill_size;      /*how many bytes for .fill */
+
+               int     field_width;    /*how wide a field is to be*/
+               int     field_value;    /*the value to stuff in a field*/
+               char    *stabname;      /*name of stab dealing with*/
+               ptrall  stabstart;      /*where the stab starts in the buffer*/
+               int     reloc_how;      /* how to relocate expressions */
+               int     toconv;         /* how to convert bignums */
+               int     incasetable;    /* set if in a case table */
+
+       incasetable = 0;
        xp = explist;
        ap = arglist;
 
        xp = explist;
        ap = arglist;
 
@@ -91,13 +101,16 @@ int        yyparse()
                if (val == INT) {
                        int i = ((struct exp *)yylval)->e_xvalue;
                        shift;
                if (val == INT) {
                        int i = ((struct exp *)yylval)->e_xvalue;
                        shift;
-                       if (val != COLON)
-                               goto nocolon;
+                       if (val != COLON){
+                               yyerror("Local label %d is not followed by a ':' for a label definition",
+                                       i);
+                               goto  errorfix;
+                       }
                        if (i < 0 || i > 9) {
                                yyerror("Local labels are 0-9");
                                goto errorfix;
                        }
                        if (i < 0 || i > 9) {
                                yyerror("Local labels are 0-9");
                                goto errorfix;
                        }
-                       sprintf(yytext, "L%d\001%d", i, lgensym[i]);
+                       (void)sprintf(yytext, "L%d\001%d", i, lgensym[i]);
                        lgensym[i]++;
                        genref[i] = 0;
                        yylval = (int)*lookup(passno == 1);
                        lgensym[i]++;
                        genref[i] = 0;
                        yylval = (int)*lookup(passno == 1);
@@ -117,15 +130,9 @@ int        yyparse()
                        }
                        np = (struct symtab *)yylval;
                        shiftover(NAME);
                        }
                        np = (struct symtab *)yylval;
                        shiftover(NAME);
-nocolon:
                        if (val != COLON) {
                        if (val != COLON) {
-#ifdef FLEXNAMES
                                yyerror("\"%s\" is not followed by a ':' for a label definition",
                                yyerror("\"%s\" is not followed by a ':' for a label definition",
-#else not FLEXNAMES
-                               yyerror("\"%.*s\" is not followed by a ':' for a label definition",
-                                       NCPS,
-#endif not FLEXNAMES
-                                       np->s_name);
+                                       FETCHNAME(np));
                                goto  errorfix;
                        }
 restlab:
                                goto  errorfix;
                        }
 restlab:
@@ -139,25 +146,15 @@ restlab:
                                      )
                                  ){
 #ifndef DEBUG
                                      )
                                  ){
 #ifndef DEBUG
-                                       if (np->s_name[0] != 'L')
+                                       if (FETCHNAME(np)[0] != 'L')
 #endif not DEBUG
                                        {
                                                if (passno == 1)
 #endif not DEBUG
                                        {
                                                if (passno == 1)
-#ifdef FLEXNAMES
                                                  yyerror("%s redefined",
                                                  yyerror("%s redefined",
-#else not FLEXNAMES
-                                                 yyerror("%.*s redefined",
-                                                       NCPS,
-#endif not FLEXNAMES 
-                                                       np->s_name);
+                                                       FETCHNAME(np));
                                                else
                                                else
-#ifdef FLEXNAMES
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
-#else not FLEXNAMES
-                                                 yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
-                                                       NCPS,
-#endif not FLEXNAMES
-                                                       np->s_name,
+                                                       FETCHNAME(np),
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
@@ -168,7 +165,7 @@ restlab:
                        np->s_value = dotp->e_xvalue;
                        if (passno == 1){
                                np->s_index = dotp-usedot;
                        np->s_value = dotp->e_xvalue;
                        if (passno == 1){
                                np->s_index = dotp-usedot;
-                               if (np->s_name[0] == 'L'){
+                               if (FETCHNAME(np)[0] == 'L'){
                                        nlabels++;
                                }
                                np->s_tag = LABELID;
                                        nlabels++;
                                }
                                np->s_tag = LABELID;
@@ -194,7 +191,7 @@ restlab:
        break;
 
    case PARSEEOF:
        break;
 
    case PARSEEOF:
-       tokptr -= sizeof(toktype);
+       tokptr -= sizeof(bytetoktype);
        *tokptr++ = VOID;
        tokptr[1] = VOID;
        tokptr[2] = PARSEEOF;
        *tokptr++ = VOID;
        tokptr[1] = VOID;
        tokptr[2] = PARSEEOF;
@@ -205,9 +202,8 @@ restlab:
        stringp = (struct strdesc *)yylval;
        shiftover(STRING);
        dotsname = &UDotsname[0];
        stringp = (struct strdesc *)yylval;
        shiftover(STRING);
        dotsname = &UDotsname[0];
-       movestr(dotsname, stringp->str,
-               stringp->str_lg >= 32? 32 :stringp->str_lg);
-       dotsname[stringp->str_lg] = '\0';
+       movestr(dotsname, stringp->sd_string,
+               min(stringp->sd_strlen, sizeof(UDotsname)));
        break;
 
    case ILINENO:
        break;
 
    case ILINENO:
@@ -246,18 +242,14 @@ restlab:
         */
        if (passno == 1){
                stpt = (struct symtab *)symalloc();
         */
        if (passno == 1){
                stpt = (struct symtab *)symalloc();
-#ifdef FLEXNAMES
                stpt->s_name = np->s_name;
                stpt->s_name = np->s_name;
-#else
-               movestr(stpt->s_name, np->s_name, NCPS);
-#endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
                np = stpt;
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
                np = stpt;
-               if (locxp->e_xtype != XABS) 
-                       ("Illegal lsym");
-               np->s_value=locxp->e_xvalue;
-               np->s_type=XABS;
+               if ( (locxp->e_xtype & XTYPE) != XABS)
+                       yyerror("Illegal second argument to lsym");
+               np->s_value = locxp->e_xvalue;
+               np->s_type = XABS;
                np->s_tag = ILSYM;
        }
        break;
                np->s_tag = ILSYM;
        }
        break;
@@ -282,7 +274,8 @@ restlab:
                seg_number = 0;
                seg_type = -seg_type;
        } else {
                seg_number = 0;
                seg_type = -seg_type;
        } else {
-               if (locxp->e_xtype != XABS || (seg_number=locxp->e_xvalue) >= NLOC) {
+               if (   ((locxp->e_xtype & XTYPE) != XABS)       /* tekmdp */
+                   || (seg_number = locxp->e_xvalue) >= NLOC) {
                        yyerror("illegal location counter");
                        seg_number = 0;
                }
                        yyerror("illegal location counter");
                        seg_number = 0;
                }
@@ -291,24 +284,10 @@ restlab:
                seg_number += NLOC;
        flushfield(NBPW/4);
        dotp = &usedot[seg_number];
                seg_number += NLOC;
        flushfield(NBPW/4);
        dotp = &usedot[seg_number];
-#ifdef UNIX
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
                relfil = rusefile[seg_number];
        }
        if (passno==2) {        /* go salt away in pass 2*/
                txtfil = usefile[seg_number];
                relfil = rusefile[seg_number];
        }
-#endif UNIX
-#ifdef VMS
-       if (passno==2) {
-               puchar(vms_obj_ptr,6);          /*  setpl  */
-               puchar(vms_obj_ptr,seg_number); /* psect # */
-               plong(vms_obj_ptr,dotp->e_xvalue);/*  offset */
-               puchar(vms_obj_ptr,80);         /*  setrb  */
-               if((vms_obj_ptr-sobuf) > 400){
-                       write(objfil,sobuf,vms_obj_ptr-sobuf);
-                       vms_obj_ptr=sobuf+1;    /*flush buf*/
-               }
-       }
-#endif VMS
        break;
 
        /*
        break;
 
        /*
@@ -320,12 +299,10 @@ restlab:
         *      outexpr:   <expr> | <expr> : <expr>
         */
    case IBYTE: curlen = NBPW/4; goto elist;
         *      outexpr:   <expr> | <expr> : <expr>
         */
    case IBYTE: curlen = NBPW/4; goto elist;
-
-   case IINT:
+   case IWORD: curlen = NBPW/2; goto elist;
+   case IINT:  curlen = NBPW;   goto elist;
    case ILONG: curlen = NBPW;   goto elist;
 
    case ILONG: curlen = NBPW;   goto elist;
 
-   case IWORD:
-       curlen = NBPW/2;
    elist:
        seg_type = val;
        shift;
    elist:
        seg_type = val;
        shift;
@@ -348,12 +325,11 @@ restlab:
                if (val == COLON){
                        shiftover(COLON);
                        expr(pval, val);
                if (val == COLON){
                        shiftover(COLON);
                        expr(pval, val);
-                       if (locxp->e_xtype != XABS)
-                         yyerror("Width not absolute");
+                       if ((locxp->e_xtype & XTYPE) != XABS) /* tekmdp */
+                               yyerror("Width not absolute");
                        field_width = locxp->e_xvalue;
                        locxp = pval;
                        field_width = locxp->e_xvalue;
                        locxp = pval;
-                       if (bitoff + field_width >
-                         curlen)
+                       if (bitoff + field_width > curlen)
                                flushfield(curlen);
                        if (field_width > curlen)
                                yyerror("Expression crosses field boundary");
                                flushfield(curlen);
                        if (field_width > curlen)
                                yyerror("Expression crosses field boundary");
@@ -362,7 +338,7 @@ restlab:
                        flushfield(curlen);
                }
 
                        flushfield(curlen);
                }
 
-                if ((locxp->e_xtype&XTYPE)!=XABS) {
+               if ((locxp->e_xtype & XTYPE) != XABS) {
                        if (bitoff)
                                yyerror("Illegal relocation in field");
                        switch(curlen){
                        if (bitoff)
                                yyerror("Illegal relocation in field");
                        switch(curlen){
@@ -376,14 +352,28 @@ restlab:
                                outrel(locxp, reloc_how);
                        }
                } else {
                                outrel(locxp, reloc_how);
                        }
                } else {
+                       /*
+                        *      
+                        *      See if we are doing a case instruction.
+                        *      If so, then see if the branch distance,
+                        *      stored as a word,
+                        *      is going to loose sig bits.
+                        */
+                       if (passno == 2 && incasetable){
+                               if (  (locxp->e_xvalue < -32768)
+                                   ||(locxp->e_xvalue > 32767)){
+                                       yyerror("Case will branch too far");
+                               }
+                       }
                        field_value = locxp->e_xvalue & ( (1L << field_width)-1);
                        bitfield |= field_value << bitoff;
                        bitoff += field_width;
                }
                        field_value = locxp->e_xvalue & ( (1L << field_width)-1);
                        bitfield |= field_value << bitoff;
                        bitoff += field_width;
                }
-               if ( auxval = (val == CM)) shift;
                xp = explist;
                xp = explist;
+               if (auxval = (val == CM))
+                       shift;
            } while (auxval);
            } while (auxval);
-       }       /*existed an expression  at all*/
+       }       /* there existed an expression at all */
 
        flushfield(curlen);
        if ( ( curlen == NBPW/4) && bitoff)
 
        flushfield(curlen);
        if ( ( curlen == NBPW/4) && bitoff)
@@ -394,34 +384,21 @@ restlab:
    case ISPACE:        /* .space <expr> */
        shift;
        expr(locxp, val);
    case ISPACE:        /* .space <expr> */
        shift;
        expr(locxp, val);
-       if (locxp->e_xtype != XABS)
+       if ((locxp->e_xtype & XTYPE) != XABS)   /* tekmdp */
                yyerror("Space size not absolute");
        space_value = locxp->e_xvalue;
   ospace:
        flushfield(NBPW/4);
                yyerror("Space size not absolute");
        space_value = locxp->e_xvalue;
   ospace:
        flushfield(NBPW/4);
-#ifdef UNIX
-       while (space_value > 96){
-               outs(strbuf[2].str, 96);
-               space_value -= 96;
-       }
-       outs(strbuf[2].str, space_value);
-#endif UNIX
-#ifdef VMS
-       dotp->e_xvalue += space_value;          /*bump pc*/
-       if (passno==2){
-         if(*(strbuf[2].str)==0) {
-               puchar(vms_obj_ptr,81);         /* AUGR  */
-               pulong(vms_obj_ptr,space_value);/* incr  */
-         } else yyerror("VMS, encountered non-0 .space");
-         if ((vms_obj_ptr-sobuf) > 400) {
-               write(objfil,sobuf,vms_obj_ptr-sobuf);
-               vms_obj_ptr=sobuf+1;            /*pur buf*/
-         }
+       {
+               static char spacebuf[128];
+               while (space_value > sizeof(spacebuf)){
+                       outs(spacebuf, sizeof(spacebuf));
+                       space_value -= sizeof(spacebuf);
+               }
+               outs(spacebuf, space_value);
        }
        }
-#endif VMS
        break;
 
        break;
 
-#ifdef UNIX
        /*
         *      .fill rep, size, value
         *      repeat rep times: fill size bytes with (truncated) value
        /*
         *      .fill rep, size, value
         *      repeat rep times: fill size bytes with (truncated) value
@@ -430,89 +407,79 @@ restlab:
    case        IFILL:
        shift;
        expr(locxp, val);
    case        IFILL:
        shift;
        expr(locxp, val);
-       if (locxp->e_xtype != XABS)
+       if ( (locxp->e_xtype & XTYPE) != XABS)  /* tekmdp */
                yyerror("Fill repetition count not absolute");
        fill_rep = locxp->e_xvalue;
        shiftover(CM);
        expr(locxp, val);
                yyerror("Fill repetition count not absolute");
        fill_rep = locxp->e_xvalue;
        shiftover(CM);
        expr(locxp, val);
-       if (locxp->e_xtype != XABS)
+       if ( (locxp->e_xtype & XTYPE) != XABS)  /* tekmdp */
                yyerror("Fill size not absolute");
        fill_size = locxp->e_xvalue;
        if (fill_size <= 0 || fill_size > 8)
                yyerror("Fill count not in in 1..8");
        shiftover(CM);
        expr(locxp, val);
                yyerror("Fill size not absolute");
        fill_size = locxp->e_xvalue;
        if (fill_size <= 0 || fill_size > 8)
                yyerror("Fill count not in in 1..8");
        shiftover(CM);
        expr(locxp, val);
-       if (passno == 2 && locxp->e_xtype != XABS)
-                       yyerror("Fill value not absolute");
+       if (passno == 2 && (locxp->e_xtype & XTYPE) != XABS)    /* tekmdp */
+               yyerror("Fill value not absolute");
        flushfield(NBPW/4);
        if (passno == 1) {
        flushfield(NBPW/4);
        if (passno == 1) {
-               locxp->e_xvalue += fill_rep * fill_size;
+               dotp->e_xvalue += fill_rep * fill_size;
        } else {
                while(fill_rep-- > 0)
        } else {
                while(fill_rep-- > 0)
-                       bwrite(&locxp->e_xvalue, fill_size, txtfil);
+                       bwrite((char *)&locxp->e_xvalue, fill_size, txtfil);
        }
        break;
        }
        break;
-#endif UNIX
 
 
-   case IASCII:        /* .ascii [ <stringlist> ] */
+   case IASCII:                /* .ascii [ <stringlist> ] */
    case IASCIZ:        /* .asciz [ <stringlist> ] */
        auxval = val;
        shift;
    case IASCIZ:        /* .asciz [ <stringlist> ] */
        auxval = val;
        shift;
-
        /*
         *      Code to consume a string list
         *
         *      stringlist: empty | STRING | stringlist STRING
         */
        /*
         *      Code to consume a string list
         *
         *      stringlist: empty | STRING | stringlist STRING
         */
-       while (val ==  STRING){
+       while (val == STRING){
+               int     mystrlen;
                flushfield(NBPW/4);
                if (bitoff)
                flushfield(NBPW/4);
                if (bitoff)
-                 dotp->e_xvalue++;
+                       dotp->e_xvalue++;
                stringp = (struct strdesc *)yylval;
                stringp = (struct strdesc *)yylval;
-#ifdef UNIX
-               outs(stringp->str, stringp->str_lg);
-#endif UNIX
-#ifdef VMS
-               {
-                       register int i;
-                       for (i=0; i < stringp->str_lg; i++){
-                         dotp->e_xvalue += 1;
-                           if (passno==2){
-                               puchar(vms_obj_ptr,-1);
-                               puchar(vms_obj_ptr,stringp->str[i]);
-                               if (vms_obj_ptr-sobuf > 400) {
-                                 write(objfil,sobuf,vms_obj_ptr-sobuf);
-                                 vms_obj_ptr = sobuf + 1;
-                               }
-                           }
+               /*
+                *      utilize the string scanner cheat;
+                *      the scanner appended a null byte on the string,
+                *      but didn't charge it to sd_strlen
+                */
+               mystrlen = stringp->sd_strlen;
+               mystrlen += (auxval == IASCIZ) ? 1 : 0;
+               if (passno == 2){
+                       if (stringp->sd_place & STR_CORE){
+                               outs(stringp->sd_string, mystrlen);
+                       } else {
+                               int     i, nread;
+                               fseek(strfile, stringp->sd_stroff, 0);
+                               for (i = 0; i < mystrlen;/*VOID*/){
+                                       nread = fread(yytext, 1,
+                                               min(mystrlen - i,
+                                                 sizeof(yytext)), strfile);
+                                       outs(yytext, nread);
+                                       i += nread;
+                               }
                        }
                        }
+               } else {
+                       dotp->e_xvalue += mystrlen;
                }
                }
-#endif VMS
                shift;          /*over the STRING*/
                if (val == CM)  /*could be a split string*/
                        shift;
        }
                shift;          /*over the STRING*/
                if (val == CM)  /*could be a split string*/
                        shift;
        }
-
-       if (auxval == IASCIZ){
-               flushfield(NBPW/4);
-#ifdef UNIX
-               outb(0);
-#endif UNIX
-#ifdef VMS
-               if (passno == 2) {
-                       puchar(vms_obj_ptr,-1);
-                       puchar(vms_obj_ptr,0);
-               }
-               dotp->e_xvalue += 1;
-#endif VMS
-       }
        break;
        
    case IORG:  /* .org <expr> */
        shift;
        expr(locxp, val);
 
        break;
        
    case IORG:  /* .org <expr> */
        shift;
        expr(locxp, val);
 
-       if (locxp->e_xtype==XABS)
+       if ((locxp->e_xtype & XTYPE) == XABS)   /* tekmdp */
                orgwarn++;
        else if ((locxp->e_xtype & ~XXTRN) != dotp->e_xtype)
                yyerror("Illegal expression to set origin");
                orgwarn++;
        else if ((locxp->e_xtype & ~XXTRN) != dotp->e_xtype)
                yyerror("Illegal expression to set origin");
@@ -546,41 +513,19 @@ restlab:
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
  *             final expression is taken to be  the current
  *             location counter, and is patched by the 2nd pass
  *
- *     .stab{<expr>,}*NCPS,<expr>, <expr>, <expr>, <expr>
+ *     .stab{<expr>,}*NCPName,<expr>, <expr>, <expr>, <expr>
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
  */
    case ISTAB: 
  *     .stabn           <expr>, <expr>, <expr>, <expr>
  *     .stabs   STRING, <expr>, <expr>, <expr>, <expr>
  *     .stabd           <expr>, <expr>, <expr> # . 
  */
    case ISTAB: 
-#ifndef FLEXNAMES
-       stabname = ".stab";
-       if (passno == 2)        goto errorfix;
-       stpt = (struct symtab *)yylval;
-       /*
-        *      Make a pointer to the .stab slot.
-        *      There is a pointer in the way (stpt), and
-        *      tokptr points to the next token.
-        */
-       stabstart = tokptr;
-       (char *)stabstart -= sizeof(struct symtab *);
-       (char *)stabstart -= sizeof(toktype);
-       shift;
-       for (argcnt = 0; argcnt < NCPS; argcnt++){
-               expr(locxp, val);
-               stpt->s_name[argcnt] = locxp->e_xvalue;
-               xp = explist;
-               shiftover(CM);
-       }
-       goto tailstab;
-#else  FLEXNAMES
-       yyerror(".stab directive not supported in; report this compiler bug to system administrator");
+       yyerror(".stab directive no longer supported");
        goto errorfix;
        goto errorfix;
-#endif FLEXNAMES
 
   tailstab:
        expr(locxp, val);
        if (! (locxp->e_xvalue & STABTYPS)){
 
   tailstab:
        expr(locxp, val);
        if (! (locxp->e_xvalue & STABTYPS)){
-               yyerror("Invalid type in %s",stabname);
+               yyerror("Invalid type in %s", stabname);
                goto errorfix;
        }
        stpt->s_ptype = locxp->e_xvalue;
                goto errorfix;
        }
        stpt->s_ptype = locxp->e_xvalue;
@@ -628,7 +573,19 @@ restlab:
                 *      The final value of value is
                 *      given by stabfix()
                 */
                 *      The final value of value is
                 *      given by stabfix()
                 */
-               stpt->s_tag = STABFLOATING;
+/*
+ * For exprs of the form (name + value) one needs to remember locxp->e_xvalue
+ * for use in stabfix. The right place to keep this is in stpt->s_value
+ * however this gets corrupted at an unknown point.
+ * As a bandaid hack the value is preserved in s_desc and s_other (a
+ * short and a char). This destroys these two values and will
+ * be fixed. May 19 ,1983 Alastair Fyfe
+ */
+               if(locxp->e_xvalue) {
+                       stpt->s_other = (locxp->e_xvalue >> 16);
+                       stpt->s_desc =  (locxp->e_xvalue  & 0x0000ffff);
+                       stpt->s_tag = STABFLOATING;
+               }
        }
        /*
         *      tokptr now points at one token beyond
        }
        /*
         *      tokptr now points at one token beyond
@@ -639,7 +596,7 @@ restlab:
         *      one.  Therefore, to point to the next token
         *      after the end of this stab, just back up one..
         */
         *      one.  Therefore, to point to the next token
         *      after the end of this stab, just back up one..
         */
-       buildskip(stabstart, (char *)tokptr - sizeof(toktype));
+       buildskip(stabstart, (bytetoktype *)tokptr - sizeof(bytetoktype));
        break;  /*end of the .stab*/
 
    case ISTABDOT:      
        break;  /*end of the .stab*/
 
    case ISTABDOT:      
@@ -674,7 +631,7 @@ restlab:
                 *      tokptr points to the next token,
                 *      build the skip up to this
                 */
                 *      tokptr points to the next token,
                 *      build the skip up to this
                 */
-               buildskip(stabstart, (toktype *)tokptr - sizeof(toktype));
+               buildskip(stabstart, (bytetoktype *)tokptr - sizeof(bytetoktype));
        }
        /*
         *      pass 1: Assign a good guess for its position
        }
        /*
         *      pass 1: Assign a good guess for its position
@@ -694,33 +651,32 @@ restlab:
        if (passno == 2) goto errorfix;
        stpt = (struct symtab *)yylval;
        stabstart = tokptr;
        if (passno == 2) goto errorfix;
        stpt = (struct symtab *)yylval;
        stabstart = tokptr;
-       (char *)stabstart -= sizeof(struct symtab *);
-       (char *)stabstart -= sizeof(toktype);
+       (bytetoktype *)stabstart -= sizeof(struct symtab *);
+       (bytetoktype *)stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
                stringp = (struct strdesc *)yylval;
                shiftover(STRING);
        shift;
        if (auxval == ISTABSTR){
                stringp = (struct strdesc *)yylval;
                shiftover(STRING);
-#ifndef FLEXNAMES
-               auxval = stringp->str_lg > NCPS ? NCPS : stringp->str_lg;
-#else
-               stringp->str[stringp->str_lg] = 0;
-#endif
+               stpt->s_name = (char *)stringp;
+               /*
+                *      We want the trailing null included in this string.
+                *      We utilize the cheat the string scanner used,
+                *      and merely increment the string length
+                */
+               stringp->sd_strlen += 1;
                shiftover(CM);
        } else {
                shiftover(CM);
        } else {
-               stringp = &(strbuf[2]);
-#ifndef FLEXNAMES
-               auxval = NCPS;
-#endif
+               static char nullstr[1];
+               static  struct  strdesc strdp;
+               strdp.sd_stroff = strfilepos;
+               strdp.sd_strlen = 0;
+               strdp.sd_place = STR_BOTH;
+               stpt->s_name = (char *)savestr(nullstr, &strdp);
        }
        }
-#ifndef FLEXNAMES
-       movestr(stpt->s_name, stringp->str, auxval);
-#else
-       stpt->s_name = savestr(stringp->str);
-#endif
        goto tailstab;
        break;
 
        goto tailstab;
        break;
 
-   case ICOMM: /* .comm  <name> , <expr> */
+   case ICOMM:         /* .comm  <name> , <expr> */
    case ILCOMM:        /* .lcomm <name> , <expr> */
        auxval = val;
        shift;
    case ILCOMM:        /* .lcomm <name> , <expr> */
        auxval = val;
        shift;
@@ -729,16 +685,10 @@ restlab:
        shiftover(CM);
        expr(locxp, val);
 
        shiftover(CM);
        expr(locxp, val);
 
-       if (locxp->e_xtype != XABS)
+       if ( (locxp->e_xtype & XTYPE) != XABS)  /* tekmdp */
                yyerror("comm size not absolute");
                yyerror("comm size not absolute");
-       if (passno==1 && (np->s_type&XTYPE)!=XUNDEF)
-#ifdef FLEXNAMES
-               yyerror("Redefinition of %s",
-#else not FLEXNAMES
-               yyerror("Redefinition of %.*s",
-                       NCPS,
-#endif not FLEXNAMES
-                       np->s_name);
+       if (passno == 1 && (np->s_type&XTYPE) != XUNDEF)
+               yyerror("Redefinition of %s", FETCHNAME(np));
        if (passno==1) {
                np->s_value = locxp->e_xvalue;
                if (auxval == ICOMM)
        if (passno==1) {
                np->s_value = locxp->e_xvalue;
                if (auxval == ICOMM)
@@ -758,14 +708,14 @@ restlab:
        break;
 
    case INST0:                 /* instructions w/o arguments*/
        break;
 
    case INST0:                 /* instructions w/o arguments*/
-       insout(yylval, (struct arg *)0, 0);
+       incasetable = 0;
+       insout(yyopcode, (struct arg *)0, 0);
        shift;  
        break;
 
    case INSTn:         /* instructions with arguments*/
    case IJXXX:                 /* UNIX style jump instructions */
        auxval = val;
        shift;  
        break;
 
    case INSTn:         /* instructions with arguments*/
    case IJXXX:                 /* UNIX style jump instructions */
        auxval = val;
-       seg_type = yylval;
        /*
         *      Code to process an argument list
         */
        /*
         *      Code to process an argument list
         */
@@ -894,7 +844,8 @@ restlab:
                        if (ap->a_atype == ABASE) {
                                ap->a_atype = ADISP;
                                xp->e_xtype = XABS;
                        if (ap->a_atype == ABASE) {
                                ap->a_atype = ADISP;
                                xp->e_xtype = XABS;
-                               xp->e_xvalue = 0;
+                               xp->e_number = Znumber;
+                               xp->e_number.num_tag = TYPL;
                                xp->e_xloc = 0;
                                ap->a_xp = xp++;
                        }
                                xp->e_xloc = 0;
                                ap->a_xp = xp++;
                        }
@@ -915,66 +866,69 @@ restlab:
                goto errorfix;
        }
 
                goto errorfix;
        }
 
-       insout(seg_type, arglist,
+       /*
+        *      See if this is a case instruction,
+        *      so we can set up tests on the following
+        *      vector of branch displacements
+        */
+       if (yyopcode.Op_eopcode == CORE){
+               switch(yyopcode.Op_popcode){
+               case 0x8f:      /* caseb */
+               case 0xaf:      /* casew */
+               case 0xcf:      /* casel */
+                       incasetable++;
+                       break;
+               default:
+                       incasetable = 0;
+                       break;
+               }
+       }
+
+       insout(yyopcode, arglist,
                auxval == INSTn ? argcnt : - argcnt);
        break;
 
                auxval == INSTn ? argcnt : - argcnt);
        break;
 
-   case IFLOAT:        curlen = 4;     goto floatlist;
-   case IQUAD:
-   case IDOUBLE: 
-       curlen = 8;
-      floatlist:       
+   case IQUAD:         toconv = TYPQ;  goto bignumlist;
+   case IOCTA:         toconv = TYPO;  goto bignumlist;
+
+   case IFFLOAT:       toconv = TYPF;  goto bignumlist;
+   case IDFLOAT:       toconv = TYPD;  goto bignumlist;
+   case IGFLOAT:       toconv = TYPG;  goto bignumlist;
+   case IHFLOAT:       toconv = TYPH;  goto bignumlist;
+   bignumlist: 
        /*
        /*
-        *      eat a list of floating point numbers
+        *      eat a list of non 32 bit numbers.
+        *      IQUAD and IOCTA can, possibly, return
+        *      INT's, if the numbers are "small".
+        *
+        *      The value of the numbers is coming back
+        *      as an expression, NOT in yybignum.
         */
         */
-       shift;
-       if (val == FLTNUM){
-               /* KLS MOD */
-               float flocal;
+       shift;  /* over the opener */
+       if ((val == BIGNUM) || (val == INT)){
                do{
                do{
-                       if (val == CM) shift;
-                       if (val != FLTNUM) {
-                         ERROR("floating number expected");
-                       }
-                       dotp->e_xvalue += curlen;
-#ifdef UNIX
-                       if (passno == 2) {
-                         if(curlen == 8)
-                          bwrite((char *)&(((union Double *)yylval)->dvalue),
-                               curlen, txtfil);
-                         else  {
-                          flocal = ((union Double *)yylval)->dvalue;
-                          bwrite((char *)&flocal, curlen, txtfil);
-                         }
+                       if ((val != BIGNUM) && (val != INT)){
+                               ERROR(ty_float[toconv]
+                                  ? "floating number expected"
+                                  : "integer number expected" );
                        }
                        }
-#endif UNIX
-
-#ifdef VMS
-                       if (passno == 2) {
-                          puchar(vms_obj_ptr,-4);
-                          pulong(vms_obj_ptr,
-                           ((struct exp *)yylval)
-                               ->doub_MSW);
-                          if (curlen==8) {
-                           puchar(vms_obj_ptr,-4);
-                           pulong(vms_obj_ptr,
-                           ((struct exp *)yylval)
-                               ->doub_LSW);
-                          }
-                          if((vms_obj_ptr-sobuf) > 400) {
-                           write(objfil,sobuf,vms_obj_ptr-sobuf);
-                           vms_obj_ptr = sobuf + 1;
-                          }
+                       dotp->e_xvalue += ty_nbyte[toconv];
+                       if (passno == 2){
+                               bignumwrite(
+                                       ((struct exp *)yylval)->e_number,
+                                       toconv);
                        }
                        }
-#endif VMS
-                       shift;
                        xp = explist;
                        xp = explist;
-               } while (val == CM);
+                       shift;          /* over this number */
+                       if (auxval = (val == CM))
+                               shift;  /* over the comma */
+               } while (auxval);       /* as long as there are commas */
        }
        break;
        }
        break;
+       /* end of the case for initialized big numbers */
     }  /*end of the switch for looking at each reserved word*/
 
     }  /*end of the switch for looking at each reserved word*/
 
-     continue;
+       continue;
 
    errorfix: 
        /*
 
    errorfix: 
        /*
@@ -1007,19 +961,19 @@ restlab:
  *     the digit, the scanner wouldn't have recognized it, so we
  *     hack it out here.
  */
  *     the digit, the scanner wouldn't have recognized it, so we
  *     hack it out here.
  */
-int funnyreg(val, regnoback)           /*what the read head will sit on*/
-       int     val;                    /*what the read head is sitting on*/
+inttoktype funnyreg(val, regnoback)    /*what the read head will sit on*/
+       inttoktype      val;            /*what the read head is sitting on*/
        int     *regnoback;             /*call by return*/
 {
        int     *regnoback;             /*call by return*/
 {
-       register        struct  exp *locxp;
-                       struct  exp *loc1xp;
-                       struct  exp **ptrloc1xp = & loc1xp;
+       reg     struct  exp *locxp;
+               struct  exp *loc1xp;
+               struct  exp **ptrloc1xp = & loc1xp;
 
        expr(locxp, val);       /*and leave the current read head with value*/
        if ( (passno == 2) &&
 
        expr(locxp, val);       /*and leave the current read head with value*/
        if ( (passno == 2) &&
-           (   locxp->e_xtype & XTYPE != XABS
-            || locxp->e_xvalue < 0
-            || locxp->e_xvalue >= 16 
+           (   (locxp->e_xtype & XTYPE) != XABS
+            || (locxp->e_xvalue < 0)
+            || (locxp->e_xvalue >= 16)
            )
          ){
                yyerror("Illegal register");
            )
          ){
                yyerror("Illegal register");
@@ -1028,6 +982,15 @@ int funnyreg(val, regnoback)              /*what the read head will sit on*/
        *regnoback = locxp->e_xvalue;
        return(val);
 } 
        *regnoback = locxp->e_xvalue;
        return(val);
 } 
+/*
+ *     Shift over error
+ */
+shiftoerror(token)
+       int     token;
+{
+       char    *tok_to_name();
+       yyerror("%s expected", tok_to_name(token));
+}
 
 /*VARARGS1*/
 yyerror(s, a1, a2,a3,a4,a5)
 
 /*VARARGS1*/
 yyerror(s, a1, a2,a3,a4,a5)
@@ -1036,12 +999,29 @@ yyerror(s, a1, a2,a3,a4,a5)
 
 #define        sink stdout
 
 
 #define        sink stdout
 
-       if (anyerrs == 0 && ! silent) 
+       if (anyerrs == 0 && anywarnings == 0 && ! silent) 
                fprintf(sink, "Assembler:\n");
        anyerrs++;
                fprintf(sink, "Assembler:\n");
        anyerrs++;
-       if (silent) return;
-       
+       if (silent)
+               return;
        fprintf(sink, "\"%s\", line %d: ", dotsname, lineno);
        fprintf(sink, s, a1, a2,a3,a4,a5);
        fprintf(sink, "\n");
        fprintf(sink, "\"%s\", line %d: ", dotsname, lineno);
        fprintf(sink, s, a1, a2,a3,a4,a5);
        fprintf(sink, "\n");
+#undef sink
+}
+
+/*VARARGS1*/
+yywarning(s, a1, a2,a3,a4,a5)
+       char    *s;
+{
+#define        sink stdout
+       if (anyerrs == 0 && anywarnings == 0 && ! silent) 
+               fprintf(sink, "Assembler:\n");
+       anywarnings++;
+       if (silent)
+               return;
+       fprintf(sink, "\"%s\", line %d: WARNING: ", dotsname, lineno);
+       fprintf(sink, s, a1, a2,a3,a4,a5);
+       fprintf(sink, "\n");
+#undef sink
 }
 }