* doc/Makefile.am (config.texi): Set top_srcdir.
[binutils-gdb.git] / gas / config / tc-tic4x.c
index 09a90dea007934a25b924da2c472164c56fe7938..8707180c13285f4163d71dc68faa8e428f9a4565 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-tic4x.c -- Assemble for the Texas Instruments TMS320C[34]x.
-   Copyright (C) 1997,1998, 2002, 2003 Free Software Foundation.
+   Copyright (C) 1997,1998, 2002, 2003, 2005 Free Software Foundation.
 
    Contributed by Michael P. Hayes (m.hayes@elec.canterbury.ac.nz)
 
@@ -17,8 +17,8 @@
 
    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.  */
+   the Free Software Foundation, 51 Franklin Street - Fifth Floor
+   Boston, MA 02110-1301, USA.  */
 /*
   TODOs:
   ------
     should be possible to define a 32-bits pattern.
 
   o .align fills all section with NOP's when used regardless if has
-    been used in .text or .data. (However the .align is primarely
+    been used in .text or .data. (However the .align is primarily
     intended used in .text sections. If you require something else,
     use .align <size>,0x00)
 
-  o .align: Implement a 'bu' insn if the number of nop's exeeds 4
+  o .align: Implement a 'bu' insn if the number of nop's exceeds 4
     within the align frag. if(fragsize>4words) insert bu fragend+1
     first.
 
@@ -46,8 +46,7 @@
 */
 
 #include <stdio.h>
-#include <ctype.h>
-
+#include "safe-ctype.h"
 #include "as.h"
 #include "opcode/tic4x.h"
 #include "subsegs.h"
@@ -158,7 +157,7 @@ static void tic4x_insert_sym
 static char *tic4x_expression
   PARAMS ((char *, expressionS *));
 static char *tic4x_expression_abs
-  PARAMS ((char *, int *));
+  PARAMS ((char *, offsetT *));
 static void tic4x_emit_char
   PARAMS ((char, int));
 static void tic4x_seg_alloc
@@ -195,8 +194,6 @@ static tic4x_inst_t *tic4x_inst_make
   PARAMS ((char *, unsigned long, char *));
 static int tic4x_inst_add
   PARAMS ((tic4x_inst_t *));
-void md_begin
-  PARAMS ((void));
 void tic4x_end
   PARAMS ((void));
 static int tic4x_indirect_parse
@@ -211,38 +208,12 @@ static void tic4x_insn_output
   PARAMS ((tic4x_insn_t *));
 static int tic4x_operands_parse
   PARAMS ((char *, tic4x_operand_t *, int ));
-void md_assemble
-  PARAMS ((char *));
 void tic4x_cleanup
   PARAMS ((void));
-char *md_atof
-  PARAMS ((int, char *, int *));
-void md_apply_fix3
-  PARAMS ((fixS *, valueT *, segT ));
-void md_convert_frag
-  PARAMS ((bfd *, segT, fragS *));
-void md_create_short_jump
-  PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
-void md_create_long_jump
-  PARAMS ((char *, addressT, addressT, fragS *, symbolS *));
-int md_estimate_size_before_relax
-  PARAMS ((register fragS *, segT));
-int md_parse_option
-  PARAMS ((int, char *));
-void md_show_usage
-  PARAMS ((FILE *));
 int tic4x_unrecognized_line
   PARAMS ((int));
-symbolS *md_undefined_symbol
-  PARAMS ((char *));
-void md_operand
-  PARAMS ((expressionS *));
-valueT md_section_align
-  PARAMS ((segT, valueT));
 static int tic4x_pc_offset
   PARAMS ((unsigned int));
-long md_pcrel_from
-  PARAMS ((fixS *));
 int tic4x_do_align
   PARAMS ((int, const char *, int, int));
 void tic4x_start_line
@@ -286,7 +257,6 @@ const pseudo_typeS
 
 int md_short_jump_size = 4;
 int md_long_jump_size = 4;
-const int md_reloc_size = RELSZ;       /* Coff headers.  */
 
 /* This array holds the chars that always start a comment.  If the
    pre-processor is disabled, these aren't very useful.  */
@@ -326,7 +296,7 @@ extern FLONUM_TYPE generic_floating_point_number;
 
 /* Precision in LittleNums.  */
 #define MAX_PRECISION (4)       /* Its a bit overkill for us, but the code
-                                   reqires it... */
+                                   requires it... */
 #define S_PRECISION (1)                /* Short float constants 16-bit.  */
 #define F_PRECISION (2)                /* Float and double types 32-bit.  */
 #define E_PRECISION (4)         /* Extended precision, 64-bit (real 40-bit). */
