no fread/fwrite in assembler, so don't have local fast version
[unix-history] / usr / src / old / as.vax / asmain.c
index f1a04ac..548a491 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1980 Regents of the University of California */
 /* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asmain.c 4.2 %G%";
+static char sccsid[] = "@(#)asmain.c 4.6 %G%";
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
@@ -10,7 +10,7 @@ static        char sccsid[] = "@(#)asmain.c 4.2 %G%";
 #include "asscan.h"
 
 #ifdef UNIX
 #include "asscan.h"
 
 #ifdef UNIX
-#define        unix_lang_name "VAX/UNIX Assembler Vasmain.c"
+#define        unix_lang_name "VAX/UNIX Assembler V%G% 4.6"
 #endif
 
 #ifdef VMS
 #endif
 
 #ifdef VMS
@@ -22,7 +22,7 @@ static        char sccsid[] = "@(#)asmain.c 4.2 %G%";
  */
 char   *dotsname;      /*the current file name; managed by the parser*/
 int    lineno;         /*current line number; managed by the parser*/
  */
 char   *dotsname;      /*the current file name; managed by the parser*/
 int    lineno;         /*current line number; managed by the parser*/
-char   *innames[32];   /*names of the files being assembled*/
+char   **innames;      /*names of the files being assembled*/
 int    ninfiles;       /*how many interesting files there are*/
 /*
  *     Flags settable from the argv process argument list
 int    ninfiles;       /*how many interesting files there are*/
 /*
  *     Flags settable from the argv process argument list
@@ -33,6 +33,8 @@ int   d124 = 4;       /*default allocate 4 bytes for unknown pointers*/
 int    anyerrs = 0;    /*no errors yet*/
 int    orgwarn = 0;    /*Bad origins*/
 int    passno = 1;     /* current pass*/
 int    anyerrs = 0;    /*no errors yet*/
 int    orgwarn = 0;    /*Bad origins*/
 int    passno = 1;     /* current pass*/
+int    jxxxJUMP = 0;   /* in jxxxes that branch too far, use jmp instead of brw */
+int    readonlydata = 0;       /* initialzed data -> text space */
 
 #ifdef DEBUG
 int    debug = 0;
 
 #ifdef DEBUG
 int    debug = 0;
@@ -53,7 +55,7 @@ char  *endcore;       /*where to get more symbol space*/
  *     Managers of the a.out file.
  */
 struct exec    hdr;
  *     Managers of the a.out file.
  */
 struct exec    hdr;
-#define        MAGIC   0410
+#define        MAGIC   0407
 u_long tsize;          /* total text size */
 u_long dsize;          /* total data size */
 u_long datbase;        /* base of the data segment */
 u_long tsize;          /* total text size */
 u_long dsize;          /* total data size */
 u_long datbase;        /* base of the data segment */
@@ -218,9 +220,12 @@ argprocess(argc, argv)
 #ifdef DEBUG
        debug = 0;
 #endif
 #ifdef DEBUG
        debug = 0;
 #endif
+       innames = (char **)ClearCalloc(argc+1, sizeof (innames[0]));
        dotsname = "<argv error>";
        while (argc > 1) {
        dotsname = "<argv error>";
        while (argc > 1) {
-               if (argv[1][0] == '-'){
+               if (argv[1][0] != '-')
+                       innames[ninfiles++] = argv[1];
+               else {
                        cp = argv[1] + 1;
                        /*
                         *      We can throw away single minus signs, so
                        cp = argv[1] + 1;
                        /*
                         *      We can throw away single minus signs, so
@@ -269,6 +274,9 @@ argprocess(argc, argv)
                                 case 'L':
                                        savelabels = 1;
                                        break;
                                 case 'L':
                                        savelabels = 1;
                                        break;
+                                case 'J':
+                                       jxxxJUMP = 1;
+                                       break;
 #ifdef DEBUG
                                 case 'D':
                                        debug = 1;
 #ifdef DEBUG
                                 case 'D':
                                        debug = 1;
@@ -277,19 +285,16 @@ argprocess(argc, argv)
                                        toktrace = 1;
                                        break;
 #endif
                                        toktrace = 1;
                                        break;
 #endif
+                                case 'R':
+                                       readonlydata = 1;
+                                       break;
                                }       /*end of the switch*/
                        }       /*end of pulling out all arguments*/
                }       /*end of a flag argument*/
                                }       /*end of the switch*/
                        }       /*end of pulling out all arguments*/
                }       /*end of a flag argument*/
-               else {  /*file name*/
-                       if (ninfiles > 32){
-                               yyerror("More than 32 file names");
-                               exit(3);
-                       }
-                       innames[ninfiles++] = argv[1];
-               }
                --argc; ++argv;
           nextarg:;
        }
                --argc; ++argv;
           nextarg:;
        }
+       /* innames[ninfiles] = 0; */
 }
 
 initialize()
 }
 
 initialize()
@@ -338,6 +343,8 @@ i_pass1()
 {
        if (useVM == 0){
                strcat(tmpn1, tmpdirprefix);
 {
        if (useVM == 0){
                strcat(tmpn1, tmpdirprefix);
+               if (tmpdirprefix[strlen(tmpdirprefix)-1] != '/')
+                       strcat(tmpn1, "/");
                strcat(tmpn1, TMP_SUFFIX);
                mktemp(tmpn1);
                tmpfil = fopen(tmpn1, "w");
                strcat(tmpn1, TMP_SUFFIX);
                mktemp(tmpn1);
                tmpfil = fopen(tmpn1, "w");
@@ -348,6 +355,7 @@ i_pass1()
        }
 
        inittmpfile();
        }
 
        inittmpfile();
+       initijxxx();
 }
 
 pass1()
 }
 
 pass1()
@@ -446,7 +454,7 @@ roundsegments()
        /*
         *              Round and assign data segment origins.
         */
        /*
         *              Round and assign data segment origins.
         */
-       datbase = round(tsize, PAGRND);
+       datbase = round(tsize, FW);
        for (locindex=0; locindex<NLOC; locindex++) {
                v = round(usedot[NLOC+locindex].e_xvalue, FW);
                usedot[NLOC+locindex].e_xvalue = datbase + dsize;
        for (locindex=0; locindex<NLOC; locindex++) {
                v = round(usedot[NLOC+locindex].e_xvalue, FW);
                usedot[NLOC+locindex].e_xvalue = datbase + dsize;
@@ -558,6 +566,12 @@ reloc_syms()
 
        hdr.a_trsize = trsize;
        hdr.a_drsize = drsize;
 
        hdr.a_trsize = trsize;
        hdr.a_drsize = drsize;
+       if (readonlydata) {
+               hdr.a_text += hdr.a_data;
+               hdr.a_data = 0;
+               hdr.a_trsize += hdr.a_drsize;
+               hdr.a_drsize = 0;
+       }
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool
        /*
         *      Output the symbol table
         *      and if FLEXNAMES is set, the string pool