]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-a29k.c
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / gas / config / tc-a29k.c
index 0a9c22af61d1b378a039c1ceeeb85ffa1a8ee9ba..600fec58857cbf2c0c1d0bb00823cb6c24ab3266 100644 (file)
@@ -1,5 +1,6 @@
 /* tc-a29k.c -- Assemble for the AMD 29000.
-   Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1998
+   Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GAS; see the file COPYING.  If not, write to
-   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   along with GAS; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
 
 /* John Gilmore has reorganized this module somewhat, to make it easier
    to convert it to new machines' assemblers as desired.  There was too
    much bloody rewriting required before.  There still probably is.  */
 
-#include "ctype.h"
+#include <ctype.h>
 #include "as.h"
 
 #include "opcode/a29k.h"
@@ -32,9 +34,6 @@
 #define        machine_ip      a29k_ip
 #define        machine_it      a29k_it
 
-const relax_typeS md_relax_table[] =
-{0};
-
 #define        IMMEDIATE_BIT   0x01000000      /* Turns RB into Immediate */
 #define        ABSOLUTE_BIT    0x01000000      /* Turns PC-relative to Absolute */
 #define        CE_BIT          0x00800000      /* Coprocessor enable in LOAD */
@@ -53,32 +52,18 @@ struct machine_it
     int reloc_offset;          /* Offset of reloc within insn */
 
     int reloc;
-
-
   }
-
 the_insn;
 
-#if __STDC__ == 1
-
-/* static int getExpression(char *str); */
-static void machine_ip (char *str);
-/* static void print_insn(struct machine_it *insn); */
-static void s_data1 (void);
-static void s_use (void);
-
-#else /* not __STDC__ */
-
-/* static int getExpression(); */
-static void machine_ip ();
-/* static void print_insn(); */
-static void s_data1 ();
-static void s_use ();
-
-#endif /* not __STDC__ */
+static void machine_ip PARAMS ((char *str));
+/* static void print_insn PARAMS ((struct machine_it *insn)); */
+#ifndef OBJ_COFF
+static void s_data1 PARAMS ((void));
+static void s_use PARAMS ((int));
+#endif
 
 const pseudo_typeS
-  md_pseudo_table[] =
+md_pseudo_table[] =
 {
   {"align", s_align_bytes, 4},
   {"block", s_space, 0},
@@ -87,15 +72,13 @@ const pseudo_typeS
   {"space", s_ignore, 0},      /* Listing control */
   {"sect", s_ignore, 0},       /* Creation of coff sections */
 #ifndef OBJ_COFF
-/* We can do this right with coff */
+  /* We can do this right with coff.  */
   {"use", s_use, 0},
 #endif
   {"word", cons, 4},
   {NULL, 0, 0},
 };
 
-int md_short_jump_size = 4;
-int md_long_jump_size = 4;
 #if defined(BFD_HEADERS)
 #ifdef RELSZ
 const int md_reloc_size = RELSZ;       /* Coff headers */
@@ -132,33 +115,30 @@ const char EXP_CHARS[] = "eE";
 const char FLT_CHARS[] = "rRsSfFdDxXpP";
 
 /* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be
-   changed in read.c .  Ideally it shouldn't have to know about it at all,
-   but nothing is ideal around here.
-   */
-
-static unsigned char octal[256];
-#define isoctal(c)  octal[c]
-static unsigned char toHex[256];
+   changed in read.c.  Ideally it shouldn't have to know about it at
+   all, but nothing is ideal around here.  */
 
 /*
  *  anull bit - causes the branch delay slot instructions to not be executed
  */
 #define ANNUL       (1 << 29)
 
+#ifndef OBJ_COFF
+
 static void
-s_use ()
+s_use (ignore)
+     int ignore;
 {
-
   if (strncmp (input_line_pointer, ".text", 5) == 0)
     {
       input_line_pointer += 5;
-      s_text ();
+      s_text (0);
       return;
     }
   if (strncmp (input_line_pointer, ".data", 5) == 0)
     {
       input_line_pointer += 5;
-      s_data ();
+      s_data (0);
       return;
     }
   if (strncmp (input_line_pointer, ".data1", 6) == 0)
@@ -167,29 +147,29 @@ s_use ()
       s_data1 ();
       return;
     }
-  /* Literals can't go in the text segment because you can't read
-          from instruction memory on some 29k's.  So, into initialized data. */
+  /* Literals can't go in the text segment because you can't read from
+     instruction memory on some 29k's.  So, into initialized data. */
   if (strncmp (input_line_pointer, ".lit", 4) == 0)
     {
       input_line_pointer += 4;
-      subseg_new (SEG_DATA, 200);
+      subseg_set (SEG_DATA, 200);
       demand_empty_rest_of_line ();
       return;
     }
 