@@ -352,7 +322,7 @@ tic4x_gen_to_words (flonum, words, precision)
   unsigned int rbit;            /* Round bit. */
   int shift;                   /* Shift count.  */
 
-  /* NOTE: Svein Seldal <Svein.Seldal@solidas.com>
+  /* NOTE: Svein Seldal <Svein@dev.seldal.com>
      The code in this function is altered slightly to support floats
      with 31-bits mantissas, thus the documentation below may be a
      little bit inaccurate.
@@ -463,7 +433,7 @@ tic4x_gen_to_words (flonum, words, precision)
 
      We now have to left shift the other littlenums by the same amount,
      propagating the shifted bits into the more significant littlenums.
-     To save a lot of unecessary shifting we only have to consider
+     To save a lot of unnecessary shifting we only have to consider
      two or three littlenums, since the greatest number of mantissa
      bits required is 24 + 1 rounding bit.  While two littlenums
      provide 32 bits of precision, the most significant littlenum
@@ -737,7 +707,7 @@ tic4x_insert_reg (regname, regnum)
   symbol_table_insert (symbol_new (regname, reg_section, (valueT) regnum,
                                   &zero_address_frag));
   for (i = 0; regname[i]; i++)
-    buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i];
+    buf[i] = ISLOWER (regname[i]) ? TOUPPER (regname[i]) : regname[i];
   buf[i] = '\0';
 
   symbol_table_insert (symbol_new (buf, reg_section, (valueT) regnum,
@@ -776,7 +746,7 @@ tic4x_expression (str, exp)
 static char *
 tic4x_expression_abs (str, value)
      char *str;
-     int *value;
+     offsetT *value;
 {
   char *s;
   char *t;
@@ -872,7 +842,7 @@ tic4x_bss (x)
   char c;
   char *name;
   char *p;
-  int size;
+  offsetT size;
   segT current_seg;
   subsegT current_subseg;
   symbolS *symbolP;
@@ -893,7 +863,7 @@ tic4x_bss (x)
     tic4x_expression_abs (++input_line_pointer, &size);
   if (size < 0)
     {
-      as_bad (".bss size %d < 0!", size);
+      as_bad (".bss size %ld < 0!", (long) size);
       return;
     }
   subseg_set (bss_section, 0);
@@ -1053,7 +1023,7 @@ tic4x_eval (x)
      int x ATTRIBUTE_UNUSED;
 {
   char c;
-  int value;
+  offsetT value;
   char *name;
 
   SKIP_WHITESPACE ();
@@ -1089,7 +1059,7 @@ tic4x_sect (x)
   char *subsection_name;
   char *name;
   segT seg;
-  int num;
+  offsetT num;
 
   SKIP_WHITESPACE ();
   if (*input_line_pointer == '"')
@@ -1174,6 +1144,7 @@ tic4x_set (x)
          ignore_rest_of_line ();
          return;
        }
+      ++input_line_pointer;
       symbolP = symbol_find_or_make (name);
     }
   else
@@ -1192,7 +1163,7 @@ tic4x_usect (x)
   char *name;
   char *section_name;
   segT seg;
-  int size, alignment_flag;
+  offsetT size, alignment_flag;
   segT current_seg;
   subsegT current_subseg;
 
@@ -1255,15 +1226,15 @@ static void
 tic4x_version (x)
      int x ATTRIBUTE_UNUSED;
 {
-  unsigned int temp;
+  offsetT temp;
 
   input_line_pointer =
     tic4x_expression_abs (input_line_pointer, &temp);
   if (!IS_CPU_TIC3X (temp) && !IS_CPU_TIC4X (temp))
-    as_bad ("This assembler does not support processor generation %d",
-           temp);
+    as_bad ("This assembler does not support processor generation %ld",
+           (long) temp);
 
-  if (tic4x_cpu && temp != tic4x_cpu)
+  if (tic4x_cpu && temp != (offsetT) tic4x_cpu)
     as_warn ("Changing processor generation on fly not supported...");
   tic4x_cpu = temp;
   demand_empty_rest_of_line ();
@@ -1556,7 +1527,7 @@ tic4x_indirect_parse (operand, indirect)
          if (*s == '%')
            s++;
 #endif
-         while (isalnum (*s))
+         while (ISALNUM (*s))
            *b++ = *s++;
          *b++ = '\0';
          if (!(symbolP = symbol_find (name)))
@@ -1623,7 +1594,7 @@ tic4x_indirect_parse (operand, indirect)
          break;
 
        default:
-         if (tolower (*s) != *n)
+         if (TOLOWER (*s) != *n)
            return 0;
          s++;
        }
@@ -2704,7 +2675,7 @@ md_atof (type, litP, sizeP)
   int ieee;
   LITTLENUM_TYPE words[MAX_LITTLENUMS];
   LITTLENUM_TYPE *wordP;
-  unsigned char *t;
+  char *t;
 
   switch (type)
     {
@@ -2747,7 +2718,7 @@ md_atof (type, litP, sizeP)
   if (t)
     input_line_pointer = t;
   *sizeP = prec * sizeof (LITTLENUM_TYPE);
-  t = litP;
+
   /* This loops outputs the LITTLENUMs in REVERSE order; in accord with
      little endian byte order.  */
   /* SES: However it is required to put the words (32-bits) out in the
@@ -2771,7 +2742,7 @@ md_atof (type, litP, sizeP)
 }
 
 void 
-md_apply_fix3 (fixP, value, seg)
+md_apply_fix (fixP, value, seg)
      fixS *fixP;
      valueT *value;
      segT seg ATTRIBUTE_UNUSED;
@@ -2869,7 +2840,7 @@ md_parse_option (c, arg)
   switch (c)
     {
     case OPTION_CPU:             /* cpu brand */
