use XNEW and related macros more
[deliverable/binutils-gdb.git] / gas / config / tc-m68hc11.c
index 3189121c423923dafd11d58b771c70190710735a..35aa4918b5aec84ab83d528a2eee2c72baf56f7a 100644 (file)
@@ -1,7 +1,5 @@
 /* tc-m68hc11.c -- Assembler code for the Motorola 68HC11 & 68HC12.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
-   2011, 2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1999-2016 Free Software Foundation, Inc.
    Written by Stephane Carrez (stcarrez@nerim.fr)
    XGATE and S12X added by James Murray (jsm@jsm-net.demon.co.uk)
 
@@ -492,7 +490,7 @@ m68hc11_print_statistics (FILE *file)
 }
 
 int
-md_parse_option (int c, char *arg)
+md_parse_option (int c, const char *arg)
 {
   get_default_target ();
   switch (c)
@@ -576,7 +574,7 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
   return 0;
 }
 
-char *
+const char *
 md_atof (int type, char *litP, int *sizeP)
 {
   return ieee_md_atof (type, litP, sizeP, TRUE);
@@ -586,7 +584,7 @@ valueT
 md_section_align (asection *seg, valueT addr)
 {
   int align = bfd_get_section_alignment (stdoutput, seg);
-  return ((addr + (1 << align) - 1) & (-1 << align));
+  return ((addr + (1 << align) - 1) & -(1 << align));
 }
 
 static int
@@ -605,7 +603,7 @@ cmp_opcode (struct m68hc11_opcode *op1, struct m68hc11_opcode *op2)
 void
 md_begin (void)
 {
-  char *prev_name = "";
+  const char *prev_name = "";
   struct m68hc11_opcode *opcodes;
   struct m68hc11_opcode_def *opc = 0;
   int i, j;
@@ -615,9 +613,7 @@ md_begin (void)
   m68hc11_hash = hash_new ();
 
   /* Get a writable copy of the opcode table and sort it on the names.  */
-  opcodes = (struct m68hc11_opcode *) xmalloc (m68hc11_num_opcodes *
-                                              sizeof (struct
-                                                      m68hc11_opcode));
+  opcodes = XNEWVEC (struct m68hc11_opcode, m68hc11_num_opcodes);
   m68hc11_sorted_opcodes = opcodes;
   num_opcodes = 0;
   for (i = 0; i < m68hc11_num_opcodes; i++)
@@ -646,8 +642,7 @@ md_begin (void)
   qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode),
          (int (*) (const void*, const void*)) cmp_opcode);
 
-  opc = (struct m68hc11_opcode_def *)
-    xmalloc (num_opcodes * sizeof (struct m68hc11_opcode_def));
+  opc = XNEWVEC (struct m68hc11_opcode_def, num_opcodes);
   m68hc11_opcode_defs = opc--;
 
   /* Insert unique names into hash table.  The M6811 instruction set
@@ -966,7 +961,7 @@ static void
 print_opcode_list (void)
 {
   int i;
-  char *prev_name = "";
+  const char *prev_name = "";
   struct m68hc11_opcode *opcodes;
   int example = flag_print_opcodes == 2;
 
@@ -2143,8 +2138,8 @@ build_indexed_byte (operand *op, int format ATTRIBUTE_UNUSED, int move_insn)
          if (!check_range (val, M6812_OP_IDX))
            as_bad (_("Offset out of 16-bit range: %ld."), val);
 
-         if (move_insn && !(val >= -16 && val <= 15) 
-             && ((!(mode & M6812_OP_IDX) && !(mode & M6812_OP_D_IDX_2)) 
+         if (move_insn && !(val >= -16 && val <= 15)
+             && ((!(mode & M6812_OP_IDX) && !(mode & M6812_OP_D_IDX_2))
                  || !(current_architecture & cpu9s12x)))
            {
              as_bad (_("Offset out of 5-bit range for movw/movb insn: %ld."),
@@ -2422,7 +2417,7 @@ build_insn_xg (struct m68hc11_opcode *opcode,
       f = m68hc11_new_insn (1);
       number_to_chars_bigendian (f, opcode->opcode >> 8, 1); /* High byte.  */
       fixup8_xg (&operands[0].exp, format, M68XG_OP_REL9);
-    } 
+    }
   else if (format & M68XG_OP_REL10)
     {
       f = m68hc11_new_insn (1);
@@ -2951,7 +2946,7 @@ md_assemble (char *str)
                }
              else
                as_bad ("No opcode found\n");
-              
+
               return;
             }
           else
