add more direct/unpack code
[deliverable/binutils-gdb.git] / gas / gasp.c
index cff902548db58e106bdd55a7a56c191c623dbfd7..3fb51b84b61f1504696c235579d33d530bb2486f 100644 (file)
@@ -1,5 +1,5 @@
 /* gasp.c - Gnu assembler preprocessor main program.
-   Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1994, 95, 96, 1997 Free Software Foundation, Inc.
 
    Written by Steve and Judy Chamberlain of Cygnus Support,
       sac@cygnus.com
@@ -70,6 +70,11 @@ extern char *malloc ();
 
 char *program_version = "1.2";
 
+/* This is normally declared in as.h, but we don't include that.  We
+   need the function because other files linked with gasp.c might call
+   it.  */
+extern void as_abort PARAMS ((const char *, int, const char *));
+
 #define MAX_INCLUDES 30                /* Maximum include depth */
 #define MAX_REASONABLE 1000    /* Maximum number of expansions */
 
@@ -470,7 +475,7 @@ hash_add_to_string_table (tab, key, name, again)
   if (ptr->value.s.len)
     {
       if (!again)
-       ERROR ((stderr, "redefintion not allowed"));
+       ERROR ((stderr, "redefinition not allowed\n"));
     }
 
   ptr->type = hash_string;