-  as_bad ("Unknown segment type");
+  as_bad (_("Unknown segment type"));
   demand_empty_rest_of_line ();
-  return;
 }
 
 static void
 s_data1 ()
 {
-  subseg_new (SEG_DATA, 1);
+  subseg_set (SEG_DATA, 1);
   demand_empty_rest_of_line ();
-  return;
 }
 
+#endif /* OBJ_COFF */
+
 /* Install symbol definition that maps REGNAME to REGNO.
    FIXME-SOON:  These are not recognized in mixed case.  */
 
@@ -198,20 +178,22 @@ insert_sreg (regname, regnum)
      char *regname;
      int regnum;
 {
-  /* FIXME-SOON, put something in these syms so they won't be output to the symbol
-          table of the resulting object file.  */
+  /* FIXME-SOON, put something in these syms so they won't be output
+     to the symbol table of the resulting object file.  */
 
   /* Must be large enough to hold the names of the special registers.  */
   char buf[80];
   int i;
 
-  symbol_table_insert (symbol_new (regname, SEG_REGISTER, regnum, &zero_address_frag));
+  symbol_table_insert (symbol_new (regname, SEG_REGISTER, (valueT) regnum,
+                                  &zero_address_frag));
   for (i = 0; regname[i]; i++)
     buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
   buf[i] = '\0';
 
-  symbol_table_insert (symbol_new (buf, SEG_REGISTER, regnum, &zero_address_frag));
-}                              /* insert_sreg() */
+  symbol_table_insert (symbol_new (buf, SEG_REGISTER, (valueT) regnum,
+                                  &zero_address_frag));
+}
 
 /* Install symbol definitions for assorted special registers.
    See ASM29K Ref page 2-9.  */
@@ -252,6 +234,12 @@ define_some_regs ()
   insert_sreg ("iba1", SREG + 25);
   insert_sreg ("ibc1", SREG + 26);
 
+  /* Additional registers for the 29040.  */
+  insert_sreg ("dba", SREG + 27);
+  insert_sreg ("dbc", SREG + 28);
+  insert_sreg ("cir", SREG + 29);
+  insert_sreg ("cdr", SREG + 30);
+
   /* Unprotected special-purpose register names */
   insert_sreg ("ipc", SREG + 128);
   insert_sreg ("ipa", SREG + 129);
@@ -266,14 +254,15 @@ define_some_regs ()
   insert_sreg ("fps", SREG + 162);
   /*  "",    SREG+163);          Reserved */
   insert_sreg ("exop", SREG + 164);
-}                              /* define_some_regs() */
+}
 
 /* This function is called once, at assembler startup time.  It should
-   set up all the tables, etc. that the MD part of the assembler will need.  */
+   set up all the tables, etc., that the MD part of the assembler will
+   need.  */
 void
 md_begin ()
 {
-  register char *retval = NULL;
+  register const char *retval = NULL;
   int lose = 0;
   register int skipnext = 0;
   register unsigned int i;
@@ -282,8 +271,6 @@ md_begin ()
   /* Hash up all the opcodes for fast use later.  */
 
   op_hash = hash_new ();
-  if (op_hash == NULL)
-    as_fatal ("Virtual memory exhausted");
 
   for (i = 0; i < num_opcodes; i++)
     {
@@ -296,12 +283,14 @@ md_begin ()
        }
 
       /* Hack to avoid multiple opcode entries.  We pre-locate all the
-                      variations (b/i field and P/A field) and handle them. */
+        variations (b/i field and P/A field) and handle them. */
 
       if (!strcmp (name, machine_opcodes[i + 1].name))
        {
-         if ((machine_opcodes[i].opcode ^ machine_opcodes[i + 1].opcode)
-             != 0x01000000)
+         if ((machine_opcodes[i].opcode & 0x01000000) != 0
+             || (machine_opcodes[i + 1].opcode & 0x01000000) == 0
+             || ((machine_opcodes[i].opcode | 0x01000000)
+                 != machine_opcodes[i + 1].opcode))
            goto bad_table;
          strend = machine_opcodes[i].args + strlen (machine_opcodes[i].args) - 1;
          strend2 = machine_opcodes[i + 1].args + strlen (machine_opcodes[i + 1].args) - 1;
@@ -311,34 +300,25 @@ md_begin ()
              if (*strend2 != 'i')
                goto bad_table;
              break;
-           case 'i':
-             if (*strend2 != 'b')
-               goto bad_table;
-             break;
            case 'P':
              if (*strend2 != 'A')
                goto bad_table;
              break;
-           case 'A':
-             if (*strend2 != 'P')
-               goto bad_table;
-             break;
            default:
            bad_table:
-             fprintf (stderr, "internal error: can't handle opcode %s\n", name);
+             fprintf (stderr, "internal error: can't handle opcode %s\n",
+                      name);
              lose = 1;
            }
 
-         /* OK, this is an i/b or A/P pair.  We skip the higher-valued one,
-                              and let the code for operand checking handle OR-ing in the bit.  */
-         if (machine_opcodes[i].opcode & 1)
-           continue;
-         else
-           skipnext = 1;
+         /* OK, this is an i/b or A/P pair.  We skip the
+            higher-valued one, and let the code for operand checking
+            handle OR-ing in the bit.  */
+         skipnext = 1;
        }
 
