The string pool is maintained both in core, and in a second tmp file.
authorRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Fri, 1 Jul 1983 10:03:49 +0000 (02:03 -0800)
committerRobert R. Henry <rrh@ucbvax.Berkeley.EDU>
Fri, 1 Jul 1983 10:03:49 +0000 (02:03 -0800)
names are in core and on the file; strings are just in the file.  The file
is maintained as a string table per a.out(5), and tacked onto the a.out file
at the very end.  The string table has more than need be, since discarde
labels and .ascii strings find their way (harmlessly) into the string table.
the string file maintained with stdio; nothing fancy, even if -V set

SCCS-vsn: old/as.vax/instrs 4.9
SCCS-vsn: old/as.vax/ascode.c 4.10
SCCS-vsn: old/as.vax/asjxxx.c 4.7
SCCS-vsn: old/as.vax/asmain.c 4.11
SCCS-vsn: old/as.vax/asparse.c 4.14
SCCS-vsn: old/as.vax/aspseudo.c 4.5
SCCS-vsn: old/as.vax/assyms.c 4.11
SCCS-vsn: old/as.vax/asscan1.c 4.5
SCCS-vsn: old/as.vax/as.h 4.15
SCCS-vsn: old/as.vax/asscan2.c 4.10
SCCS-vsn: old/as.vax/asscan.h 4.9

usr/src/old/as.vax/as.h
usr/src/old/as.vax/ascode.c
usr/src/old/as.vax/asjxxx.c
usr/src/old/as.vax/asmain.c
usr/src/old/as.vax/asparse.c
usr/src/old/as.vax/aspseudo.c
usr/src/old/as.vax/asscan.h
usr/src/old/as.vax/asscan1.c
usr/src/old/as.vax/asscan2.c
usr/src/old/as.vax/assyms.c
usr/src/old/as.vax/instrs

index 8558b0d..f9e7dbb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     Copyright (c) 1982 Regents of the University of California
 /*
  *     Copyright (c) 1982 Regents of the University of California
- *     @(#)as.h 4.14 %G%
+ *     @(#)as.h 4.15 %G%
  */
 #ifdef VMS
 # define       vax     1
  */
 #ifdef VMS
 # define       vax     1
