This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 gas patch: scale factor handling improvements





This patch changes i386_intel_memory_operand to handle the scale factor
in more places.  

Ok to commit?


                                        -gavin...

	* config/tc-i386.c (i386_scale_nowarn): New.  Adapted from i386_scale.
	(i386_scale): Use it.
	(i386_index_check): Delay check of scale_factor && !index_reg till here.
	(i386_intel_memory_operand): Add handling of scale factor before
	the index register.   

Index: tc-i386.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-i386.c,v
retrieving revision 1.150
diff -c -p -r1.150 tc-i386.c
*** tc-i386.c	2000/04/28 13:40:27	1.150
--- tc-i386.c	2000/05/19 15:20:33
*************** i386_immediate (imm_start)
*** 2642,2651 ****
    return 1;
  }
  
! static int i386_scale PARAMS ((char *));
  
  static int
! i386_scale (scale)
       char *scale;
  {
    if (!isdigit (*scale))
--- 2642,2654 ----
    return 1;
  }
  
! 
! 
! 
! static int i386_scale_nowarn PARAMS ((char *));
  
  static int
! i386_scale_nowarn (scale)
       char *scale;
  {
    if (!isdigit (*scale))
*************** i386_scale (scale)
*** 2656,2686 ****
      case '0':
      case '1':
        i.log2_scale_factor = 0;
!       break;
      case '2':
        i.log2_scale_factor = 1;
!       break;
      case '4':
        i.log2_scale_factor = 2;
!       break;
      case '8':
        i.log2_scale_factor = 3;
!       break;
      default:
      bad_scale:
-       as_bad (_("expecting scale factor of 1, 2, 4, or 8: got `%s'"),
-               scale);
        return 0;
      }
!   if (i.log2_scale_factor != 0 && ! i.index_reg)
      {
!       as_warn (_("scale factor of %d without an index register"),
!                1 << i.log2_scale_factor);
! #if SCALE1_WHEN_NO_INDEX
!       i.log2_scale_factor = 0;
! #endif
      }
!   return 1;
  }
  
  static int i386_displacement PARAMS ((char *, char *));
--- 2659,2696 ----
      case '0':
      case '1':
        i.log2_scale_factor = 0;
!       return 1;
      case '2':
        i.log2_scale_factor = 1;
!       return 1;
      case '4':
        i.log2_scale_factor = 2;
!       return 1;
      case '8':
        i.log2_scale_factor = 3;
!       return 1;
      default:
      bad_scale:
        return 0;
      }
! }
! 
! static int i386_scale PARAMS ((char *));
! 
! static int
! i386_scale (scale)
!      char *scale;
! {
!   if (i386_scale_nowarn (scale))
      {
!       return 1;
      }
!   else
!     {
!       as_bad (_("expecting scale factor of 1, 2, 4, or 8: got `%s'"),
!               scale);
!       return 0;
!     }
  }
  
  static int i386_displacement PARAMS ((char *, char *));
*************** i386_index_check (operand_string)
*** 3084,3090 ****
--- 3094,3111 ----
  {
  #if INFER_ADDR_PREFIX
    int fudged = 0;
+ #endif
  
+   if (i.log2_scale_factor != 0 && ! i.index_reg)
+     {
+       as_warn (_("scale factor of %d without an index register"),
+ 	       1 << i.log2_scale_factor);
+ #if SCALE1_WHEN_NO_INDEX
+       i.log2_scale_factor = 0;
+ #endif
+     }
+   
+ #if INFER_ADDR_PREFIX
   tryprefix:
  #endif
    if (flag_16bit_code ^ (i.prefix[ADDR_PREFIX] != 0)
*************** i386_intel_memory_operand (operand_strin
*** 3207,3212 ****
--- 3228,3234 ----
  	  const reg_entry *temp_reg;
  	  char *end_op;
  	  char *temp_string;
+ 	  int found_leading_scale;
  
  	  while (*end_of_operand_string != '+'
  		 && *end_of_operand_string != '-'
*************** i386_intel_memory_operand (operand_strin
*** 3222,3231 ****
  		++temp_string;
  	    }
  
  	  if ((*temp_string == REGISTER_PREFIX || allow_naked_reg)
  	      && (temp_reg = parse_register (temp_string, &end_op)) != NULL)
  	    {
! 	      if (i.base_reg == NULL)
  		i.base_reg = temp_reg;
  	      else
  		i.index_reg = temp_reg;
--- 3244,3272 ----
  		++temp_string;
  	    }
  
+ 	  found_leading_scale = 0;
+ 	  if (*end_of_operand_string == '*'
+ 	      && i386_scale_nowarn (temp_string))
+ 	    {
+ 	      found_leading_scale = 1;
+ 	      end_of_operand_string++;
+ 	      op_string = temp_string = end_of_operand_string;
+ 	      if (is_space_char (*temp_string))
+ 		++temp_string;
+ 
+ 	      while (*end_of_operand_string != '+'
+ 		     && *end_of_operand_string != '-'
+ 		     && *end_of_operand_string != '*'
+ 		     && *end_of_operand_string != ']')
+ 		end_of_operand_string++;
+ 	    }
+ 
  	  if ((*temp_string == REGISTER_PREFIX || allow_naked_reg)
  	      && (temp_reg = parse_register (temp_string, &end_op)) != NULL)
  	    {
! 	      if (i.base_reg == NULL
! 		  && !found_leading_scale
! 		  && *end_of_operand_string != '*')
  		i.base_reg = temp_reg;
  	      else
  		i.index_reg = temp_reg;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]