-      retval = hash_insert (op_hash, name, &machine_opcodes[i]);
-      if (retval != NULL && *retval != '\0')
+      retval = hash_insert (op_hash, name, (PTR) &machine_opcodes[i]);
+      if (retval != NULL)
        {
          fprintf (stderr, "internal error: can't hash `%s': %s\n",
                   machine_opcodes[i].name, retval);
@@ -347,26 +327,11 @@ md_begin ()
     }
 
   if (lose)
-    as_fatal ("Broken assembler.  No assembly attempted.");
-
-  for (i = '0'; i < '8'; ++i)
-    octal[i] = 1;
-  for (i = '0'; i <= '9'; ++i)
-    toHex[i] = i - '0';
-  for (i = 'a'; i <= 'f'; ++i)
-    toHex[i] = i + 10 - 'a';
-  for (i = 'A'; i <= 'F'; ++i)
-    toHex[i] = i + 10 - 'A';
+    as_fatal (_("Broken assembler.  No assembly attempted."));
 
   define_some_regs ();
 }
 
-void
-md_end ()
-{
-  return;
-}
-
 /* Assemble a single instruction.  Its label has already been handled
    by the generic front end.  We just parse opcode and operands, and
    produce the bytes of data and relocation.  */
@@ -376,7 +341,6 @@ md_assemble (str)
      char *str;
 {
   char *toP;
-  /* !!!!    int rsd; */
 
   know (str);
   machine_ip (str);
@@ -387,35 +351,30 @@ md_assemble (str)
   /* put out the symbol-dependent stuff */
   if (the_insn.reloc != NO_RELOC)
     {
-      fix_new (
-               frag_now,       /* which frag */
-               (toP - frag_now->fr_literal + the_insn.reloc_offset),   /* where */
-               4,              /* size */
-               the_insn.exp.X_add_symbol,
-               the_insn.exp.X_subtract_symbol,
-               the_insn.exp.X_add_number,
-               the_insn.pcrel,
-               the_insn.reloc
-       );
+      fix_new_exp (frag_now,
+                  (toP - frag_now->fr_literal + the_insn.reloc_offset),
+                  4,           /* size */
+                  &the_insn.exp,
+                  the_insn.pcrel,
+                  the_insn.reloc);
     }
 }
 
 char *
-parse_operand (s, operandp)
+parse_operand (s, operandp, opt)
      char *s;
      expressionS *operandp;
+     int opt;
 {
   char *save = input_line_pointer;
   char *new;
-  segT seg;
 
   input_line_pointer = s;
-  seg = expr (0, operandp);
+  expression (operandp);
+  if (operandp->X_op == O_absent && ! opt)
+    as_bad (_("missing operand"));
   new = input_line_pointer;
   input_line_pointer = save;
-
-  if (seg == SEG_ABSENT)
-    as_bad ("Missing operand");
   return new;
 }
 
@@ -429,12 +388,9 @@ machine_ip (str)
 {
   char *s;
   const char *args;
-  /* !!!!    char c; */
-  /* !!!!    unsigned long i; */
   struct machine_opcode *insn;
   char *argsStart;
   unsigned long opcode;
-  /* !!!!    unsigned int mask; */
   expressionS the_operand;
   expressionS *operand = &the_operand;
   unsigned int reg;
@@ -456,12 +412,12 @@ machine_ip (str)
       break;
 
     default:
-      as_bad ("Unknown opcode: `%s'", str);
+      as_bad (_("Unknown opcode: `%s'"), str);
       return;
     }
   if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL)
     {
-      as_bad ("Unknown opcode `%s'.", str);
+      as_bad (_("Unknown opcode `%s'."), str);
       return;
     }
   argsStart = s;
@@ -469,15 +425,17 @@ machine_ip (str)
   memset (&the_insn, '\0', sizeof (the_insn));
   the_insn.reloc = NO_RELOC;
 