@@ -2975,7 +2970,7 @@ md_assemble (char *str)
                {
                  opcode_local.opcode |= (operands[0].exp.X_add_number);
                  operands[0].mode = M68XG_OP_IMM3;
-  
+
                  opcode = find (opc, operands, 1);
                   if (opcode)
                     {
@@ -3069,7 +3064,7 @@ md_assemble (char *str)
 
       if (opc->format & (M68XG_OP_REL9 | M68XG_OP_REL10))
         {
-          opcode_local.format = opc->format; 
+          opcode_local.format = opc->format;
           input_line_pointer = skip_whites (input_line_pointer);
           expression (&operands[0].exp);
           if (operands[0].exp.X_op == O_illegal)
@@ -3095,12 +3090,12 @@ md_assemble (char *str)
       if ((*input_line_pointer == '\n') || (*input_line_pointer == '\r')
           || (*input_line_pointer == '\0'))
         return; /* nothing left */
-      
+
       if (*input_line_pointer == '#')
         {
           as_bad ("No register specified before hash\n");
           return;
-        } 
+        }
 
       /* first operand is expected to be a register */
       if ((*input_line_pointer == 'R') || (*input_line_pointer == 'r'))
@@ -3167,12 +3162,12 @@ md_assemble (char *str)
                   if (opcode)
                    opcode_local.opcode = opcode->opcode
                      | (operands[0].reg1 << 8);
-                  
+
                   if (operands[0].exp.X_op != O_constant)
                     as_bad ("Only constants supported at for IMM4 mode\n");
                   else
                     {
-                      if (check_range 
+                      if (check_range
                           (operands[0].exp.X_add_number,M68XG_OP_R_IMM4))
                         opcode_local.opcode
                          |= (operands[0].exp.X_add_number << 4);
@@ -3228,7 +3223,7 @@ md_assemble (char *str)
                              com RD, RS alias for xnor RD,R0,RS
                              mov RD, RS alias for or RD, R0, RS
                              neg RD, RS alias for sub RD, R0, RS */
-                          opcode_local.opcode = opcode->opcode 
+                          opcode_local.opcode = opcode->opcode
                             | (operands[0].reg1 << 8) | (operands[1].reg1 << 2);
                         }
                       else if ((strncmp (opc->opcode->name, "cmp",3) == 0)
@@ -3237,7 +3232,7 @@ md_assemble (char *str)
                           /* special cases for:
                              cmp RS1, RS2 alias for sub R0, RS1, RS2
                              cpc RS1, RS2 alias for sbc R0, RS1, RS2 */
-                          opcode_local.opcode = opcode->opcode 
+                          opcode_local.opcode = opcode->opcode
                            | (operands[0].reg1 << 5) | (operands[1].reg1 << 2);
                         }
                       else
@@ -3279,7 +3274,7 @@ md_assemble (char *str)
                       opcode = find (opc, operands, 1);
                       if (opcode)
                         {
-                          opcode_local.opcode = opcode->opcode 
+                          opcode_local.opcode = opcode->opcode
                             | (operands[0].reg1 << 8) | (operands[1].reg1 << 5)
                             | (operands[2].reg1 << 2);
                           opcode_local.format = M68XG_OP_NONE;
@@ -3316,7 +3311,7 @@ md_assemble (char *str)
                 }
 
               input_line_pointer = skip_whites (input_line_pointer);
-              
+
               if (*input_line_pointer != ',')
                 {
                   as_bad (_("Missing operand."));
@@ -3351,7 +3346,7 @@ md_assemble (char *str)
                     {
                       input_line_pointer++;
                     }
-                      
+
                   /* Ok so far, can only be one mode. */
                   opcode_local.format = M68XG_OP_R_R_OFFS5;
                   operands[0].mode = M68XG_OP_R_R_OFFS5;
@@ -3762,10 +3757,9 @@ s_m68hc11_mark_symbol (int mark)
 
   do
     {
-      name = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (&name);
       symbolP = symbol_find_or_make (name);
-      *input_line_pointer = c;
+      (void) restore_line_pointer (c);
 
       SKIP_WHITESPACE ();
 
@@ -3834,8 +3828,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
-  reloc = (arelent *) xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc = XNEW (arelent);
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
   if (fixp->fx_r_type == 0)
@@ -3960,7 +3954,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, asection *sec ATTRIBUTE_UNUSED,
   char *buffer_address = fragP->fr_literal;
 
   /* Address in object code of the displacement.  */
-  register int object_address = fragP->fr_fix + fragP->fr_address;
+  int object_address = fragP->fr_fix + fragP->fr_address;
 
   buffer_address += fragP->fr_fix;
 
@@ -4435,7 +4429,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
                      value);
       if (value >= 0)
        where[0] |= value;
-      else 
+      else
        where[0] |= (0x10 | (16 + value));
       break;
 
@@ -4447,7 +4441,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
         /* sign bit already in xb postbyte */
       if (value >= 0)
         where[1] = value;
-      else 
+      else
         where[1] = (256 + value);
       break;
 
This page took 0.029251 seconds and 4 git commands to generate.