@@ -249,10 +249,16 @@ struct symtab{
  *     with the old naming conventions.
  */
 #ifdef FLEXNAMES
  *     with the old naming conventions.
  */
 #ifdef FLEXNAMES
-#define        s_name  s_nm.n_un.n_name        /* name pointer */
+#define        s_name  s_nm.n_un.n_name
+#define        i_name  s_name
+#define        FETCHNAME(sp)   (((struct strdesc *)(sp)->s_name)->sd_string)
+#define        STRLEN(sp)      (((struct strdesc *)(sp)->s_name)->sd_strlen)
+#define        STROFF(sp)      (((struct strdesc *)(sp)->s_name)->sd_stroff)
 #define        s_nmx   s_nm.n_un.n_strx        /* string table index */
 #else  not FLEXNAMES
 #define        s_name  s_nm.n_name
 #define        s_nmx   s_nm.n_un.n_strx        /* string table index */
 #else  not FLEXNAMES
 #define        s_name  s_nm.n_name
+#define        i_name  s_name
+#define        FETCHNAME(sp)   ((sp)->s_name)
 #endif
 #define        s_type  s_nm.n_type             /* type of the symbol */
 #define        s_other s_nm.n_other            /* other information for sdb */
 #endif
 #define        s_type  s_nm.n_type             /* type of the symbol */
 #define        s_other s_nm.n_other            /* other information for sdb */
@@ -381,7 +387,33 @@ struct     exp {
 #define                ISUBYTE(x)      (((x) >= MINUBYTE) && ((x) <= MAXUBYTE))
 #define                ISWORD(x)       (((x) >= MINWORD) && ((x) <= MAXWORD))
 #define                ISUWORD(x)      (((x) >= MINUWORD) && ((x) <= MAXUWORD))
 #define                ISUBYTE(x)      (((x) >= MINUBYTE) && ((x) <= MAXUBYTE))
 #define                ISWORD(x)       (((x) >= MINWORD) && ((x) <= MAXWORD))
 #define                ISUWORD(x)      (((x) >= MINUWORD) && ((x) <= MAXUWORD))
+/*
+ *     Definitions for strings.
+ *
+ *     Strings are stored in the string pool; see strsave(str, length)
+ *     Strings are known by their length and values.
+ *     A string pointer points to the beginning of the value bytes;
+ *
+ *     If this structure is changed, change insts also.
+ */
+struct strdesc{
+       int     sd_stroff;      /* offset into string file */
+       short   sd_place;       /* where string is */
+       u_short sd_strlen;      /* string length */
+       char    sd_string[1];   /* the string itself, flexible length */
+};
+/*
+ *     Where a string can be.  If these are changed, also change instrs.
+ */
+#define        STR_FILE        0x1
+#define        STR_CORE        0x2
+#define        STR_BOTH        0x3
 
 
+struct strdesc *savestr();
+\f
+/*
+ *     Global variables
+ */
        extern  struct  arg     arglist[NARG];  /*building operands in instructions*/
        extern  struct  exp     explist[NEXP];  /*building up a list of expressions*/
        extern  struct  exp     *xp;            /*current free expression*/
        extern  struct  arg     arglist[NARG];  /*building operands in instructions*/
        extern  struct  exp     explist[NEXP];  /*building up a list of expressions*/
        extern  struct  exp     *xp;            /*current free expression*/
@@ -412,7 +444,6 @@ struct      exp {
        extern  int     lgensym[10];
        extern  char    genref[10];
 
        extern  int     lgensym[10];
        extern  char    genref[10];
 
-       extern  char    tmpn1[TNAMESIZE];       /* Interpass temporary */
        extern  struct  exp     *dotp;          /* the current dot location */
        extern  int     loctr;
 
        extern  struct  exp     *dotp;          /* the current dot location */
        extern  int     loctr;
 
@@ -440,7 +471,11 @@ struct     exp {
        extern  int     lineno;                 /*the line number*/
        extern  char    *dotsname;              /*the name of the as source*/
 
        extern  int     lineno;                 /*the line number*/
        extern  char    *dotsname;              /*the name of the as source*/
 
-       extern  FILE    *tmpfil;                /* interpass communication*/
+       extern  FILE    *tokfile;               /* temp token communication*/
+       extern  FILE    *strfile;               /* temp string file*/
+       extern  char    tokfilename[TNAMESIZE]; /* token file name */
+       extern  char    strfilename[TNAMESIZE]; /* string file name */
+       extern  int     strfilepos;             /* position in string file */
 
        extern  int     passno;                 /* 1 or 2 */
 
 
        extern  int     passno;                 /* 1 or 2 */
 
index 3eaf483..cd6a3a0 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)ascode.c 4.9 %G%";
+static char sccsid[] = "@(#)ascode.c 4.10 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -253,10 +253,10 @@ PASS2:
                                        xp->e_xvalue - (dotp->e_xvalue + 1);
                                if (xp->e_xtype & XXTRN)
                                        yywarning("%s: destination label is external",
                                        xp->e_xvalue - (dotp->e_xvalue + 1);
                                if (xp->e_xtype & XXTRN)
                                        yywarning("%s: destination label is external",
-                                               ITABFETCH(opcode)->s_name);
+                                               FETCHNAME(ITABFETCH(opcode)));
                                if (!ISBYTE(argtype))
                                        yyerror("%s: Branch too far(%db): try -J flag",
                                if (!ISBYTE(argtype))
                                        yyerror("%s: Branch too far(%db): try -J flag",
-                                               ITABFETCH(opcode)->s_name,
+                                               FETCHNAME(ITABFETCH(opcode)),
                                                argtype);
                                break;
                        }
                                                argtype);
                                break;
                        }
@@ -265,11 +265,11 @@ PASS2:
                                        -= dotp->e_xvalue + 2;
                                if (xp->e_xtype & XXTRN)
                                        yywarning("%s: destination label is external",
                                        -= dotp->e_xvalue + 2;
                                if (xp->e_xtype & XXTRN)
                                        yywarning("%s: destination label is external",
-                                               ITABFETCH(opcode)->s_name);
+                                               FETCHNAME(ITABFETCH(opcode)));
                                xp->e_xtype = XABS;
                                if (!ISWORD(argtype))
                                        yyerror("%s: Branch too far(%db): try -J flag",
                                xp->e_xtype = XABS;
                                if (!ISWORD(argtype))
                                        yyerror("%s: Branch too far(%db): try -J flag",
-                                               ITABFETCH(opcode)->s_name,
+                                               FETCHNAME(ITABFETCH(opcode)),
                                                argtype);
                                xp->e_xvalue = argtype>>8;
                                reloc_how = TYPB;
                                                argtype);
                                xp->e_xvalue = argtype>>8;
                                reloc_how = TYPB;
index b7156f9..71366f2 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asjxxx.c 4.6 %G%";
+static char sccsid[] = "@(#)asjxxx.c 4.7 %G%";
 #endif not lint
 
 #include       <stdio.h>
 #endif not lint
 
 #include       <stdio.h>
@@ -301,7 +301,8 @@ jxxxfix()
 #ifdef DEBUG
                                                if(debug)
                                                printf("Tunnel from %s from line %d\n",
 #ifdef DEBUG
                                                if(debug)
                                                printf("Tunnel from %s from line %d\n",
-                                                       jumpfrom->s_name, lineno);
+                                                       FETCHNAME(jumpfrom),
+                                                       lineno);
 #endif
                                                continue;
                                } else {        /*tunneling not possible*/
 #endif
                                                continue;
                                } else {        /*tunneling not possible*/
@@ -476,7 +477,7 @@ jxxxbump(segno, starthint)
                        if (debug){
                        if (sp->s_dest != 0)
                                printf("Explode jump to %s on line %d\n",
                        if (debug){
                        if (sp->s_dest != 0)
                                printf("Explode jump to %s on line %d\n",
-                                       sp->s_dest->s_name, lineno);
+                                       FETCHNAME(sp->s_dest), lineno);
                        else
                                printf("Explode an align!\n");
                        }
                        else
                                printf("Explode an align!\n");
                        }
index 0592cfe..e56de1d 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asmain.c 4.10 %G%";
+static char sccsid[] = "@(#)asmain.c 4.11 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -15,7 +15,7 @@ static char sccsid[] = "@(#)asmain.c 4.10 %G%";
 #include "asexpr.h"
 
 #ifdef UNIX
 #include "asexpr.h"
 
 #ifdef UNIX
-#define        unix_lang_name "VAX/UNIX Assembler V%G% 4.10"
+#define        unix_lang_name "VAX/UNIX Assembler V%G% 4.11"
 #endif
 
 #ifdef VMS
 #endif
 
 #ifdef VMS
@@ -82,11 +82,19 @@ u_long      drsize;         /* total data relocation size */
 struct exp     usedot[NLOC+NLOC];      /* info about all segments */
 struct exp     *dotp;                  /* data/text location pointer */
 /*
 struct exp     usedot[NLOC+NLOC];      /* info about all segments */
 struct exp     *dotp;                  /* data/text location pointer */
 /*
- *     The inter pass temporary file is opened and closed by stdio, but
+ *     The inter pass temporary token file is opened and closed by stdio, but
  *     is written to using direct read/write, as the temporary file
  *     is composed of buffers exactly BUFSIZ long.
  */
  *     is written to using direct read/write, as the temporary file
  *     is composed of buffers exactly BUFSIZ long.
  */
-FILE   *tmpfil;                        /* interpass communication file */
+FILE   *tokfile;                       /* interpass communication file */
+char   tokfilename[TNAMESIZE];
+/*
+ *     The string file is the string table
+ *     cat'ed to the end of the built up a.out file
+ */
+FILE   *strfile;                       /* interpass string file */
+char   strfilename[TNAMESIZE];
+int    strfilepos = 0;                 /* position within the string file */
 /*
  *     a.out is created during the second pass.
  *     It is opened by stdio, but is filled with the parallel
 /*
  *     a.out is created during the second pass.
  *     It is opened by stdio, but is filled with the parallel
@@ -171,8 +179,6 @@ char        *tmpdirprefix =
                        "/usr/tmp/";
 #endif
 
                        "/usr/tmp/";
 #endif
 
-#define                TMP_SUFFIX      "asXXXXXX"
-char           tmpn1[TNAMESIZE];
 
 int delexit();
 
 
 int delexit();
 
@@ -182,7 +188,8 @@ main(argc, argv)
 {
        char    *sbrk();
 
 {
        char    *sbrk();
 
-       tmpn1[0] = 0;
+       tokfilename[0] = 0;
+       strfilename[0] = 0;
        endcore = sbrk(0);
 
        argprocess(argc, argv);         /* process argument lists */
        endcore = sbrk(0);
 
        argprocess(argc, argv);         /* process argument lists */
@@ -394,23 +401,40 @@ zerolocals()
 
 i_pass1()
 {
 
 i_pass1()
 {
-       if (useVM == 0){
-               strcat(tmpn1, tmpdirprefix);
-               if (tmpdirprefix[strlen(tmpdirprefix)-1] != '/')
-                       strcat(tmpn1, "/");
-               (void)strcat(tmpn1, TMP_SUFFIX);
-               (void)mktemp(tmpn1);
-               tmpfil = fopen(tmpn1, "w");
-               if (tmpfil==NULL) {
-                 yyerror("Bad pass 1 temporary file for writing %s", tmpn1);
-                 delexit();
-               }
-       }
+       FILE    *tempopen();
+       if (useVM == 0)
+               tokfile = tempopen(tokfilename, "T");
+       strfile = tempopen(strfilename, "S");
+       /*
+        *      write out the string length.
+        *      This will be overwritten when the
+        *      strings are tacked onto the growing a.out file
+        */
+       strfilepos = sizeof(int);
+       fwrite(&strfilepos, sizeof(int), 1, strfile);
 
 
-       inittmpfile();
+       inittokfile();
        initijxxx();
 }
 
        initijxxx();
 }
 
+FILE *tempopen(tname, part)
+       char    *tname;
+       char    *part;
+{
+       FILE    *file;
+       sprintf(tname, "%s%sas%s%05d",
+               tmpdirprefix,
+               (tmpdirprefix[strlen(tmpdirprefix)-1] != '/') ? "/" : 0,
+               part,
+               getpid());
+       file = fopen(tname, "w");
+       if (file == NULL) {
+               yyerror("Bad pass 1 temporary file for writing %s", tname);
+               delexit();
+       }
+       return(file);
+}
+
 pass1()
 {
        register        int     i;
 pass1()
 {
        register        int     i;
@@ -439,7 +463,7 @@ pass1()
                }
        }
 
                }
        }
 
