* config/tc-h8500.c (md_begin): Use a local variable when
[deliverable/binutils-gdb.git] / gas / config / tc-h8500.c
index 0379f7176cf4aa66abeae8f45e54353db3c3ca1b..1cb1bcfa6d0effba979d49313cb9200006ab686b 100644 (file)
@@ -33,7 +33,7 @@
 
 const char comment_chars[] = "!";
 const char line_separator_chars[] = ";";
-const char line_comment_chars[] = "!";
+const char line_comment_chars[] = "!#";
 
 /* This table describes all the machine specific pseudo-ops the assembler
    has to support.  The fields are:
@@ -87,7 +87,7 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
 #define WORD_F 32767
 #define WORD_B 32768
 
-relax_typeS md_relax_table[C (END, 0)];
+const relax_typeS md_relax_table[C (END, 0)];
 
 static struct hash_control *opcode_hash_control;       /* Opcode mnemonics */
 
@@ -102,6 +102,7 @@ md_begin ()
   h8500_opcode_info *opcode;
   char prev_buffer[100];
   int idx = 0;
+  register relax_typeS *table;
 
   opcode_hash_control = hash_new ();
   prev_buffer[0] = 0;
@@ -116,36 +117,38 @@ md_begin ()
        }
     }
 
-  /* Initialize the relax table */
-  md_relax_table[C (BRANCH, BYTE_DISP)].rlx_forward = BYTE_F;
-  md_relax_table[C (BRANCH, BYTE_DISP)].rlx_backward = BYTE_B;
-  md_relax_table[C (BRANCH, BYTE_DISP)].rlx_length = 2;
-  md_relax_table[C (BRANCH, BYTE_DISP)].rlx_more = C (BRANCH, WORD_DISP);
-
-  md_relax_table[C (BRANCH, WORD_DISP)].rlx_forward = WORD_F;
-  md_relax_table[C (BRANCH, WORD_DISP)].rlx_backward = WORD_B;
-  md_relax_table[C (BRANCH, WORD_DISP)].rlx_length = 3;
-  md_relax_table[C (BRANCH, WORD_DISP)].rlx_more = 0;
-
-  md_relax_table[C (SCB_F, BYTE_DISP)].rlx_forward = BYTE_F;
-  md_relax_table[C (SCB_F, BYTE_DISP)].rlx_backward = BYTE_B;
-  md_relax_table[C (SCB_F, BYTE_DISP)].rlx_length = 3;
-  md_relax_table[C (SCB_F, BYTE_DISP)].rlx_more = C (SCB_F, WORD_DISP);
-
-  md_relax_table[C (SCB_F, WORD_DISP)].rlx_forward = WORD_F;
-  md_relax_table[C (SCB_F, WORD_DISP)].rlx_backward = WORD_B;
-  md_relax_table[C (SCB_F, WORD_DISP)].rlx_length = 8;
-  md_relax_table[C (SCB_F, WORD_DISP)].rlx_more = 0;
-
-  md_relax_table[C (SCB_TST, BYTE_DISP)].rlx_forward = BYTE_F;
-  md_relax_table[C (SCB_TST, BYTE_DISP)].rlx_backward = BYTE_B;
-  md_relax_table[C (SCB_TST, BYTE_DISP)].rlx_length = 3;
-  md_relax_table[C (SCB_TST, BYTE_DISP)].rlx_more = C (SCB_TST, WORD_DISP);
-
-  md_relax_table[C (SCB_TST, WORD_DISP)].rlx_forward = WORD_F;
-  md_relax_table[C (SCB_TST, WORD_DISP)].rlx_backward = WORD_B;
-  md_relax_table[C (SCB_TST, WORD_DISP)].rlx_length = 10;
-  md_relax_table[C (SCB_TST, WORD_DISP)].rlx_more = 0;
+  /* Initialize the relax table.  We use a local variable to avoid
+     warnings about modifying a supposedly const data structure.  */
+  table = (relax_typeS *) md_relax_table;
+  table[C (BRANCH, BYTE_DISP)].rlx_forward = BYTE_F;
+  table[C (BRANCH, BYTE_DISP)].rlx_backward = BYTE_B;
+  table[C (BRANCH, BYTE_DISP)].rlx_length = 2;
+  table[C (BRANCH, BYTE_DISP)].rlx_more = C (BRANCH, WORD_DISP);
+
+  table[C (BRANCH, WORD_DISP)].rlx_forward = WORD_F;
+  table[C (BRANCH, WORD_DISP)].rlx_backward = WORD_B;
+  table[C (BRANCH, WORD_DISP)].rlx_length = 3;
+  table[C (BRANCH, WORD_DISP)].rlx_more = 0;
+
+  table[C (SCB_F, BYTE_DISP)].rlx_forward = BYTE_F;
+  table[C (SCB_F, BYTE_DISP)].rlx_backward = BYTE_B;
+  table[C (SCB_F, BYTE_DISP)].rlx_length = 3;
+  table[C (SCB_F, BYTE_DISP)].rlx_more = C (SCB_F, WORD_DISP);
+
+  table[C (SCB_F, WORD_DISP)].rlx_forward = WORD_F;
+  table[C (SCB_F, WORD_DISP)].rlx_backward = WORD_B;
+  table[C (SCB_F, WORD_DISP)].rlx_length = 8;
+  table[C (SCB_F, WORD_DISP)].rlx_more = 0;
+
+  table[C (SCB_TST, BYTE_DISP)].rlx_forward = BYTE_F;
+  table[C (SCB_TST, BYTE_DISP)].rlx_backward = BYTE_B;
+  table[C (SCB_TST, BYTE_DISP)].rlx_length = 3;
+  table[C (SCB_TST, BYTE_DISP)].rlx_more = C (SCB_TST, WORD_DISP);
+
+  table[C (SCB_TST, WORD_DISP)].rlx_forward = WORD_F;
+  table[C (SCB_TST, WORD_DISP)].rlx_backward = WORD_B;
+  table[C (SCB_TST, WORD_DISP)].rlx_length = 10;
+  table[C (SCB_TST, WORD_DISP)].rlx_more = 0;
 
 }
 