-  /*
-        * Build the opcode, checking as we go to make
-        * sure that the operands match.
-        *
-        * If an operand matches, we modify the_insn or opcode appropriately,
-        * and do a "continue".  If an operand fails to match, we "break".
-        */
+  /* Build the opcode, checking as we go to make sure that the
+     operands match.
+   
+     If an operand matches, we modify the_insn or opcode appropriately,
+     and do a "continue".  If an operand fails to match, we "break".  */
+
   if (insn->args[0] != '\0')
-    s = parse_operand (s, operand);    /* Prime the pump */
+    {
+      /* Prime the pump.  */
+      s = parse_operand (s, operand, insn->args[0] == 'I');
+    }
 
   for (args = insn->args;; ++args)
     {
@@ -491,19 +449,20 @@ machine_ip (str)
              the_insn.opcode = opcode;
              return;
            }
-         as_bad ("Too many operands: %s", s);
+         as_bad (_("Too many operands: %s"), s);
          break;
 
        case ',':               /* Must match a comma */
          if (*s++ == ',')
            {
-             s = parse_operand (s, operand);   /* Parse next opnd */
+             /* Parse next operand.  */
+             s = parse_operand (s, operand, args[1] == 'I');
              continue;
            }
          break;
 
        case 'v':               /* Trap numbers (immediate field) */
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              if (operand->X_add_number < 256)
                {
@@ -512,8 +471,8 @@ machine_ip (str)
                }
              else
                {
-                 as_bad ("Immediate value of %d is too large",
-                         operand->X_add_number);
+                 as_bad (_("Immediate value of %ld is too large"),
+                         (long) operand->X_add_number);
                  continue;
                }
            }
@@ -525,12 +484,16 @@ machine_ip (str)
        case 'b':               /* A general register or 8-bit immediate */
        case 'i':
          /* We treat the two cases identically since we mashed
-                          them together in the opcode table.  */
-         if (operand->X_seg == SEG_REGISTER)
+            them together in the opcode table.  */
+         if (operand->X_op == O_register)
            goto general_reg;
 
+         /* Make sure the 'i' case really exists.  */
+         if ((insn->opcode | IMMEDIATE_BIT) != (insn + 1)->opcode)
+           break;
+
          opcode |= IMMEDIATE_BIT;
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              if (operand->X_add_number < 256)
                {
@@ -539,8 +502,8 @@ machine_ip (str)
                }
              else
                {
-                 as_bad ("Immediate value of %d is too large",
-                         operand->X_add_number);
+                 as_bad (_("Immediate value of %ld is too large"),
+                         (long) operand->X_add_number);
                  continue;
                }
            }
@@ -553,18 +516,16 @@ machine_ip (str)
        case 'c':
        general_reg:
          /* lrNNN or grNNN or %%expr or a user-def register name */
-         if (operand->X_seg != SEG_REGISTER)
+         if (operand->X_op != O_register)
            break;              /* Only registers */
          know (operand->X_add_symbol == 0);
-         know (operand->X_subtract_symbol == 0);
+         know (operand->X_op_symbol == 0);
          reg = operand->X_add_number;
          if (reg >= SREG)
            break;              /* No special registers */
 
-         /*
-                        * Got the register, now figure out where
-                        * it goes in the opcode.
-                        */
+         /* Got the register, now figure out where it goes in the
+            opcode.  */
          switch (*args)
            {
            case 'a':
@@ -580,12 +541,12 @@ machine_ip (str)
              opcode |= reg << 16;
              continue;
            }
-         as_fatal ("failed sanity check.");
+         as_fatal (_("failed sanity check."));
          break;
 
        case 'x':               /* 16 bit constant, zero-extended */
        case 'X':               /* 16 bit constant, one-extended */
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              opcode |= (operand->X_add_number & 0xFF) << 0 |
                ((operand->X_add_number & 0xFF00) << 8);