-       closetmpfile();         /*kick out the last buffered intermediate text*/
+       closetokfile();         /*kick out the last buffered intermediate text*/
 }
 
 testlocals()
 }
 
 testlocals()
@@ -560,13 +584,15 @@ build_hdr()
 i_pass2()
 {
        if (useVM == 0) {
 i_pass2()
 {
        if (useVM == 0) {
-               fclose(tmpfil);
-               tmpfil = fopen(tmpn1, "r");
-               if (tmpfil==NULL) {
-                  yyerror("Bad pass 2 temporary file for reading %s", tmpn1);
+               fclose(tokfile);
+               tokfile = fopen(tokfilename, "r");
+               if (tokfile==NULL) {
+                  yyerror("Bad pass 2 temporary file for reading %s", tokfilename);
                   delexit();
                }
        }
                   delexit();
                }
        }
+       fclose(strfile);
+       strfile = fopen(strfilename, "r");
 }
 
 pass2()
 }
 
 pass2()
@@ -582,11 +608,11 @@ pass2()
        relfil = 0;             /* outrel takes care of the rest */
        initoutrel();
 
        relfil = 0;             /* outrel takes care of the rest */
        initoutrel();
 
-       inittmpfile();
+       inittokfile();
 
        yyparse();
 
 
        yyparse();
 
-       closetmpfile();
+       closetokfile();
 }
 
 fillsegments()
 }
 
 fillsegments()
@@ -628,7 +654,12 @@ reloc_syms()
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool
+        *
+        *      We must first rewind the string pool file to its beginning,
+        *      in case it was seek'ed into for fetching ascii and asciz
+        *      strings.
         */
         */
+       fseek(strfile, 0, 0);
        symwrite(relocfile);
 }
 
        symwrite(relocfile);
 }
 
@@ -651,8 +682,10 @@ delexit()
 
 delete()
 {
 
 delete()
 {
-       if (useVM == 0 || tmpn1[0])
-               unlink(tmpn1);
+       if (useVM == 0 || tokfilename[0])
+               unlink(tokfilename);
+       if (strfilename[0])
+               unlink(strfilename);
 }
 
 sawabort()
 }
 
 sawabort()
index 7ad5b1b..d5cf43d 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asparse.c 4.13 %G%";
+static char sccsid[] = "@(#)asparse.c 4.14 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -44,7 +44,7 @@ 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*/
 
 yyparse()
 {
 
 yyparse()
 {
@@ -68,7 +68,7 @@ yyparse()
        reg     struct  symtab  *p;
        reg     struct  symtab  *stpt;
 
        reg     struct  symtab  *p;
        reg     struct  symtab  *stpt;
 
-               char    *stringp;       /*handles string lists*/
+               struct  strdesc *stringp;       /*handles string lists*/
 
                int     regno;          /*handles arguments*/
                int     *ptrregno = &regno;
 
                int     regno;          /*handles arguments*/
                int     *ptrregno = &regno;
@@ -137,7 +137,7 @@ yyparse()
                                yyerror("\"%.*s\" is not followed by a ':' for a label definition",
                                        NCPName,
 #endif not FLEXNAMES
                                yyerror("\"%.*s\" is not followed by a ':' for a label definition",
                                        NCPName,
 #endif not FLEXNAMES
-                                       np->s_name);
+                                       FETCHNAME(np));
                                goto  errorfix;
                        }
 restlab:
                                goto  errorfix;
                        }
 restlab:
