gas/:
[binutils-gdb.git] / gas / config / tc-mcore.c
index 6319f337ab7d47e436f92c212d0eeb40d86679f1..73307b13e1e9a4b2a9079ba463b73d7c09891fdb 100644 (file)
@@ -1,12 +1,12 @@
 /* tc-mcore.c -- Assemble code for M*Core
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
 
    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, 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
-#include <stdio.h>
 #include "as.h"
-#include "bfd.h"
 #include "subsegs.h"
 #define DEFINE_TABLE
 #include "../opcodes/mcore-opc.h"
 #include "safe-ctype.h"
-#include <string.h>
 
 #ifdef OBJ_ELF
 #include "elf/mcore.h"
@@ -49,8 +46,6 @@ const char comment_chars[] = "#/";
 const char line_separator_chars[] = ";";
 const char line_comment_chars[] = "#/";
 
-const int md_reloc_size = 8;
-
 static int do_jsri2bsr = 0;    /* Change here from 1 by Cruess 19 August 97.  */
 static int sifilter_mode = 0;
 
@@ -416,8 +411,8 @@ const pseudo_typeS md_pseudo_table[] =
      occupy can be taken into account when deciding whether or not to
      dump the current literal pool.
      XXX - currently we do not cope with the .space and .dcb.d directives.  */
-  { "ascii",    mcore_stringer,       0 },
-  { "asciz",    mcore_stringer,       1 },
+  { "ascii",    mcore_stringer,       8 + 0 },
+  { "asciz",    mcore_stringer,       8 + 1 },
   { "byte",     mcore_cons,           1 },
   { "dc",       mcore_cons,           2 },
   { "dc.b",     mcore_cons,           1 },
@@ -435,7 +430,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "quad",     mcore_cons,           8 },
   { "short",    mcore_cons,           2 },
   { "single",   mcore_float_cons,    'f'},
-  { "string",   mcore_stringer,       1 },
+  { "string",   mcore_stringer,       8 + 1 },
   { "word",     mcore_cons,           2 },
   { "fill",     mcore_fill,           0 },
 
@@ -1621,77 +1616,11 @@ md_mcore_end (void)
 }
 
 /* Various routines to kill one day.  */
-/* Equal to MAX_PRECISION in atof-ieee.c.  */
-#define MAX_LITTLENUMS 6
-
-/* 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.  */
 
 char *
-md_atof (int type,  char * litP, int * sizeP)
+md_atof (int type, char * litP, int * sizeP)
 {
-  int prec;
-  LITTLENUM_TYPE words[MAX_LITTLENUMS];
-  int    i;
-  char * t;
-
-  switch (type)
-    {
-    case 'f':
-    case 'F':
-    case 's':
-    case 'S':
-      prec = 2;
-      break;
-
-    case 'd':
-    case 'D':
-    case 'r':
-    case 'R':
-      prec = 4;
-      break;
-
-    case 'x':
-    case 'X':
-      prec = 6;
-      break;
-
-    case 'p':
-    case 'P':
-      prec = 6;
-      break;
-
-    default:
-      *sizeP = 0;
-      return _("Bad call to MD_NTOF()");
-    }
-
-  t = atof_ieee (input_line_pointer, type, words);
-
-  if (t)
-    input_line_pointer = t;
-
-  *sizeP = prec * sizeof (LITTLENUM_TYPE);
-
-  if (! target_big_endian)
-    {
-      for (i = prec - 1; i >= 0; i--)
-       {
-         md_number_to_chars (litP, (valueT) words[i],
-                             sizeof (LITTLENUM_TYPE));
-         litP += sizeof (LITTLENUM_TYPE);
-       }
-    }
-  else
-    for (i = 0; i < prec; i++)
-      {
-       md_number_to_chars (litP, (valueT) words[i],
-                           sizeof (LITTLENUM_TYPE));
-       litP += sizeof (LITTLENUM_TYPE);
-      }
-
-  return 0;
+  return ieee_md_atof (type, litP, sizeP, target_big_endian);
 }
 \f
 const char * md_shortopts = "";
@@ -1984,7 +1913,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED,
    Also sets up addends for 'rela' type relocations.  */
 
 void
-md_apply_fix3 (fixS *   fixP,
+md_apply_fix (fixS *   fixP,
               valueT * valP,
               segT     segment ATTRIBUTE_UNUSED)
 {
@@ -2175,24 +2104,10 @@ md_estimate_size_before_relax (fragS * fragP, segT segment_type)
 void
 md_number_to_chars (char * ptr, valueT use, int nbytes)
 {
-  if (! target_big_endian)
-    switch (nbytes)
-      {
-      case 4: ptr[3] = (use >> 24) & 0xff; /* Fall through.  */
-      case 3: ptr[2] = (use >> 16) & 0xff; /* Fall through.  */
-      case 2: ptr[1] = (use >>  8) & 0xff; /* Fall through.  */
-      case 1: ptr[0] = (use >>  0) & 0xff;    break;
-      default: abort ();
-      }
+  if (target_big_endian)
+    number_to_chars_bigendian (ptr, use, nbytes);
   else
-    switch (nbytes)
-      {
-      case 4: *ptr++ = (use >> 24) & 0xff; /* Fall through.  */
-      case 3: *ptr++ = (use >> 16) & 0xff; /* Fall through.  */
-      case 2: *ptr++ = (use >>  8) & 0xff; /* Fall through.  */
-      case 1: *ptr++ = (use >>  0) & 0xff;    break;
-      default: abort ();
-      }
+    number_to_chars_littleendian (ptr, use, nbytes);
 }
 
 /* Round up a section size to the appropriate boundary.  */