-      if (tolower (*arg) == 'c')
+      if (TOLOWER (*arg) == 'c')
        arg++;
       tic4x_cpu = atoi (arg);
       if (!IS_CPU_TIC3X (tic4x_cpu) && !IS_CPU_TIC4X (tic4x_cpu))
@@ -2959,14 +2930,14 @@ tic4x_unrecognized_line (c)
   int lab;
   char *s;
 
-  if (c != '$' || !isdigit (input_line_pointer[0]))
+  if (c != '$' || ! ISDIGIT (input_line_pointer[0]))
     return 0;
 
   s = input_line_pointer;
 
   /* Let's allow multiple digit local labels.  */
   lab = 0;
-  while (isdigit (*s))
+  while (ISDIGIT (*s))
     {
       lab = lab * 10 + *s - '0';
       s++;
@@ -2991,13 +2962,13 @@ md_undefined_symbol (name)
      char *name;
 {
   /* Look for local labels of the form $n.  */
-  if (name[0] == '$' && isdigit (name[1]))
+  if (name[0] == '$' && ISDIGIT (name[1]))
     {
       symbolS *symbolP;
       char *s = name + 1;
       int lab = 0;
 
-      while (isdigit ((unsigned char) *s))
+      while (ISDIGIT ((unsigned char) *s))
        {
          lab = lab * 10 + *s - '0';
          s++;
@@ -3101,9 +3072,10 @@ long
 md_pcrel_from (fixP)
      fixS *fixP;
 {
-  unsigned char *buf = fixP->fx_where + fixP->fx_frag->fr_literal;
+  unsigned char *buf;
   unsigned int op;
 
+  buf = (unsigned char *) fixP->fx_frag->fr_literal + fixP->fx_where;
   op = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
 
   return ((fixP->fx_where + fixP->fx_frag->fr_address) >> 2) +
@@ -3119,16 +3091,16 @@ tic4x_do_align (alignment, fill, len, max)
      int len ATTRIBUTE_UNUSED;
      int max ATTRIBUTE_UNUSED;
 {
-  unsigned long nop = NOP_OPCODE;
+  unsigned long nop = TIC_NOP_OPCODE;
 
-  /* Because we are talking lwords, not bytes, adjust aligment to do words */
+  /* Because we are talking lwords, not bytes, adjust alignment to do words */
   alignment += 2;
   
   if (alignment != 0 && !need_pass_2)
     {
       if (fill == NULL)
         {
-          /*if (subseg_text_p (now_seg))*/  /* FIXME: doesnt work for .text for some reason */
+          /*if (subseg_text_p (now_seg))*/  /* FIXME: doesn't work for .text for some reason */
           frag_align_pattern( alignment, (const char *)&nop, sizeof(nop), max);
           return 1;
           /*else
@@ -3140,7 +3112,7 @@ tic4x_do_align (alignment, fill, len, max)
        frag_align_pattern (alignment, fill, len, max);
     }
   
-  /* Return 1 to skip the default aligment function */
+  /* Return 1 to skip the default alignment function */
   return 1;
 }
 
@@ -3163,10 +3135,6 @@ tic4x_start_line ()
          /* So line counters get bumped.  */
          input_line_pointer[-1] = '\n';
        }
-      else
-        {
-          as_bad ("Parallel opcode cannot contain more than two instructions");
-        }
     }
   else
     {