@@ -596,7 +557,7 @@ machine_ip (str)
          continue;
 
        case 'h':
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              opcode |= (operand->X_add_number & 0x00FF0000) >> 16 |
                (((unsigned long) operand->X_add_number
@@ -610,9 +571,19 @@ machine_ip (str)
        case 'P':               /* PC-relative jump address */
        case 'A':               /* Absolute jump address */
          /* These two are treated together since we folded the
-                          opcode table entries together.  */
-         if (operand->X_seg == SEG_ABSOLUTE)
+            opcode table entries together.  */
+         if (operand->X_op == O_constant)
            {
+             /* Make sure the 'A' case really exists.  */
+             if ((insn->opcode | ABSOLUTE_BIT) != (insn + 1)->opcode)
+               break;
+             {
+               bfd_vma v, mask;
+               mask = 0x1ffff;
+               v = operand->X_add_number & ~ mask;
+               if (v)
+                 as_bad ("call/jmp target out of range");
+             }
              opcode |= ABSOLUTE_BIT |
                (operand->X_add_number & 0x0003FC00) << 6 |
                ((operand->X_add_number & 0x000003FC) >> 2);
@@ -621,11 +592,12 @@ machine_ip (str)
          the_insn.reloc = RELOC_JUMPTARG;
          the_insn.exp = *operand;
          the_insn.pcrel = 1;   /* Assume PC-relative jump */
-         /* FIXME-SOON, Do we figure out whether abs later, after know sym val? */
+         /* FIXME-SOON, Do we figure out whether abs later, after
+             know sym val? */
          continue;
 
        case 'e':               /* Coprocessor enable bit for LOAD/STORE insn */
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              if (operand->X_add_number == 0)
                continue;
@@ -638,7 +610,7 @@ machine_ip (str)
          break;
 
        case 'n':               /* Control bits for LOAD/STORE instructions */
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 128)
            {
              opcode |= (operand->X_add_number << 16);
@@ -647,7 +619,7 @@ machine_ip (str)
          break;
 
        case 's':               /* Special register number */
-         if (operand->X_seg != SEG_REGISTER)
+         if (operand->X_op != O_register)
            break;              /* Only registers */
          if (operand->X_add_number < SREG)
            break;              /* Not a special register */
@@ -655,7 +627,7 @@ machine_ip (str)
          continue;
 
        case 'u':               /* UI bit of CONVERT */
-         if (operand->X_seg == SEG_ABSOLUTE)
+         if (operand->X_op == O_constant)
            {
              if (operand->X_add_number == 0)
                continue;
@@ -668,7 +640,7 @@ machine_ip (str)
          break;
 
        case 'r':               /* RND bits of CONVERT */
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 8)
            {
              opcode |= operand->X_add_number << 4;
@@ -676,8 +648,20 @@ machine_ip (str)
            }
          break;
 
+       case 'I':               /* ID bits of INV and IRETINV.  */
+         /* This operand is optional.  */
+         if (operand->X_op == O_absent)
+           continue;
+         else if (operand->X_op == O_constant
+                  && operand->X_add_number < 4)
+           {
+             opcode |= operand->X_add_number << 16;
+             continue;
+           }
+         break;
+
        case 'd':               /* FD bits of CONVERT */
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 4)
            {
              opcode |= operand->X_add_number << 2;
@@ -687,7 +671,7 @@ machine_ip (str)
 
 
        case 'f':               /* FS bits of CONVERT */
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 4)
            {
              opcode |= operand->X_add_number << 0;
@@ -696,7 +680,7 @@ machine_ip (str)
          break;
 
        case 'C':
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 4)
            {
              opcode |= operand->X_add_number << 16;
@@ -705,7 +689,7 @@ machine_ip (str)
          break;
 
        case 'F':
-         if (operand->X_seg == SEG_ABSOLUTE &&
+         if (operand->X_op == O_constant &&
              operand->X_add_number < 16)
            {
              opcode |= operand->X_add_number << 18;
@@ -722,14 +706,13 @@ machine_ip (str)
     }
 }
 
-/*
-  This is identical to the md_atof in m68k.c.  I think this is right,
-  but I'm not sure.
+/* This is identical to the md_atof in m68k.c.  I think this is right,
+   but I'm not sure.
 
-  Turn a string in input_line_pointer into a floating point constant of type
-  type, and store the appropriate bytes in *litP.  The number of LITTLENUMS
-  emitted is stored in *sizeP .  An error message is returned, or NULL on OK.
-  */
+   Turn a string in input_line_pointer into a floating point constant
+   of type type, and store the appropriate bytes in *litP.  The number
+   of LITTLENUMS emitted is stored in *sizeP .  An error message is
+   returned, or NULL on OK.  */
 
 /* Equal to MAX_PRECISION in atof-ieee.c */
 #define MAX_LITTLENUMS 6
@@ -782,10 +765,10 @@ md_atof (type, litP, sizeP)
   *sizeP = prec * sizeof (LITTLENUM_TYPE);
   for (wordP = words; prec--;)
     {
-      md_number_to_chars (litP, (long) (*wordP++), sizeof (LITTLENUM_TYPE));
+      md_number_to_chars (litP, (valueT) (*wordP++), sizeof (LITTLENUM_TYPE));
       litP += sizeof (LITTLENUM_TYPE);
     }
-  return "";                   /* Someone should teach Dean about null pointers */
+  return 0;
 }
 
 /*
@@ -794,26 +777,10 @@ md_atof (type, litP, sizeP)
 void
 md_number_to_chars (buf, val, n)
      char *buf;
-     long val;
+     valueT val;
      int n;
 {
-
-  switch (n)
-    {
-
-    case 4:
-      *buf++ = val >> 24;
-      *buf++ = val >> 16;
-    case 2:
-      *buf++ = val >> 8;
-    case 1:
-      *buf = val;
-      break;
-
-    default:
-      as_fatal ("failed sanity check.");
-    }
-  return;
+  number_to_chars_bigendian (buf, val, n);
 }
 
 void
@@ -829,10 +796,7 @@ md_apply_fix (fixP, val)
   know (fixP->fx_size == 4);
   know (fixP->fx_r_type < NO_RELOC);
 
-  /*
-        * This is a hack.  There should be a better way to
-        * handle this.
-        */
+  /* This is a hack.  There should be a better way to handle this.  */
   if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy)
     {
       val += fixP->fx_where + fixP->fx_frag->fr_address;
@@ -885,16 +849,30 @@ md_apply_fix (fixP, val)
       buf[3] = val;
       break;
 
-#if 0
-    case RELOC_PC10:
-    case RELOC_PC22:
-    case RELOC_JMP_TBL:
-    case RELOC_SEGOFF16:
-    case RELOC_GLOB_DAT:
-    case RELOC_JMP_SLOT:
-    case RELOC_RELATIVE:
-#endif
     case RELOC_JUMPTARG:       /* 00XX00XX pattern in a word */
+      if (!fixP->fx_done)
+       {
+         /* The linker tries to support both AMD and old GNU style
+             R_IREL relocs.  That means that if the addend is exactly
+             the negative of the address within the section, the
+             linker will not handle it correctly.  */
+         if (fixP->fx_pcrel
+             && val != 0
+             && val == - (fixP->fx_frag->fr_address + fixP->fx_where))
+           as_bad_where
+             (fixP->fx_file, fixP->fx_line,
+              "the linker will not handle this relocation correctly");
+       }
+      else if (fixP->fx_pcrel)
+       {
+         long v = val >> 17;
+         if (v != 0 && v != -1)
+           as_bad_where (fixP->fx_file, fixP->fx_line,
+                         "call/jmp target out of range");
+       }
+      else
+       /* this case was supposed to be handled in machine_ip */
+       abort ();
       buf[1] = val >> 10;      /* Holds bits 0003FFFC of address */
       buf[3] = val >> 2;
       break;
@@ -911,10 +889,9 @@ md_apply_fix (fixP, val)
 
     case NO_RELOC:
     default:
-      as_bad ("bad relocation type: 0x%02x", fixP->fx_r_type);
+      as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type);
       break;
     }