@@ -258,7 +261,6 @@ parse_exp (s, op, page)
 {
   char *save;
   char *new;
-  segT seg;
 
   save = input_line_pointer;
 
@@ -268,9 +270,13 @@ parse_exp (s, op, page)
       if (s[1] == 'p' && s[2] == 'a' && s[3] == 'g' && s[4] == 'e')
        {
          s += 5;
-
          *page = 'p';
        }
+      if (s[1] == 'h' && s[2] == 'i' && s[3] == '1' && s[4] == '6')
+       {
+         s += 5;
+         *page = 'h';
+       }
       else if (s[1] == 'o' && s[2] == 'f' && s[3] == 'f')
        {
          s += 4;
@@ -280,26 +286,11 @@ parse_exp (s, op, page)
 
   input_line_pointer = s;
 
-  seg = expr (0, op);
+  if (expression (op) == O_absent)
+    as_bad ("missing operand");
   new = input_line_pointer;
   input_line_pointer = save;
-  if (SEG_NORMAL (seg))
-    return new;
-  switch (seg)
-    {
-    case SEG_ABSOLUTE:
-    case SEG_UNKNOWN:
-    case SEG_DIFFERENCE:
-    case SEG_BIG:
-    case SEG_REGISTER:
-      return new;
-    case SEG_ABSENT:
-      as_bad ("Missing operand");
-      return new;
-    default:
-      as_bad ("Don't understand operand of type %s", segment_name (seg));
-      return new;
-    }
+  return new;
 }
 
 typedef enum
@@ -353,12 +344,16 @@ skip_colonthing (sign, ptr, exp, def, size8, size16, size24)
        {
          exp->type = IMM8;
        }
+      else if (exp->page == 'h')
+       {
+         exp->type = IMM16;
+       }
       else
        {
          /* Let's work out the size from the context */
          int n = exp->exp.X_add_number;
          if (size8
-             && exp->exp.X_seg == SEG_ABSOLUTE
+             && exp->exp.X_op == O_constant
              && ((sign == exp_signed && (n >= -128 && n <= 127))
                  || (sign == exp_unsigned && (n >= 0 && (n <= 255)))
                  || (sign == exp_sandu && (n >= -128 && (n <= 255)))))
@@ -422,9 +417,9 @@ parse_reglist (src, op)
     }
   idx++;
   op->exp.X_add_symbol = 0;
-  op->exp.X_subtract_symbol = 0;
+  op->exp.X_op_symbol = 0;
   op->exp.X_add_number = mask;
-  op->exp.X_seg = SEG_ABSOLUTE;
+  op->exp.X_op = O_constant;
   op->type = IMM8;
   return idx;
 
@@ -787,7 +782,7 @@ get_specific (opcode, operands)
              break;
            case QIM:
              if (user->type == IMM8
-                 && user->exp.X_seg == SEG_ABSOLUTE
+                 && user->exp.X_op == O_constant
                  &&
                  (user->exp.X_add_number == -2
                   || user->exp.X_add_number == -1
@@ -863,7 +858,7 @@ check (operand, low, high)
      int low;
      int high;
 {
-  if (operand->X_seg != SEG_ABSOLUTE
+  if (operand->X_op != O_constant
       || operand->X_add_number < low
       || operand->X_add_number > high)
     {
@@ -881,14 +876,12 @@ insert (output, index, exp, reloc, pcrel)
      int reloc;
      int pcrel;
 {
-  fix_new (frag_now,
-          output - frag_now->fr_literal + index,
-          4,                   /* always say size is 4, but we know better */
-          exp->X_add_symbol,
-          exp->X_subtract_symbol,
-          exp->X_add_number,
-          pcrel,
-          reloc);
+  fix_new_exp (frag_now,
+              output - frag_now->fr_literal + index,
+              4,               /* always say size is 4, but we know better */
+              exp,
+              pcrel,
+              reloc);
 }
 
 void
@@ -982,9 +975,25 @@ build_bytes (opcode, operand)
            case FPIND_D8:
              insert (output, index, &displacement, R_H8500_IMM8, 0);
              break;
+
            case IMM16:
-             insert (output, index, &immediate, immediate_inpage ?
-                     R_H8500_LOW16 : R_H8500_IMM16, 0);
+             {
+               int p;
+               switch (immediate_inpage) {
+               case 'p':
+                 p = R_H8500_LOW16;
+                 break;
+               case 'h':               
+                 p = R_H8500_HIGH16;
+                 break;
+               default:
+                 p = R_H8500_IMM16;
+                 break;
+               }
+               
+               insert (output, index, &immediate,p, 0);
+             }
+               
              index++;
              break;
            case RLIST:
@@ -1244,8 +1253,8 @@ tc_aout_fix_to_chars ()
 void
 md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
      char *ptr;
-     long from_addr;
-     long to_addr;
+     addressT from_addr;
+     addressT to_addr;
      fragS *frag;
      symbolS *to_symbol;
 {
@@ -1255,7 +1264,7 @@ md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
 void
 md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
      char *ptr;
-     long from_addr, to_addr;
+     addressT from_addr, to_addr;
      fragS *frag;
      symbolS *to_symbol;
 {
@@ -1375,7 +1384,6 @@ md_convert_frag (headers, fragP)
               fragP->fr_fix + inst_size,
               4,
               fragP->fr_symbol,
-              0,
               fragP->fr_offset,
               0,
               R_H8500_PCREL16);
@@ -1402,10 +1410,10 @@ md_convert_frag (headers, fragP)
 
 }
 
-long
-DEFUN (md_section_align, (seg, size),
-       segT seg AND
-       long size)
+valueT
+md_section_align (seg, size)
+     segT seg ;
+     valueT size;
 {
   return ((size + (1 << section_alignment[(int) seg]) - 1) 
          & (-1 << section_alignment[(int) seg]));
@@ -1440,6 +1448,10 @@ md_apply_fix (fixP, val)
     case R_H8500_HIGH8:
       *buf++ = val >> 16;
       break;
+    case R_H8500_HIGH16:
+      *buf++ = val >> 24;
+      *buf++ = val >> 16;
+      break;
     case R_H8500_IMM24:
       *buf++ = (val >> 16);
       *buf++ = (val >> 8);
@@ -1506,7 +1518,7 @@ md_estimate_size_before_relax (fragP, segment_type)
 void
 md_number_to_chars (ptr, use, nbytes)
      char *ptr;
-     long use;
+     valueT use;
      int nbytes;
 {
   switch (nbytes)
This page took 0.026574 seconds and 4 git commands to generate.