@@ -1103,7 +1108,21 @@ change_base (idx, in, out)
 
   while (idx < in->len)
     {
-      if (idx < in->len - 1 && in->ptr[idx + 1] == '\'' && ! mri)
+      if (in->ptr[idx] == '\\'
+         && idx + 1 < in->len
+         && in->ptr[idx + 1] == '(')
+       {
+         idx += 2;
+         while (idx < in->len
+                && in->ptr[idx] != ')')
+           {
+             sb_add_char (out, in->ptr[idx]);
+             idx++;
+           }
+         if (idx < in->len)
+           idx++;
+       }
+      else if (idx < in->len - 1 && in->ptr[idx + 1] == '\'' && ! mri)
        {
          int base;
          int value;
@@ -1399,15 +1418,29 @@ do_align (idx, in)
      int idx;
      sb *in;
 {
-  int al;
+  int al, have_fill, fill;
+
   idx = exp_get_abs ("align needs absolute expression.\n", idx, in, &al);
+  idx = sb_skip_white (idx, in);
+  have_fill = 0;
+  fill = 0;
+  if (! eol (idx, in))
+    {
+      idx = sb_skip_comma (idx, in);
+      idx = exp_get_abs (".align needs absolute fill value.\n", idx, in,
+                        &fill);
+      have_fill = 1;
+    }
 
   if (al != 1
       && al != 2
       && al != 4)
     WARNING ((stderr, "alignment must be one of 1, 2 or 4.\n"));
 
-  fprintf (outfile, ".align    %d\n", al);
+  fprintf (outfile, ".align    %d", al);
+  if (have_fill)
+    fprintf (outfile, ",%d", fill);
+  fprintf (outfile, "\n");
 }
 
 /* .res[.b|.w|.l] <size> */
@@ -1761,11 +1794,24 @@ process_assigns (idx, in, buf)
     {
       hash_entry *ptr;
       if (in->ptr[idx] == '\\'
+         && idx + 1 < in->len
+         && in->ptr[idx + 1] == '(')
+       {
+         do
+           {
+             sb_add_char (buf, in->ptr[idx]);
+             idx++;
+           }
+         while (idx < in->len && in->ptr[idx - 1] != ')');
+       }
+      else if (in->ptr[idx] == '\\'
+         && idx + 1 < in->len
          && in->ptr[idx + 1] == '&')
        {
          idx = condass_lookup_name (in, idx + 2, buf, 1);
        }
       else if (in->ptr[idx] == '\\'
+              && idx + 1 < in->len
               && in->ptr[idx + 1] == '$')
        {
          idx = condass_lookup_name (in, idx + 2, buf, 0);
@@ -1876,19 +1922,43 @@ process_file ()
        {
          l = grab_label (&line, &label_in);
          sb_reset (&label);              
-         if (label_in.len)
-           {
-             /* Munge any label */
-
-             
-             process_assigns (0, &label_in, &label);
-           }
 
          if (line.ptr[l] == ':')
            l++;
          while (ISWHITE (line.ptr[l]) && l < line.len)
            l++;
 
+         if (label_in.len)
+           {
+             int do_assigns;
+
+             /* Munge the label, unless this is EQU or ASSIGN.  */
+             do_assigns = 1;
+             if (l < line.len
+                 && (line.ptr[l] == '.' || alternate || mri))
+               {
+                 int lx = l;
+
+                 if (line.ptr[lx] == '.')
+                   ++lx;
+                 if (lx + 3 <= line.len
+                     && strncasecmp ("EQU", line.ptr + lx, 3) == 0
+                     && (lx + 3 == line.len
+                         || ! ISFIRSTCHAR (line.ptr[lx + 3])))
+                   do_assigns = 0;
+                 else if (lx + 6 <= line.len
+                          && strncasecmp ("ASSIGN", line.ptr + lx, 6) == 0
+                          && (lx + 6 == line.len
+                              || ! ISFIRSTCHAR (line.ptr[lx + 6])))
+                   do_assigns = 0;
+               }
+
+             if (do_assigns)
+               process_assigns (0, &label_in, &label);
+             else
+               sb_add_sb (&label, &label_in);
+           }
+
          if (l < line.len)
            {
              if (process_pseudo_op (l, &line, &acc))
@@ -2597,7 +2667,7 @@ do_macro (idx, in)
   const char *err;
   int line = linecount ();
 
-  err = define_macro (idx, in, &label, get_line);
+  err = define_macro (idx, in, &label, get_line, (const char **) NULL);
   if (err != NULL)
     ERROR ((stderr, "macro at line %d: %s\n", line - 1, err));
 }
@@ -3225,7 +3295,7 @@ process_pseudo_op (idx, line, acc)
            {
            case K_ALTERNATE:
              alternate = 1;
-             macro_init (1, mri, exp_get_abs);
+             macro_init (1, mri, 0, exp_get_abs);
              return 1;
            case K_AELSE:
              do_aelse ();
@@ -3267,7 +3337,7 @@ process_pseudo_op (idx, line, acc)
              do_sdata (idx, line, 'z');
              return 1;
            case K_ASSIGN:
-             do_assign (1, 0, line);
+             do_assign (0, 0, line);
              return 1;
            case K_AIF:
              do_aif (idx, line);
@@ -3285,7 +3355,7 @@ process_pseudo_op (idx, line, acc)
              do_aendr ();
              return 1;
            case K_EQU:
-             do_assign (0, idx, line);
+             do_assign (1, idx, line);
              return 1;
            case K_ALIGN:
              do_align (idx, line);
@@ -3500,13 +3570,16 @@ Usage: %s \n\
   [-h]      [--help]              print this message\n\
   [-M]      [--mri]               enter MRI compatibility mode\n\
   [-o out]  [--output out]        set the output file\n\
-  [-p]      [--print]             print line numbers\n\
+  [-p]      [--print]             print line numbers\n", program_name);
+  fprintf (file, "\
   [-s]      [--copysource]        copy source through as comments \n\
   [-u]      [--unreasonable]      allow unreasonable nesting\n\
   [-v]      [--version]           print the program version\n\
   [-Dname=value]                  create preprocessor variable called name, with value\n\
   [-Ipath]                        add to include path list\n\
-  [in-file]\n",   program_name);
+  [in-file]\n");
+  if (status == 0)
+    printf ("\nReport bugs to bug-gnu-utils@prep.ai.mit.edu\n");
   exit (status);
 }
 
@@ -3592,7 +3665,12 @@ main (argc, argv)
          show_help ();
          /*NOTREACHED*/
        case 'v':
-         printf ("GNU %s version %s\n", program_name, program_version);
+         /* This output is intended to follow the GNU standards document.  */
+         printf ("GNU assembler pre-processor %s\n", program_version);
+         printf ("Copyright 1996 Free Software Foundation, Inc.\n");
+         printf ("\
+This program is free software; you may redistribute it under the terms of\n\
+the GNU General Public License.  This program has absolutely no warranty.\n");
          exit (0);
          /*NOTREACHED*/
        case 0:
@@ -3605,7 +3683,7 @@ main (argc, argv)
 
   process_init ();
 
-  macro_init (alternate, mri, exp_get_abs);
+  macro_init (alternate, mri, 0, exp_get_abs);
 
   if (out_name) {
     outfile = fopen (out_name, "w");
This page took 0.025466 seconds and 4 git commands to generate.