@@ -151,7 +151,7 @@ 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)
@@ -161,7 +161,7 @@ restlab:
                                                  yyerror("%.*s redefined",
                                                        NCPName,
 #endif not FLEXNAMES 
                                                  yyerror("%.*s redefined",
                                                        NCPName,
 #endif not FLEXNAMES 
-                                                       np->s_name);
+                                                       FETCHNAME(np));
                                                else
 #ifdef FLEXNAMES
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                else
 #ifdef FLEXNAMES
                                                  yyerror("%s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
@@ -169,7 +169,7 @@ restlab:
                                                  yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                        NCPName,
 #endif not FLEXNAMES
                                                  yyerror("%.*s redefined: PHASE ERROR, 1st: %d, 2nd: %d",
                                                        NCPName,
 #endif not FLEXNAMES
-                                                       np->s_name,
+                                                       FETCHNAME(np),
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
                                                        np->s_value,
                                                        dotp->e_xvalue);
                                        }
@@ -180,7 +180,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;
@@ -214,10 +214,11 @@ restlab:
 
    case IFILE:
        shift;
 
    case IFILE:
        shift;
-       stringp = (char *)yylval;
+       stringp = (struct strdesc *)yylval;
        shiftover(STRING);
        dotsname = &UDotsname[0];
        shiftover(STRING);
        dotsname = &UDotsname[0];
-       movestr(dotsname, stringp, min(STRLEN(stringp), sizeof(dotsname)));
+       movestr(dotsname, stringp->sd_string,
+               min(stringp->sd_strlen, sizeof(UDotsname)));
        break;
 
    case ILINENO:
        break;
 
    case ILINENO:
@@ -259,7 +260,7 @@ restlab:
 #ifdef FLEXNAMES
                stpt->s_name = np->s_name;
 #else
 #ifdef FLEXNAMES
                stpt->s_name = np->s_name;
 #else
-               movestr(stpt->s_name, np->s_name, NCPName);
+               movestr(FETCHNAME(stpt), FETCHNAME(np), NCPName);
 #endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
 #endif
                np->s_tag = OBSOLETE;   /*invalidate original */
                nforgotten++;