-  return;
 }
 
 #ifdef OBJ_COFF
@@ -936,45 +913,23 @@ tc_coff_fix2rtype (fixP)
     case RELOC_JUMPTARG:
       return (R_IREL);
     default:
-      printf ("need %o3\n", fixP->fx_r_type);
+      printf (_("need %o3\n"), fixP->fx_r_type);
       abort ();
     }                          /* switch on type */
 
   return (0);
-}                              /* tc_coff_fix2rtype() */
+}
 
 #endif /* OBJ_COFF */
 
-/* should never be called for sparc */
-void
-md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
-     char *ptr;
-     long from_addr, to_addr;
-     fragS *frag;
-     symbolS *to_symbol;
-{
-  as_fatal ("a29k_create_short_jmp\n");
-}
-
 /* should never be called for 29k */
 void
-md_convert_frag (headers, fragP)
+md_convert_frag (headers, seg, fragP)
      object_headers *headers;
+     segT seg;
      register fragS *fragP;
 {
-  as_fatal ("sparc_convert_frag\n");
-}
-
-/* should never be called for 29k */
-void
-md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
-     char *ptr;
-     long from_addr;
-     long to_addr;
-     fragS *frag;
-     symbolS *to_symbol;
-{
-  as_fatal ("sparc_create_long_jump\n");
+  as_fatal (_("a29k_convert_frag\n"));
 }
 
 /* should never be called for a29k */
@@ -983,8 +938,8 @@ md_estimate_size_before_relax (fragP, segtype)
      register fragS *fragP;
      segT segtype;
 {
-  as_fatal ("sparc_estimate_size_before_relax\n");
-  return (0);
+  as_fatal (_("a29k_estimate_size_before_relax\n"));
+  return 0;
 }
 
 #if 0
@@ -1033,14 +988,13 @@ print_insn (insn)
           insn->exp.X_add_symbol ?
           (S_GET_NAME (insn->exp.X_add_symbol) ?
            S_GET_NAME (insn->exp.X_add_symbol) : "???") : "0");
