date and time created 88/07/22 16:08:01 by bostic
[unix-history] / usr / src / old / as.vax / asmain.c
index e56de1d..f8d32cc 100644 (file)
@@ -1,8 +1,17 @@
 /*
 /*
- *     Copyright (c) 1982 Regents of the University of California
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  */
  */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1982 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)asmain.c 4.11 %G%";
+static char sccsid[] = "@(#)asmain.c   5.3 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -14,14 +23,9 @@ static char sccsid[] = "@(#)asmain.c 4.11 %G%";
 #include "asscan.h"
 #include "asexpr.h"
 
 #include "asscan.h"
 #include "asexpr.h"
 
-#ifdef UNIX
-#define        unix_lang_name "VAX/UNIX Assembler V%G% 4.11"
-#endif
-
-#ifdef VMS
-#define vms_lang_name "VAX/VMS C Assembler V1.00"
-#endif VMS
+#include <sys/stat.h>
 
 
+#define        unix_lang_name "VAX/UNIX Assembler V%G% 5.3"
 /*
  *     variables to manage reading the assembly source files
  */
 /*
  *     variables to manage reading the assembly source files
  */
@@ -35,6 +39,7 @@ int   ninfiles;       /*how many interesting files there are*/
 int    silent = 0;     /*don't complain about any errors*/
 int    savelabels = 0; /*write the labels to the a.out file*/
 int    d124 = 4;       /*default allocate 4 bytes for unknown pointers*/
 int    silent = 0;     /*don't complain about any errors*/
 int    savelabels = 0; /*write the labels to the a.out file*/
 int    d124 = 4;       /*default allocate 4 bytes for unknown pointers*/
+int    maxalign = 2;   /*default .align maximum*/
 int    anyerrs = 0;    /*no errors yet*/
 int    anywarnings=0;  /*no warnings yet*/
 int    orgwarn = 0;    /*Bad origins*/
 int    anyerrs = 0;    /*no errors yet*/
 int    anywarnings=0;  /*no warnings yet*/
 int    orgwarn = 0;    /*Bad origins*/
@@ -51,13 +56,7 @@ int  debug = 0;
 int    toktrace = 0;
 #endif
 
 int    toktrace = 0;
 #endif
 
-int    useVM =         /*put the temp file in virtual memory*/
-#ifdef VMS
-       1;              /*VMS has virtual memory (duh)*/
-#endif VMS
-#ifdef UNIX
-       0;
-#endif
+int    useVM = 0;
 
 char   *endcore;       /*where to get more symbol space*/
 
 
 char   *endcore;       /*where to get more symbol space*/
 
@@ -171,15 +170,7 @@ BFILE      *relocfile;                     /* concatnated relocation info */
  *
  *     We use relfil to output the symbol table information.
  */
  *
  *     We use relfil to output the symbol table information.
  */
-
-char   *tmpdirprefix =
-#ifdef UNIX
-                       "/tmp/";
-#else VMS
-                       "/usr/tmp/";
-#endif
-
-
+char   *tmpdirprefix = "/tmp/";
 int delexit();
 
 main(argc, argv)
 int delexit();
 
 main(argc, argv)
@@ -235,7 +226,7 @@ main(argc, argv)
                yywarning("These are not defined for all implementations of the VAX architecture.\n");
 
        exit(anyerrs != 0);
                yywarning("These are not defined for all implementations of the VAX architecture.\n");
 
        exit(anyerrs != 0);
-}      /*end of UNIX main*/
+}
 
 argprocess(argc, argv)
        int     argc;
 
 argprocess(argc, argv)
        int     argc;
@@ -277,6 +268,15 @@ argprocess(argc, argv)
                                                exit(1);
                                        }
                                        break;
                                                exit(1);
                                        }
                                        break;
+                                case 'a':
+                                       maxalign = atoi(cp+1);
+                                       for (cp++; isdigit(*cp); cp++)
+                                               /*VOID*/;
+                                       if ( (maxalign > 16) || (maxalign < 0)){
+                                               yyerror("-a: 0<=align<=16");
+                                               exit(1);
+                                       }
+                                       break;
                                 case 'o':
                                        if (argc < 3){
                                                yyerror("-o what???");
                                 case 'o':
                                        if (argc < 3){
                                                yyerror("-o what???");
@@ -422,9 +422,9 @@ FILE *tempopen(tname, part)
        char    *part;
 {
        FILE    *file;
        char    *part;
 {
        FILE    *file;
-       sprintf(tname, "%s%sas%s%05d",
+       (void)sprintf(tname, "%s%sas%s%05d",
                tmpdirprefix,
                tmpdirprefix,
-               (tmpdirprefix[strlen(tmpdirprefix)-1] != '/') ? "/" : 0,
+               (tmpdirprefix[strlen(tmpdirprefix)-1] != '/') ? "/" : "",
                part,
                getpid());
        file = fopen(tname, "w");
                part,
                getpid());
        file = fopen(tname, "w");
@@ -491,6 +491,8 @@ pass1_5()
 
 open_a_out()
 {
 
 open_a_out()
 {
+       struct stat stb;
+
        /*
         *      Open up the a.out file now, and get set to build
         *      up offsets into it for all of the various text,data
        /*
         *      Open up the a.out file now, and get set to build
         *      up offsets into it for all of the various text,data
@@ -502,6 +504,8 @@ open_a_out()
                delexit();
        }
        biofd = a_out_file->_file;
                delexit();
        }
        biofd = a_out_file->_file;
+       fstat(biofd, &stb);
+       biobufsize = stb.st_blksize;
        a_out_off = 0;
 }
 
        a_out_off = 0;
 }
 
@@ -652,8 +656,7 @@ reloc_syms()
                hdr.a_drsize = 0;
        }
        /*
                hdr.a_drsize = 0;
        }
        /*
-        *      Output the symbol table
-        *      and if FLEXNAMES is set, the string pool
+        *      Output the symbol table and 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
         *
         *      We must first rewind the string pool file to its beginning,
         *      in case it was seek'ed into for fetching ascii and asciz