@@ -487,18 +488,36 @@ restlab:
         *      stringlist: empty | STRING | stringlist STRING
         */
        while (val == STRING){
         *      stringlist: empty | STRING | stringlist STRING
         */
        while (val == STRING){
+               int     mystrlen;
                flushfield(NBPW/4);
                if (bitoff)
                        dotp->e_xvalue++;
                flushfield(NBPW/4);
                if (bitoff)
                        dotp->e_xvalue++;
-               stringp = (char *)yylval;
+               stringp = (struct strdesc *)yylval;
                /*
                /*
-                *      utilize the string scanner cheat,
-                *      where it appended a null byte on the string,
-                *      but didn't charge it to STRLEN
+                *      utilize the string scanner cheat;
+                *      the scanner appended a null byte on the string,
+                *      but didn't charge it to sd_strlen
                 */
                 */
-               STRLEN(stringp) += (auxval == IASCIZ) ? 1 : 0;
+               mystrlen = stringp->sd_strlen;
+               mystrlen += (auxval == IASCIZ) ? 1 : 0;
 #ifdef UNIX
 #ifdef UNIX
-               outs(stringp, STRLEN(stringp));
+               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 UNIX
 #ifdef VMS
                {
 #endif UNIX
 #ifdef VMS
                {
@@ -581,7 +600,7 @@ restlab:
        shift;
        for (argcnt = 0; argcnt < NCPName; argcnt++){
                expr(locxp, val);
        shift;
        for (argcnt = 0; argcnt < NCPName; argcnt++){
                expr(locxp, val);
-               stpt->s_name[argcnt] = locxp->e_xvalue;
+               FETCHNAME(stpt)[argcnt] = locxp->e_xvalue;
                xp = explist;
                shiftover(CM);
        }
                xp = explist;
                shiftover(CM);
        }
@@ -724,27 +743,32 @@ restlab:
        (bytetoktype *)stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
        (bytetoktype *)stabstart -= sizeof(bytetoktype);
        shift;
        if (auxval == ISTABSTR){
-               stringp = (char *)yylval;
+               stringp = (struct strdesc *)yylval;
                shiftover(STRING);
 #ifndef FLEXNAMES
                shiftover(STRING);
 #ifndef FLEXNAMES
-               movestr(stpt->s_name, stringp, min(STRLEN(stringp), NCPName));
+               movestr(FETCHNAME(stpt), stringp,
+                       min(stringp->sd_strlen, NCPName));
 #else
 #else
-               stpt->s_name = stringp;
+               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
                 */
                /*
                 *      We want the trailing null included in this string.
                 *      We utilize the cheat the string scanner used,
                 *      and merely increment the string length
                 */
-               STRLEN(stringp) += 1;
+               stringp->sd_strlen += 1;
 #endif
                shiftover(CM);
        } else {
 #ifndef FLEXNAMES
                static char nullstr[NCPName];
 #endif
                shiftover(CM);
        } else {
 #ifndef FLEXNAMES
                static char nullstr[NCPName];
-               movestr(stpt->s_name, nullstr, NCPName);
+               movestr(FETCHNAME(stpt), nullstr, NCPName);
 #else
                static char nullstr[1];
 #else
                static char nullstr[1];
-               stpt->s_name = savestr(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);
 #endif
        }
        goto tailstab;
 #endif
        }
        goto tailstab;
@@ -768,7 +792,7 @@ restlab:
                yyerror("Redefinition of %.*s",
                        NCPName,
 #endif not FLEXNAMES
                yyerror("Redefinition of %.*s",
                        NCPName,
 #endif not FLEXNAMES
-                       np->s_name);
+                       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)
index 66fb73e..8b7d885 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)aspseudo.c 4.4 %G%";
+static char sccsid[] = "@(#)aspseudo.c 4.5 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -21,5 +21,5 @@ static char sccsid[] = "@(#)aspseudo.c 4.4 %G%";
 
 readonly struct Instab instab[] = {
 #include "instrs.as"
 
 readonly struct Instab instab[] = {
 #include "instrs.as"
-0
+PSEUDO("\0\0\0\0\0\0\0\0\0\0", 0, 0)
 };
 };
index ddc7164..d2adb0f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *     Copyright (c) 1982 Regents of the University of California
 /*
  *     Copyright (c) 1982 Regents of the University of California
- *     @(#)asscan.h 4.8 %G%
+ *     @(#)asscan.h 4.9 %G%
  */
 /*
  *     The character scanner is called to fill up one token buffer
  */
 /*
  *     The character scanner is called to fill up one token buffer
@@ -84,11 +84,3 @@ typedef u_short lgtype;                      /*for storing length of strings or skiping*/
 
 extern ptrall tokptr;  /*the next token to consume, call by copy*/
 extern ptrall tokub;   /*current upper bound in the current buffer*/
 
 extern ptrall tokptr;  /*the next token to consume, call by copy*/
 extern ptrall tokub;   /*current upper bound in the current buffer*/
-/*
- *     Strings are stored in the string pool; see strsave(str, length)
- *     Strings are known by their length and values.
- *     A string pointer points to the beginning of the value bytes;
- *     the preceding two bytes are the length.
- */
-#define        STRLEN(str)     (((lgtype *)str)[-1])
-char *savestr();
index 4036af9..d1ee1b2 100644 (file)
@@ -2,12 +2,12 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asscan1.c 4.4 %G%";
+static char sccsid[] = "@(#)asscan1.c 4.5 %G%";
 #endif not lint
 
 #include "asscanl.h"
 
 #endif not lint
 
 #include "asscanl.h"
 
-inittmpfile()
+inittokfile()
 {
        if (passno == 1){
                if (useVM){
 {
        if (passno == 1){
                if (useVM){
@@ -27,7 +27,7 @@ inittmpfile()
        tokub = 0;
 }
 
        tokub = 0;
 }
 
-closetmpfile()
+closetokfile()
 {
        if (passno == 1){
                if (useVM){
 {
        if (passno == 1){
                if (useVM){
@@ -38,7 +38,7 @@ closetmpfile()
                         *      written out yet
                         */
                        if (tokbuf[bufno ^ 1].tok_count >= 0){
                         *      written out yet
                         */
                        if (tokbuf[bufno ^ 1].tok_count >= 0){
-                               if (writeTEST((char *)&tokbuf[bufno ^ 1], sizeof *emptybuf, 1, tmpfil)){
+                               if (writeTEST((char *)&tokbuf[bufno ^ 1], sizeof *emptybuf, 1, tokfile)){
                                  badwrite:
                                        yyerror("Unexpected end of file writing the interpass tmp file");
                                exit(2);
                                  badwrite:
                                        yyerror("Unexpected end of file writing the interpass tmp file");
                                exit(2);
@@ -50,7 +50,7 @@ closetmpfile()
                         *      in the argument list
                         */
                        tokbuf[bufno].toks[tokbuf[bufno].tok_count++] = PARSEEOF;
                         *      in the argument list
                         */
                        tokbuf[bufno].toks[tokbuf[bufno].tok_count++] = PARSEEOF;
-                       if (writeTEST((char *)&tokbuf[bufno], sizeof *emptybuf, 1, tmpfil))
+                       if (writeTEST((char *)&tokbuf[bufno], sizeof *emptybuf, 1, tokfile))
                                goto badwrite;
                }
        }       /*end of being pass 1*/
                                goto badwrite;
                }
        }       /*end of being pass 1*/
@@ -148,7 +148,7 @@ inttoktype yylex()
                case    BIGNUM: bignumprint(((struct exp*)yylval)->e_number);
                                break;
                case    NAME:   printf("\"%.8s\"",
                case    BIGNUM: bignumprint(((struct exp*)yylval)->e_number);
                                break;
                case    NAME:   printf("\"%.8s\"",
-                                       ((struct symtab *)yylval)->s_name);
+                                       FETCHNAME((struct symtab *)yylval));
                                break;
                case    REG:    printf(" r%d",
                                        yylval);
                                break;
                case    REG:    printf(" r%d",
                                        yylval);
@@ -156,7 +156,8 @@ inttoktype yylex()
                case    IJXXX:
                case    INST0:  
                case    INSTn:  if (ITABCHECK(yyopcode))
                case    IJXXX:
                case    INST0:  
                case    INSTn:  if (ITABCHECK(yyopcode))
-                                       printf("%.8s", ITABFETCH(yyopcode)->s_name);
+                                       printf("%.8s",
+                                               FETCHNAME(ITABFETCH(yyopcode)));
                                else
                                        printf("IJXXX or INST0 or INSTn can't get into the itab\n");
                                break;
                                else
                                        printf("IJXXX or INST0 or INSTn can't get into the itab\n");
                                break;
@@ -208,14 +209,14 @@ inttoktype yylex()
                         *      out at all
                         */
                        if (emptybuf->tok_count >= 0){
                         *      out at all
                         */
                        if (emptybuf->tok_count >= 0){
-                           if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tmpfil)){
+                           if (writeTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
                                yyerror("Unexpected end of file writing the interpass tmp file");
                                exit(2);
                            }
                        }
                        scan_dot_s(emptybuf);
                } else {        /*pass 2*/
                                yyerror("Unexpected end of file writing the interpass tmp file");
                                exit(2);
                            }
                        }
                        scan_dot_s(emptybuf);
                } else {        /*pass 2*/
-                   if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tmpfil)){
+                   if (readTEST((char *)emptybuf, sizeof *emptybuf, 1, tokfile)){
                         badread:
                             yyerror("Unexpected end of file while reading the interpass tmp file");
                             exit(1);
                         badread:
                             yyerror("Unexpected end of file while reading the interpass tmp file");
                             exit(1);
index 197024f..3ad6369 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)asscan2.c 4.9 %G%";
+static char sccsid[] = "@(#)asscan2.c 4.10 %G%";
 #endif not lint
 
 #include "asscanl.h"
 #endif not lint
 
 #include "asscanl.h"
@@ -73,10 +73,11 @@ scan_dot_s(bufferbox)
                ptrall  lgbackpatch;    /* where to stuff a string length */
        reg     ptrall  bufptr;         /* where to stuff tokens */
                ptrall  bufub;          /* where not to stuff tokens */
                ptrall  lgbackpatch;    /* where to stuff a string length */
        reg     ptrall  bufptr;         /* where to stuff tokens */
                ptrall  bufub;          /* where not to stuff tokens */
-       reg     int     maxstrlg;       /* how long a string can be */
+       reg     int     strlg;          /* the length of a string */
                long    intval;         /* value of int */
                int     linescrossed;   /* when doing strings and comments */
                struct  Opcode          opstruct;
                long    intval;         /* value of int */
                int     linescrossed;   /* when doing strings and comments */
                struct  Opcode          opstruct;
+               struct  strdesc strd;   /* for building DQ strings */
 
        (bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]); 
        (bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
 
        (bytetoktype *)bufptr = (bytetoktype *) & (bufferbox->toks[0]); 
        (bytetoktype *)bufub = &(bufferbox->toks[AVAILTOKS]);
@@ -84,7 +85,13 @@ scan_dot_s(bufferbox)
        MEMTOREGBUF;
        if (newfflag){
                newfflag = 0;
        MEMTOREGBUF;
        if (newfflag){
                newfflag = 0;
-               ryylval = (int)savestr(newfname, strlen(newfname) + 1);
+               strd.sd_stroff = strfilepos;
+               strd.sd_place = STR_BOTH;
+               strd.sd_strlen = strlen(newfname) + 1;
+               fputs(newfname, strfile);
+               putc(0, strfile);
+               strfilepos += strd.sd_strlen;
+               ryylval = (int)savestr(newfname, &strd);
 
                ptoken(bufptr, IFILE);
                ptoken(bufptr, STRING);
 
                ptoken(bufptr, IFILE);
                ptoken(bufptr, STRING);
@@ -253,7 +260,7 @@ scan_dot_s(bufferbox)
                case 0:
                case LABELID:
                        /*
                case 0:
                case LABELID:
                        /*
-                        *      Its a name... (Labels are subsets ofname)
+                        *      Its a name... (Labels are subsets of name)
                         */
                        ryylval = (int)op;
                        val = NAME;
                         */
                        ryylval = (int)op;
                        val = NAME;
@@ -316,13 +323,15 @@ scan_dot_s(bufferbox)
        case DQ:
           eatstr:
                linescrossed = 0;
        case DQ:
           eatstr:
                linescrossed = 0;
-               for(rcp = strtext, maxstrlg = NCPString; maxstrlg > 0; --maxstrlg){
+               strd.sd_stroff = strfilepos;
+               strd.sd_place = STR_FILE;
+               for (strd.sd_strlen = 0; /*VOID*/; strd.sd_strlen++){
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
                    default:
                    stuff:
                    switch(ch = getchar()){
                    case '"':
                        goto tailDQ;
                    default:
                    stuff:
-                       pchar(rcp, ch);
+                       putc(ch, strfile);
                        break;
                    case '\n':
                        yywarning("New line in a string constant");
                        break;
                    case '\n':
                        yywarning("New line in a string constant");
@@ -331,7 +340,7 @@ scan_dot_s(bufferbox)
                        ch = getchar();
                        switch(ch){
                        case EOFCHAR:
                        ch = getchar();
                        switch(ch){
                        case EOFCHAR:
-                               pchar(rcp, '\n');
+                               putc('\n', strfile);
                                ungetc(EOFCHAR);
                                goto tailDQ;
                        default:
                                ungetc(EOFCHAR);
                                goto tailDQ;
                        default:
@@ -378,18 +387,17 @@ scan_dot_s(bufferbox)
                /*
                 *      put the string in strtext into the string pool
                 *
                /*
                 *      put the string in strtext into the string pool
                 *
-                *      The value in ryylval points to the string;
-                *      the previous 2 bytes is the length of the string
-                *
                 *      Cheat: append a trailing null to the string
                 *      and then adjust the string length to ignore
                 *      the trailing null.  If any STRING client requires
                 *      the trailing null, the client can just change STRLEN
                 */
                val = STRING;
                 *      Cheat: append a trailing null to the string
                 *      and then adjust the string length to ignore
                 *      the trailing null.  If any STRING client requires
                 *      the trailing null, the client can just change STRLEN
                 */
                val = STRING;
-               *rcp++ = 0;
-               ryylval = (int)savestr(strtext, rcp - strtext);
-               STRLEN(((char *)ryylval)) -= 1;
+               putc(0, strfile);
+               strd.sd_strlen += 1;
+               strfilepos += strd.sd_strlen;
+               ryylval = (int)savestr(strtext, &strd);
+               ((struct strdesc *)ryylval)->sd_strlen -= 1;
                goto ret;
 
        case BADCHAR:
                goto ret;
 
        case BADCHAR:
index d45cf70..5c18d8d 100644 (file)
@@ -2,7 +2,7 @@
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
  *     Copyright (c) 1982 Regents of the University of California
  */
 #ifndef lint
-static char sccsid[] = "@(#)assyms.c 4.10 %G%";
+static char sccsid[] = "@(#)assyms.c 4.11 %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -69,12 +69,8 @@ syminstall()
        for (i = 0; i < NINST; i++)
                itab[i] = (Iptr*)BADPOINT;
 
        for (i = 0; i < NINST; i++)
                itab[i] = (Iptr*)BADPOINT;
 
-#ifdef FLEXNAMES
-       for (ip = (Iptr)instab; ip->s_name != 0; ip++) {
-#else not FLEXNAMES
-       for (ip = (Iptr)instab; ip->s_name[0] != '\0'; ip++){
-#endif not FLEXNAMES
-               p1 = ip->s_name;
+       for (ip = (Iptr)instab; FETCHNAME(ip)[0]; ip++) {
+               p1 = FETCHNAME(ip);
                p2 = yytext;
                while (*p2++ = *p1++);
                hp = lookup(0);         /* 0 => don't install this*/
                p2 = yytext;
                while (*p2++ = *p1++);
                hp = lookup(0);         /* 0 => don't install this*/
@@ -133,7 +129,7 @@ freezesymtab()
                        hdr.a_bss += bs;
                }
           assignindex:
                        hdr.a_bss += bs;
                }
           assignindex:
-               if (    (sp->s_name[0] != 'L')
+               if (    (FETCHNAME(sp)[0] != 'L')
                     || (sp->s_tag != LABELID)
                     || savelabels
                     )                  /*then, we will write it later on*/
                     || (sp->s_tag != LABELID)
                     || savelabels
                     )                  /*then, we will write it later on*/
@@ -324,12 +320,12 @@ dumpsymtab()
                SEGITERATE(segno, 0, 0, cosp, sp, ub, ++){
 #ifdef FLEXNAMES
                        printf("\tSeg: %d \"%s\" value: %d index: %d tag %s\n",
                SEGITERATE(segno, 0, 0, cosp, sp, ub, ++){
 #ifdef FLEXNAMES
                        printf("\tSeg: %d \"%s\" value: %d index: %d tag %s\n",
-                               segno, sp->s_name,
+                               segno, FETCHNAME(sp),
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #else not FLEXNAMES
                        printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #else not FLEXNAMES
                        printf("\tSeg: %d \"%*.*s\" value: %d index: %d tag %s\n",
-                               segno, NCPName, NCPName, sp->s_name,
+                               segno, NCPName, NCPName, FETCHNAME(sp),
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #endif not FLEXNAMES
                                sp->s_value, sp->s_index,
                                tagstring(sp->s_tag));
 #endif not FLEXNAMES
@@ -400,10 +396,11 @@ struct symtab **lookup(instflg)
        register char           *to;
        register        int     len;
        register        int     nprobes;
        register char           *to;
        register        int     len;
        register        int     nprobes;
-       static   struct hashdallop *hdallop;
-       static   struct symtab  **emptyslot;
-       static   struct hashdallop *emptyhd;
-       static   struct symtab  **hp_ub;
+       static  struct  hashdallop *hdallop;
+       static  struct  symtab  **emptyslot;
+       static  struct  hashdallop *emptyhd;
+       static  struct  symtab  **hp_ub;
+       static  struct  strdesc strdp;
 
        emptyslot = 0;
        for (nprobes = 0, from = yytext;
 
        emptyslot = 0;
        for (nprobes = 0, from = yytext;
@@ -426,7 +423,7 @@ struct symtab **lookup(instflg)
                                nprobes += 2)
                {
                        from = yytext;
                                nprobes += 2)
                {
                        from = yytext;
-                       to = (*hp)->s_name;
+                       to = FETCHNAME(*hp);
 #ifndef FLEXNAMES
                        for (len = 0; (len<NCPName) && *from; len++)
                                if (*from++ != *to++)
 #ifndef FLEXNAMES
                        for (len = 0; (len<NCPName) && *from; len++)
                                if (*from++ != *to++)
@@ -463,37 +460,46 @@ struct symtab **lookup(instflg)
                *hp = symalloc();
                hdallop->h_nused++;
 #ifndef FLEXNAMES
                *hp = symalloc();
                hdallop->h_nused++;
 #ifndef FLEXNAMES
-               strncpy((*hp)->s_name, yytext, NCPName);
+               strncpy(FETCHNAME(*hp), yytext, NCPName);
 #else FLEXNAMES
                for (from = yytext, len = 0; *from++; len++)
                        continue;
                /*
 #else FLEXNAMES
                for (from = yytext, len = 0; *from++; len++)
                        continue;
                /*
-                *      save string and trailing null
+                *      save string and trailing null, both
+                *      internally, and in the string temporary file
                 */
                 */
-               (*hp)->s_name = savestr(yytext, len + 1);
+               strdp.sd_stroff = strfilepos;
+               strdp.sd_place = STR_BOTH;
+               strdp.sd_strlen = len + 1;      /* length and null */
+               fputs(yytext, strfile);         /* string */
+               putc(0, strfile);               /* null */
+               strfilepos += strdp.sd_strlen;
+               (*hp)->s_name = (char *)savestr(yytext, &strdp);
 #endif FLEXNAMES
        }
        return(hp);
 }      /*end of lookup*/
 /*
 #endif FLEXNAMES
        }
        return(hp);
 }      /*end of lookup*/
 /*
- *     save a string str, length len in the string pool.
- *     string known just by its length; can have or not have trailing nulls.
- *
- *     The length of the string occurs as a short just before
- *     the character pointer returned.
+ *     save a string str, descriptor strdp, in the string pool
  */
  */
-char *savestr(str, len)
+struct strdesc *savestr(str, strdp)
        char    *str;
        char    *str;
-       int     len;
+       struct  strdesc *strdp;
 {
 {
-       char    *res;
+       reg     struct  strdesc *res;
+               int     tlen;
+
+       tlen = sizeof(struct strdesc) - sizeof(res->sd_string);
+       if (strdp->sd_place & STR_FILE)
+               tlen += strdp->sd_strlen;
 
 
-       if (len + sizeof(lgtype) >= (STRPOOLDALLOP - strplhead->str_nalloc))
+       if (tlen >= (STRPOOLDALLOP - strplhead->str_nalloc))
                strpoolalloc();
                strpoolalloc();
-       res = strplhead->str_names + strplhead->str_nalloc;
-       plgtype(res, len);
-       movestr(res, str, len);
-       strplhead->str_nalloc += sizeof(lgtype) + len;
+       res = (struct strdesc *)(strplhead->str_names + strplhead->str_nalloc);
+       res[0] = *strdp;
+       if (strdp->sd_place & STR_FILE)
+               movestr(res[0].sd_string, str, strdp->sd_strlen);
+       strplhead->str_nalloc += tlen;
        return(res);
 }
 
        return(res);
 }
 
@@ -669,12 +675,14 @@ int sizesymtab()
 int symwrite(symfile)
        BFILE *symfile;
 {
 int symwrite(symfile)
        BFILE *symfile;
 {
-       int     symsout;                        /*those actually written*/
-       int     symsdesired = NOUTSYMS;
-       register        struct  symtab *sp, *ub;
+               int     symsout;                /*those actually written*/
+               int     symsdesired = NOUTSYMS;
+       reg     struct  symtab *sp, *ub;
 #ifdef FLEXNAMES
 #ifdef FLEXNAMES
-       char            *name;                  /* temp to save the name */
-       long            stroff  = sizeof (stroff);
+               char    *name;                  /* temp to save the name */
+               int     nread;
+               char    rbuf[2048];
+               int     i;
        /*
         *      We use sp->s_index to hold the length of the
         *      name; it isn't used for anything else
        /*
         *      We use sp->s_index to hold the length of the
         *      name; it isn't used for anything else
@@ -688,7 +696,7 @@ int symwrite(symfile)
        {
                if (sp->s_tag >= IGNOREBOUND) 
                        continue;
        {
                if (sp->s_tag >= IGNOREBOUND) 
                        continue;
-               if ((sp->s_name[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
+               if ((FETCHNAME(sp)[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
                        continue;
                symsout++;
 
                        continue;
                symsout++;
 
@@ -698,13 +706,15 @@ int symwrite(symfile)
                 *      the length of the symbol table string
                 *      always includes the trailing null
                 */
                 *      the length of the symbol table string
                 *      always includes the trailing null
                 */
-               if (sp->s_name && (sp->s_index = STRLEN(sp->s_name))){
-                       sp->s_nmx = stroff;     /* clobber pointer */
-                       stroff += sp->s_index;
+               if (sp->s_name && (sp->s_index = STRLEN(sp))){
+                       sp->s_nmx = STROFF(sp); /* clobber */
                } else {
                        sp->s_nmx = 0;
                }
                } else {
                        sp->s_nmx = 0;
                }
-#endif
+#ifdef DEBUG
+               printf("symbol %d: nmx == %d\n", symsout, sp->s_nmx);
+#endif DEBUG
+#endif FLEXNAMES
                sp->s_type = (sp->s_ptype != 0) ? sp->s_ptype : (sp->s_type & (~XFORW));
                if (readonlydata && (sp->s_type&~N_EXT) == N_DATA)
                        sp->s_type = N_TEXT | (sp->s_type & N_EXT);
                sp->s_type = (sp->s_ptype != 0) ? sp->s_ptype : (sp->s_type & (~XFORW));
                if (readonlydata && (sp->s_type&~N_EXT) == N_DATA)
                        sp->s_type = N_TEXT | (sp->s_type & N_EXT);
@@ -718,21 +728,21 @@ int symwrite(symfile)
                        symsout, symsdesired);
 #ifdef FLEXNAMES
        /*
                        symsout, symsdesired);
 #ifdef FLEXNAMES
        /*
-        *      Pass 2 through the string pool
+        *      Copy the string temporary file to the symbol file,
+        *      copying all the strings and symbols we ever saw,
+        *      including labels, stabs strings, ascii strings, etc.
+        *      This is slightly wasteful.
         */
         */
-       symsout = 0;
-       bwrite((char *)&stroff, sizeof (stroff), symfile);
-       stroff = sizeof (stroff);
-       symsout = 0;
-       DECLITERATE(allocwalk, sp, ub)
-       {
-               if (sp->s_tag >= IGNOREBOUND) 
-                       continue;
-               if ((sp->s_name[0] == 'L') && (sp->s_tag == LABELID) && !savelabels)
-                       continue;
-               if (sp->s_name && (sp->s_index = STRLEN(sp->s_name))){
-                       bwrite(sp->s_name, sp->s_index, symfile);
+       i = 0;
+       while((nread = read(strfile->_file, rbuf, sizeof(rbuf))) > 0){
+               if (i == 0){
+#ifdef DEBUG
+                       printf("%d bytes of strings\n", strfilepos);
+#endif DEBUG
+                       ((int *)rbuf)[0] = strfilepos;
                }
                }
+               bwrite(rbuf, nread, symfile);
+               i++;
        }
 #endif FLEXNAMES
 }
        }
 #endif FLEXNAMES
 }
index 0e46adf..c5eaaf3 100644 (file)
@@ -1,6 +1,6 @@
 ##
 ##     Copyright (c) 1982 Regents of the University of California
 ##
 ##     Copyright (c) 1982 Regents of the University of California
-##     @(#)instrs 4.8 %G%
+##     @(#)instrs 4.9 %G%
 ##
 ##     Robert R. Henry
 ##     University of California, Berkeley
 ##
 ##     Robert R. Henry
 ##     University of California, Berkeley
 
 BEGIN{
        flavor = AS;
 
 BEGIN{
        flavor = AS;
+       ##
+       ##      magic padding before the string for AS
+       ##      4 bytes of 0's: seek position of the string
+       ##      2 bytes, value 2, indicating core resident
+       ##      2 bytes, value 0, length
+       ##
+       ASpad = "\\0\\0\\0\\0" "\\2\\0";
 }
 {
        if (NF == 0){
 }
 {
        if (NF == 0){
@@ -137,7 +144,8 @@ BEGIN{
                if (flavor == "AS"){
                        if ($4 == "CBR")
                                $4 = "IJXXX";
                if (flavor == "AS"){
                        if ($4 == "CBR")
                                $4 = "IJXXX";
-                       printf("PSEUDO(\"%s\", %s, %s),\n", $3, $7, $4);
+                       printf("PSEUDO(\"%s\\0%o\\0%s\",", ASpad,length($3),$3);
+                       printf("%s, %s),\n", $7, $4);
                        next;
                }
                if (flavor == "C2"){
                        next;
                }
                if (flavor == "C2"){
@@ -182,8 +190,13 @@ BEGIN{
                printf("T(%s,%s),\n", $4, $5);  # special value
                next;
        }
                printf("T(%s,%s),\n", $4, $5);  # special value
                next;
        }
-       if (flavor == "AS" || flavor == "ADB"){
+       if (flavor == "AS"){
+               printf("OP(\"%s\\0%o\\0%s\", ", ASpad, length($3), $3);
+               printf("%s, %s, %d", $6, $7, $8);
+       } else {
                printf("OP(\"%s\", %s, %s, %d", $3, $6, $7, $8);
                printf("OP(\"%s\", %s, %s, %d", $3, $6, $7, $8);
+       }
+       if (flavor == "AS" || flavor == "ADB"){
                for (i = 9; i+1 <= NF; i = i + 2){
                        printf(", A_%s%s", $i, $(i+1));
                }
                for (i = 9; i+1 <= NF; i = i + 2){
                        printf(", A_%s%s", $i, $(i+1));
                }