-  fprintf (stderr, "\t\tX_sub_symbol = %s\n",
-          insn->exp.X_subtract_symbol ?
-          (S_GET_NAME (insn->exp.X_subtract_symbol) ?
-           S_GET_NAME (insn->exp.X_subtract_symbol) : "???") : "0");
+  fprintf (stderr, "\t\tX_op_symbol = %s\n",
+          insn->exp.X_op_symbol ?
+          (S_GET_NAME (insn->exp.X_op_symbol) ?
+           S_GET_NAME (insn->exp.X_op_symbol) : "???") : "0");
   fprintf (stderr, "\t\tX_add_number = %d\n",
           insn->exp.X_add_number);
   fprintf (stderr, "}\n");
-  return;
 }
 
 #endif
@@ -1080,21 +1034,71 @@ tc_aout_fix_to_chars (where, fixP, segment_address_in_file)
   where[7] = (((!S_IS_DEFINED (fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F);
   /* Also easy */
   md_number_to_chars (&where[8], fixP->fx_addnumber, 4);
-
-  return;
-}                              /* tc_aout_fix_to_chars() */
+}
 
 #endif /* OBJ_AOUT */
+\f
+CONST char *md_shortopts = "";
+struct option md_longopts[] = {
+  {NULL, no_argument, NULL, 0}
+};
+size_t md_longopts_size = sizeof(md_longopts);
 
 int
-md_parse_option (argP, cntP, vecP)
-     char **argP;
-     int *cntP;
-     char ***vecP;
+md_parse_option (c, arg)
+     int c;
+     char *arg;
 {
-  return (0);
+  return 0;
 }
 
+void
+md_show_usage (stream)
+     FILE *stream;
+{
+}
+\f
+/* This is called when a line is unrecognized.  This is used to handle
+   definitions of a29k style local labels.  */
+
+int
+a29k_unrecognized_line (c)
+     int c;
+{
+  int lab;
+  char *s;
+
+  if (c != '$'
+      || ! isdigit ((unsigned char) input_line_pointer[0]))
+    return 0;
+
+  s = input_line_pointer;
+
+  lab = 0;
+  while (isdigit ((unsigned char) *s))
+    {
+      lab = lab * 10 + *s - '0';
+      ++s;
+    }
+
+  if (*s != ':')
+    {
+      /* Not a label definition.  */
+      return 0;
+    }
+
+  if (dollar_label_defined (lab))
+    {
+      as_bad (_("label \"$%d\" redefined"), lab);
+      return 0;
+    }
+
+  define_dollar_label (lab);
+  colon (dollar_label_name (lab, 0));
+  input_line_pointer = s + 1;
+
+  return 1;
+}
 
 /* Default the values of symbols known that should be "predefined".  We
    don't bother to predefine them unless you actually use one, since there
@@ -1107,28 +1111,41 @@ md_undefined_symbol (name)
   long regnum;
   char testbuf[5 + /*SLOP*/ 5];
 
-  if (name[0] == 'g' || name[0] == 'G' || name[0] == 'l' || name[0] == 'L')
+  if (name[0] == 'g' || name[0] == 'G'
+      || name[0] == 'l' || name[0] == 'L'
+      || name[0] == 's' || name[0] == 'S')
     {
       /* Perhaps a global or local register name */
       if (name[1] == 'r' || name[1] == 'R')
        {
-         /* Parse the number, make sure it has no extra zeroes or trailing
-                                  chars */
+         long maxreg;
+
+         /* Parse the number, make sure it has no extra zeroes or
+            trailing chars. */
          regnum = atol (&name[2]);
-         if (regnum > 127)
-           return 0;
+
+         if (name[0] == 's' || name[0] == 'S')
+           maxreg = 255;
+         else
+           maxreg = 127;
+         if (regnum > maxreg)
+           return NULL;
+
          sprintf (testbuf, "%ld", regnum);
          if (strcmp (testbuf, &name[2]) != 0)
-           return 0;           /* gr007 or lr7foo or whatever */
+           return NULL;        /* gr007 or lr7foo or whatever */
 
          /* We have a wiener!  Define and return a new symbol for it.  */
          if (name[0] == 'l' || name[0] == 'L')
            regnum += 128;
-         return (symbol_new (name, SEG_REGISTER, regnum, &zero_address_frag));
+         else if (name[0] == 's' || name[0] == 'S')
+           regnum += SREG;
+         return (symbol_new (name, SEG_REGISTER, (valueT) regnum,
+                             &zero_address_frag));
        }
     }
 
-  return 0;
+  return NULL;
 }
 
 /* Parse an operand that is machine-specific.  */
@@ -1143,30 +1160,125 @@ md_operand (expressionP)
       /* We have a numeric register expression.  No biggy.  */
       input_line_pointer += 2; /* Skip %% */
       (void) expression (expressionP);
-      if (expressionP->X_seg != SEG_ABSOLUTE
+      if (expressionP->X_op != O_constant
          || expressionP->X_add_number > 255)
-       as_bad ("Invalid expression after %%%%\n");
-      expressionP->X_seg = SEG_REGISTER;
+       as_bad (_("Invalid expression after %%%%\n"));
+      expressionP->X_op = O_register;
     }
   else if (input_line_pointer[0] == '&')
     {
       /* We are taking the 'address' of a register...this one is not
-                      in the manual, but it *is* in traps/fpsymbol.h!  What they
-                      seem to want is the register number, as an absolute number.  */
+        in the manual, but it *is* in traps/fpsymbol.h!  What they
+        seem to want is the register number, as an absolute number.  */
       input_line_pointer++;    /* Skip & */
       (void) expression (expressionP);
-      if (expressionP->X_seg != SEG_REGISTER)
-       as_bad ("Invalid register in & expression");
+      if (expressionP->X_op != O_register)
+       as_bad (_("Invalid register in & expression"));
       else
-       expressionP->X_seg = SEG_ABSOLUTE;
+       expressionP->X_op = O_constant;
+    }
+  else if (input_line_pointer[0] == '$'
+          && isdigit ((unsigned char) input_line_pointer[1]))
+    {
+      long lab;
+      char *name;
+      symbolS *sym;
+
+      /* This is a local label.  */
+      ++input_line_pointer;
+      lab = (long) get_absolute_expression ();
+      if (dollar_label_defined (lab))
+       {
+         name = dollar_label_name (lab, 0);
+         sym = symbol_find (name);
+       }
+      else
+       {
+         name = dollar_label_name (lab, 1);
+         sym = symbol_find_or_make (name);
+       }
+
+      expressionP->X_op = O_symbol;
+      expressionP->X_add_symbol = sym;
+      expressionP->X_add_number = 0;
+    }
+  else if (input_line_pointer[0] == '$')
+    {
+      char *s;
+      char type;
+      int fieldnum, fieldlimit;
+      LITTLENUM_TYPE floatbuf[8];
+
+      /* $float(), $doubleN(), or $extendN() convert floating values
+        to integers.  */
+
+      s = input_line_pointer;
+
+      ++s;
+
+      fieldnum = 0;
+      if (strncmp (s, "double", sizeof "double" - 1) == 0)
+       {
+         s += sizeof "double" - 1;
+         type = 'd';
+         fieldlimit = 2;
+       }
+      else if (strncmp (s, "float", sizeof "float" - 1) == 0)
+       {
+         s += sizeof "float" - 1;
+         type = 'f';
+         fieldlimit = 1;
+       }
+      else if (strncmp (s, "extend", sizeof "extend" - 1) == 0)
+       {
+         s += sizeof "extend" - 1;
+         type = 'x';
+         fieldlimit = 4;
+       }
+      else 
+       {
+         return;
+       }
+
+      if (isdigit (*s))
+       {
+         fieldnum = *s - '0';
+         ++s;
+       }
+      if (fieldnum >= fieldlimit)
+       return;
+
+      SKIP_WHITESPACE ();
+      if (*s != '(')
+       return;
+      ++s;
+      SKIP_WHITESPACE ();
+
+      s = atof_ieee (s, type, floatbuf);
+      if (s == NULL)
+       return;
+      s = s;
+
+      SKIP_WHITESPACE ();
+      if (*s != ')')
+       return;
+      ++s;
+      SKIP_WHITESPACE ();
+
+      input_line_pointer = s;
+      expressionP->X_op = O_constant; 
+      expressionP->X_unsigned = 1;
+      expressionP->X_add_number = ((floatbuf[fieldnum * 2]
+                                   << LITTLENUM_NUMBER_OF_BITS)
+                                  + floatbuf[fieldnum * 2 + 1]);
     }
 }
 
 /* Round up a section size to the appropriate boundary.  */
-long
+valueT
 md_section_align (segment, size)
      segT segment;
-     long size;
+     valueT size;
 {
   return size;                 /* Byte alignment is fine */
 }
@@ -1181,10 +1293,4 @@ md_pcrel_from (fixP)
   return fixP->fx_where + fixP->fx_frag->fr_address;
 }
 
-/*
- * Local Variables:
- * comment-column: 0
- * End:
- */
-
 /* end of tc-a29k.c */