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]

[patch] avr-binutils changes


Here are a few more changes for AVR binutils - I hope you find them
useful.  The patch is quite big. but much of it are really indentation
changes, and cleanups that don't change how the code works.  A few
warnings are removed, and a few new target-specific switches added.

Thanks,
Marek


bfd/ChangeLog:

2000-07-03  Marek Michalkiewicz  <marekm@linux.org.pl>

	* elf32-avr.c (bfd_elf32_bfd_reloc_type_lookup):
	Add ATTRIBUTE_UNUSED to unused arguments to avoid warnings.
	(avr_info_to_howto_rela): Likewise.
	(elf32_avr_gc_mark_hook): Likewise.
	(elf32_avr_gc_sweep_hook): Likewise.
	(elf32_avr_relocate_section): Likewise.


gas/ChangeLog:

2000-07-03  Marek Michalkiewicz  <marekm@linux.org.pl>

	* config/tc-avr.c: Change _ () to _() around all strings marked
	for translation (exception from the usual coding style).
	(avr_opt): New struct variable, how the new switches are set.
	(OPTION_MMCU): Define as 'm' and actually use.
	(md_longopts): Add -mall-opcodes, -mno-skip-bug, -mno-wrap.
	(show_mcu_list): New function, display the list of known MCUs.
	(md_show_usage): Document the new switches.  Call show_mcu_list.
	(avr_set_arch): Change 'm' to OPTION_MMCU.
	(md_parse_option): Call show_mcu_list if unknown MCU specified.
	Handle the new switches.
	(avr_operands): Disable warnings for undefined combinations of
	operands if -mall-opcodes.  Disable warnings for skipping two-word
	instructions if enhanced core or -mno-skip-bug.
	(avr_operand): Accept all addressing modes on avr1 if -mall-opcodes.
	(md_apply_fix3): Reject 8K wrap if >8K or -mno-wrap.
	(md_assemble): Accept opcodes not supported by MCU if -mall-opcodes.
	(avr_ldi_expression): Warn about implicit lo8().
	* config/tc-avr.h (md_pcrel_from_section): Add prototype.


opcodes/ChangeLog:

2000-07-03  Marek Michalkiewicz  <marekm@linux.org.pl>

	* avr-dis.c (avr_operand): Change _ () to _() around all strings
	marked for translation (exception from the usual coding style).
	(print_insn_avr): Initialize insn2 to avoid warnings.


diff -Nrc3p orig/src/bfd/elf32-avr.c src/bfd/elf32-avr.c
*** orig/src/bfd/elf32-avr.c	Tue Jun 27 08:20:24 2000
--- src/bfd/elf32-avr.c	Mon Jul  3 13:33:26 2000
*************** struct avr_reloc_map
*** 369,375 ****
  
  static reloc_howto_type *
  bfd_elf32_bfd_reloc_type_lookup (abfd, code)
!      bfd *abfd;
       bfd_reloc_code_real_type code;
  {
    unsigned int i;
--- 369,375 ----
  
  static reloc_howto_type *
  bfd_elf32_bfd_reloc_type_lookup (abfd, code)
!      bfd *abfd ATTRIBUTE_UNUSED;
       bfd_reloc_code_real_type code;
  {
    unsigned int i;
*************** bfd_elf32_bfd_reloc_type_lookup (abfd, c
*** 389,395 ****
  
  static void
  avr_info_to_howto_rela (abfd, cache_ptr, dst)
!      bfd *abfd;
       arelent *cache_ptr;
       Elf32_Internal_Rela *dst;
  {
--- 389,395 ----
  
  static void
  avr_info_to_howto_rela (abfd, cache_ptr, dst)
!      bfd *abfd ATTRIBUTE_UNUSED;
       arelent *cache_ptr;
       Elf32_Internal_Rela *dst;
  {
*************** avr_info_to_howto_rela (abfd, cache_ptr,
*** 403,409 ****
  static asection *
  elf32_avr_gc_mark_hook (abfd, info, rel, h, sym)
       bfd *abfd;
!      struct bfd_link_info *info;
       Elf_Internal_Rela *rel;
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *sym;
--- 403,409 ----
  static asection *
  elf32_avr_gc_mark_hook (abfd, info, rel, h, sym)
       bfd *abfd;
!      struct bfd_link_info *info ATTRIBUTE_UNUSED;
       Elf_Internal_Rela *rel;
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *sym;
*************** elf32_avr_gc_mark_hook (abfd, info, rel,
*** 442,451 ****
  
  static boolean
  elf32_avr_gc_sweep_hook (abfd, info, sec, relocs)
!      bfd *abfd;
!      struct bfd_link_info *info;
!      asection *sec;
!      const Elf_Internal_Rela *relocs;
  {
    /* We don't use got and plt entries for avr.  */
    return true;
--- 442,451 ----
  
  static boolean
  elf32_avr_gc_sweep_hook (abfd, info, sec, relocs)
!      bfd *abfd ATTRIBUTE_UNUSED;
!      struct bfd_link_info *info ATTRIBUTE_UNUSED;
!      asection *sec ATTRIBUTE_UNUSED;
!      const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
  {
    /* We don't use got and plt entries for avr.  */
    return true;
*************** avr_final_link_relocate (howto, input_bf
*** 717,723 ****
  static boolean
  elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
  			    contents, relocs, local_syms, local_sections)
!      bfd *output_bfd;
       struct bfd_link_info *info;
       bfd *input_bfd;
       asection *input_section;
--- 717,723 ----
  static boolean
  elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
  			    contents, relocs, local_syms, local_sections)
!      bfd *output_bfd ATTRIBUTE_UNUSED;
       struct bfd_link_info *info;
       bfd *input_bfd;
       asection *input_section;
diff -Nrc3p orig/src/gas/config/tc-avr.c src/gas/config/tc-avr.c
*** orig/src/gas/config/tc-avr.c	Tue Jun 27 08:20:24 2000
--- src/gas/config/tc-avr.c	Mon Jul  3 15:07:19 2000
*************** static struct mcu_type_s mcu_types[] =
*** 96,101 ****
--- 96,111 ----
  static struct mcu_type_s default_mcu = {"avr2", AVR_ISA_2xxx,bfd_mach_avr2};
  static struct mcu_type_s *avr_mcu = &default_mcu;
  
+ /* AVR target-specific switches.  */
+ struct avr_opt_s
+ {
+   int all_opcodes;  /* -mall-opcodes: accept all known AVR opcodes */
+   int no_skip_bug;  /* -mno-skip-bug: no warnings for skipping 2-word insns */
+   int no_wrap;      /* -mno-wrap: reject rjmp/rcall with 8K wrap-around */
+ };
+ 
+ static struct avr_opt_s avr_opt = { 0, 0, 0 };
+ 
  const char EXP_CHARS[] = "eE";
  const char FLT_CHARS[] = "dD";
  static void avr_set_arch (int dummy);
*************** const pseudo_typeS md_pseudo_table[] =
*** 109,114 ****
--- 119,125 ----
  
  #define LDI_IMMEDIATE(x) (((x) & 0xf) | (((x) << 4) & 0xf00))
  
+ static void show_mcu_list (FILE *stream);
  static char * skip_space (char * s);
  static char * extract_word (char *from, char *to, int limit);
  static unsigned int avr_operand (struct avr_opcodes_s *opcode,
*************** static struct hash_control *avr_hash;
*** 150,163 ****
  /* Reloc modifiers hash control (hh8,hi8,lo8,pm_xx).  */
  static struct hash_control *avr_mod_hash;
  
! #define OPTION_MMCU (OPTION_MD_BASE + 1)
  
  struct option md_longopts[] = {
!   {"mmcu", required_argument, NULL, 'm'},
!   {NULL, no_argument, NULL, 0}
  };
  size_t md_longopts_size = sizeof(md_longopts);
  
  static inline char *
  skip_space (s)
       char * s;
--- 161,207 ----
  /* Reloc modifiers hash control (hh8,hi8,lo8,pm_xx).  */
  static struct hash_control *avr_mod_hash;
  
! #define OPTION_MMCU 'm'
! #define OPTION_ALL_OPCODES (OPTION_MD_BASE + 1)
! #define OPTION_NO_SKIP_BUG (OPTION_MD_BASE + 2)
! #define OPTION_NO_WRAP     (OPTION_MD_BASE + 3)
  
  struct option md_longopts[] = {
!   { "mmcu",   required_argument, NULL, OPTION_MMCU        },
!   { "mall-opcodes", no_argument, NULL, OPTION_ALL_OPCODES },
!   { "mno-skip-bug", no_argument, NULL, OPTION_NO_SKIP_BUG },
!   { "mno-wrap",     no_argument, NULL, OPTION_NO_WRAP     },
!   { NULL, no_argument, NULL, 0 }
  };
  size_t md_longopts_size = sizeof(md_longopts);
  
+ 
+ /* Display nicely formatted list of known MCU names.  */
+ static void
+ show_mcu_list (FILE *stream)
+ {
+   int i, x;
+ 
+   fprintf (stream, _("Known MCU names:"));
+   x = 1000;
+   for (i = 0; mcu_types[i].name; i++)
+     {
+       int len = strlen (mcu_types[i].name);
+       x += len + 1;
+       if (x < 75)
+ 	{
+ 	  fprintf (stream, " %s", mcu_types[i].name);
+ 	}
+       else
+ 	{
+ 	  fprintf (stream, "\n  %s", mcu_types[i].name);
+ 	  x = len + 2;
+ 	}
+     }
+     fprintf (stream, "\n");
+ }
+ 
+ 
  static inline char *
  skip_space (s)
       char * s;
*************** void
*** 202,210 ****
  md_show_usage (stream)
    FILE *stream;
  {
!   fprintf
!     (stream,
!      _ ("AVR options:\n"
  	"  -mmcu=[avr-name] select microcontroller variant\n"
  	"                   [avr-name] can be:\n"
  	"                   avr1 - AT90S1200, ATtiny1x, ATtiny28\n"
--- 246,253 ----
  md_show_usage (stream)
    FILE *stream;
  {
!   fprintf (stream,
!       _("AVR options:\n"
  	"  -mmcu=[avr-name] select microcontroller variant\n"
  	"                   [avr-name] can be:\n"
  	"                   avr1 - AT90S1200, ATtiny1x, ATtiny28\n"
*************** md_show_usage (stream)
*** 213,218 ****
--- 256,268 ----
  	"                   avr4 - ATmega83, ATmega85\n"
  	"                   avr5 - ATmega161, ATmega163, ATmega32, AT94K\n"
  	"                   or immediate microcontroller name.\n"));
+   fprintf (stream,
+       _("  -mall-opcodes    accept all AVR opcodes, even if not supported by MCU\n"
+ 	"  -mno-skip-bug    disable warnings for skipping two-word instructions\n"
+ 	"                   (default for avr4, avr5)\n"
+ 	"  -mno-wrap        reject rjmp/rcall instructions with 8K wrap-around\n"
+ 	"                   (default for avr3, avr5)\n"));
+   show_mcu_list (stream);
  }
  
  static void
*************** avr_set_arch (dummy)
*** 222,228 ****
    char * str;
    str = (char *)alloca (20);
    input_line_pointer = extract_word (input_line_pointer, str, 20);
!   md_parse_option ('m', str);
    bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach);
  }
  
--- 272,278 ----
    char * str;
    str = (char *)alloca (20);
    input_line_pointer = extract_word (input_line_pointer, str, 20);
!   md_parse_option (OPTION_MMCU, str);
    bfd_set_arch_mach (stdoutput, TARGET_ARCH, avr_mcu->mach);
  }
  
*************** md_parse_option (c, arg)
*** 231,263 ****
       int c;
       char *arg;
  {
!   char *t = alloca (strlen (arg) + 1);
!   char *s = t;
!   char *arg1 = arg;
!   do
!     *t = tolower (*arg1++);
!   while (*t++);
! 
!   if (c == 'm')
      {
!       int i;
  
!       for (i = 0; mcu_types[i].name; ++i)
! 	if (strcmp (mcu_types[i].name, s) == 0)
! 	  break;
  
!       if (!mcu_types[i].name)
! 	as_fatal (_ ("unknown MCU: %s\n"), arg);
  
!       /* It is OK to redefine mcu type within the same avr[1-5] bfd machine
! 	 type - this for allows passing -mmcu=... via gcc ASM_SPEC as well
! 	 as .arch ... in the asm output at the same time.  */
  
!       if (avr_mcu == &default_mcu || avr_mcu->mach == mcu_types[i].mach)
! 	avr_mcu = &mcu_types[i];
!       else
! 	as_fatal (_ ("redefinition of mcu type `%s' to `%s'"),
! 		  avr_mcu->name, mcu_types[i].name);
        return 1;
      }
    return 0;
--- 281,331 ----
       int c;
       char *arg;
  {
!   switch (c)
      {
!     case OPTION_MMCU:
!       {
! 	int i;
! 	char *s = alloca (strlen (arg) + 1);
  
! 	{
! 	  char *t = s;
! 	  char *arg1 = arg;
  
! 	  do
! 	    *t = tolower(*arg1++);
! 	  while (*t++);
! 	}
  
! 	for (i = 0; mcu_types[i].name; ++i)
! 	  if (strcmp (mcu_types[i].name, s) == 0)
! 	    break;
  
! 	if (!mcu_types[i].name)
! 	  {
! 	    show_mcu_list (stderr);
! 	    as_fatal (_("unknown MCU: %s\n"), arg);
! 	  }
! 
! 	/* It is OK to redefine mcu type within the same avr[1-5] bfd machine
! 	   type - this for allows passing -mmcu=... via gcc ASM_SPEC as well
! 	   as .arch ... in the asm output at the same time.  */
! 
! 	if (avr_mcu == &default_mcu || avr_mcu->mach == mcu_types[i].mach)
! 	  avr_mcu = &mcu_types[i];
! 	else
! 	  as_fatal (_("redefinition of mcu type `%s' to `%s'"),
! 		    avr_mcu->name, mcu_types[i].name);
! 	return 1;
!       }
!     case OPTION_ALL_OPCODES:
!       avr_opt.all_opcodes = 1;
!       return 1;
!     case OPTION_NO_SKIP_BUG:
!       avr_opt.no_skip_bug = 1;
!       return 1;
!     case OPTION_NO_WRAP:
!       avr_opt.no_wrap = 1;
        return 1;
      }
    return 0;
*************** avr_operands (opcode, line)
*** 413,419 ****
  
  	      str = skip_space (str);
  	      if (*str++ != ',')
! 		as_bad (_ ("`,' required"));
  	      str = skip_space (str);
  
  	      reg2 = avr_operand (opcode, where, op, &str);
--- 481,487 ----
  
  	      str = skip_space (str);
  	      if (*str++ != ',')
! 		as_bad (_("`,' required"));
  	      str = skip_space (str);
  
  	      reg2 = avr_operand (opcode, where, op, &str);
*************** avr_operands (opcode, line)
*** 429,450 ****
        bin |= reg1 | reg2;
      }
  
!   /* detect undefined combinations (like lpm r31,Z+) */
!     if (((bin & 0xFDEF) == 0x91AD) || ((bin & 0xFDEF) == 0x91AE) ||
! 	((bin & 0xFDEF) == 0x91C9) || ((bin & 0xFDEF) == 0x91CA) ||
! 	((bin & 0xFDEF) == 0x91E1) || ((bin & 0xFDEF) == 0x91E2) ||
! 	((bin & 0xFFED) == 0x91E5))
!       as_warn( _("undefined combination of operands"));
!     
    if (opcode->insn_size == 2)
      {
!       /* warn if previous opcode was cpse/sbic/sbis/sbrc/sbrs
! 	 (AVR core bug)  */
!       if ((prev & 0xFC00) == 0x1000
! 	  || (prev & 0xFD00) == 0x9900
! 	  || (prev & 0xFC08) == 0xFC00)
! 	as_warn (_("skipping two-word instruction"));
!       
        bfd_putl32 ((bfd_vma)bin, frag);
      }
    else
--- 497,525 ----
        bin |= reg1 | reg2;
      }
  
!   if (!avr_opt.all_opcodes)
!     {
!       /* Detect undefined combinations (like ld r31,Z+).  */
!       if (((bin & 0xFDEF) == 0x91AD) || ((bin & 0xFDEF) == 0x91AE) ||
! 	  ((bin & 0xFDEF) == 0x91C9) || ((bin & 0xFDEF) == 0x91CA) ||
! 	  ((bin & 0xFDEF) == 0x91E1) || ((bin & 0xFDEF) == 0x91E2) ||
! 	  ((bin & 0xFFED) == 0x91E5))
! 	as_warn (_("undefined combination of operands"));
!     }
! 
    if (opcode->insn_size == 2)
      {
!       /* Warn if the previous opcode was cpse/sbic/sbis/sbrc/sbrs
!          (AVR core bug, fixed in the newer devices).  */
! 
!       if (!((avr_mcu->isa & AVR_ISA_MUL) || avr_opt.no_skip_bug))
! 	{
! 	  if ((prev & 0xFC00) == 0x1000
! 	      || (prev & 0xFD00) == 0x9900
! 	      || (prev & 0xFC08) == 0xFC00)
! 	    as_warn (_("skipping two-word instruction"));
! 	}
! 
        bfd_putl32 ((bfd_vma)bin, frag);
      }
    else
*************** avr_operand (opcode, where, op, line)
*** 508,539 ****
  	      {
  	      case 'a':
  		if (op_mask < 16 || op_mask > 23)
! 		  as_bad (_ ("register r16-r23 required"));
  		op_mask -= 16;
  		break;
  
  	      case 'd':
  		if (op_mask < 16)
! 		  as_bad (_ ("register number above 15 required"));
  		op_mask -= 16;
  		break;
  		
  	      case 'v':
  		if (op_mask & 1)
! 		  as_bad (_ ("even register number required"));
  		op_mask >>= 1;
  		break;
  		
  	      case 'w':
  		op_mask -= 24;
  		if (op_mask & 1 || op_mask > 6)
! 		  as_bad (_ ("register r24,r26,r28 or r30 required"));
  		op_mask >>= 1;
  		break;
  	      }
  	    break;
  	  }
! 	as_bad (_ ("register name or number from 0 to 31 required"));
        }
        break;
  
--- 583,614 ----
  	      {
  	      case 'a':
  		if (op_mask < 16 || op_mask > 23)
! 		  as_bad (_("register r16-r23 required"));
  		op_mask -= 16;
  		break;
  
  	      case 'd':
  		if (op_mask < 16)
! 		  as_bad (_("register number above 15 required"));
  		op_mask -= 16;
  		break;
  		
  	      case 'v':
  		if (op_mask & 1)
! 		  as_bad (_("even register number required"));
  		op_mask >>= 1;
  		break;
  		
  	      case 'w':
  		op_mask -= 24;
  		if (op_mask & 1 || op_mask > 6)
! 		  as_bad (_("register r24, r26, r28 or r30 required"));
  		op_mask >>= 1;
  		break;
  	      }
  	    break;
  	  }
! 	as_bad (_("register name or number from 0 to 31 required"));
        }
        break;
  
*************** avr_operand (opcode, where, op, line)
*** 551,582 ****
  	else if (c == 'y')
  	  op_mask |= 0x8;
  	else if (c != 'z')
! 	  as_bad (_ ("pointer register (X,Y or Z) required"));
  
  	str = skip_space (str+1);
  	if (*str == '+')
  	  {
  	    ++str;
  	    if (op_mask & 2)
! 	      as_bad (_ ("cannot both predecrement and postincrement"));
  	    op_mask |= 0x1001;
  	  }
  
  	/* avr1 can do "ld r,Z" and "st Z,r" but no other pointer
  	   registers, no predecrement, no postincrement.  */
  	
! 	if ((op_mask & 0x100F) && !(avr_mcu->isa & AVR_ISA_SRAM))
! 	  as_bad (_ ("addressing mode not supported"));
        }
        break;
  
      case 'z':
        {
  	if (*str == '-')
! 	  as_bad (_ ("can't predecrement"));
  
  	if (! (*str == 'z' || *str == 'Z'))
! 	  as_bad (_ ("pointer register Z required"));
  
  	str = skip_space (str + 1);
  	if (*str == '+')
--- 626,658 ----
  	else if (c == 'y')
  	  op_mask |= 0x8;
  	else if (c != 'z')
! 	  as_bad (_("pointer register (X, Y or Z) required"));
  
  	str = skip_space (str+1);
  	if (*str == '+')
  	  {
  	    ++str;
  	    if (op_mask & 2)
! 	      as_bad (_("cannot both predecrement and postincrement"));
  	    op_mask |= 0x1001;
  	  }
  
  	/* avr1 can do "ld r,Z" and "st Z,r" but no other pointer
  	   registers, no predecrement, no postincrement.  */
  	
! 	if (!avr_opt.all_opcodes && (op_mask & 0x100F)
! 	    && !(avr_mcu->isa & AVR_ISA_SRAM))
! 	  as_bad (_("addressing mode not supported"));
        }
        break;
  
      case 'z':
        {
  	if (*str == '-')
! 	  as_bad (_("can't predecrement"));
  
  	if (! (*str == 'z' || *str == 'Z'))
! 	  as_bad (_("pointer register Z required"));
  
  	str = skip_space (str + 1);
  	if (*str == '+')
*************** avr_operand (opcode, where, op, line)
*** 593,599 ****
  	if (c == 'y')
  	  op_mask |= 0x8;
  	else if (c != 'z')
! 	  as_bad (_ ("pointer register (Y or Z) required"));
  	str = skip_space (str);
  	if (*str++ == '+')
  	  {
--- 669,675 ----
  	if (c == 'y')
  	  op_mask |= 0x8;
  	else if (c != 'z')
! 	  as_bad (_("pointer register (Y or Z) required"));
  	str = skip_space (str);
  	if (*str++ == '+')
  	  {
*************** avr_operand (opcode, where, op, line)
*** 702,708 ****
      case '?':
        break;
      default:
!       as_bad (_ ("unknown constraint `%c'"), *op);
      }
    *line = str;
    return op_mask;
--- 778,784 ----
      case '?':
        break;
      default:
!       as_bad (_("unknown constraint `%c'"), *op);
      }
    *line = str;
    return op_mask;
*************** md_apply_fix3 (fixp, valuep, seg)
*** 778,784 ****
  	    {
  	      /* We don't actually support subtracting a symbol.  */
   	      as_bad_where (fixp->fx_file, fixp->fx_line,
! 			    _ ("expression too complex"));
  	    }
  	}
      }
--- 854,860 ----
  	    {
  	      /* We don't actually support subtracting a symbol.  */
   	      as_bad_where (fixp->fx_file, fixp->fx_line,
! 			    _("expression too complex"));
  	    }
  	}
      }
*************** md_apply_fix3 (fixp, valuep, seg)
*** 829,835 ****
  	  if (value < -2048 || value > 2047)
  	    {
  	      /* No wrap for devices with >8K of program memory.  */
! 	      if (avr_mcu->isa & AVR_ISA_MEGA)
  		as_bad_where (fixp->fx_file, fixp->fx_line,
  			      _("operand out of range: %ld"), value);
  	    }
--- 905,911 ----
  	  if (value < -2048 || value > 2047)
  	    {
  	      /* No wrap for devices with >8K of program memory.  */
! 	      if ((avr_mcu->isa & AVR_ISA_MEGA) || avr_opt.no_wrap)
  		as_bad_where (fixp->fx_file, fixp->fx_line,
  			      _("operand out of range: %ld"), value);
  	    }
*************** md_assemble (str)
*** 1007,1019 ****
    str = skip_space (extract_word (str, op, sizeof(op)));
  
    if (!op[0])
!     as_bad (_ ("can't find opcode "));
  
    opcode = (struct avr_opcodes_s *) hash_find (avr_hash, op);
  
    if (opcode == NULL)
      {
!       as_bad (_ ("unknown opcode `%s'"), op);
        return;
      }
  
--- 1083,1095 ----
    str = skip_space (extract_word (str, op, sizeof(op)));
  
    if (!op[0])
!     as_bad (_("can't find opcode "));
  
    opcode = (struct avr_opcodes_s *) hash_find (avr_hash, op);
  
    if (opcode == NULL)
      {
!       as_bad (_("unknown opcode `%s'"), op);
        return;
      }
  
*************** md_assemble (str)
*** 1023,1030 ****
    if (*str && *opcode->constraints == '?')
      ++opcode;
  
!   if ((opcode->isa & avr_mcu->isa) != opcode->isa)
!     as_bad (_ ("illegal opcode %s for mcu %s"), opcode->name, avr_mcu->name);
  
    /* We used to set input_line_pointer to the result of get_operands,
       but that is wrong.  Our caller assumes we don't change it.  */
--- 1099,1106 ----
    if (*str && *opcode->constraints == '?')
      ++opcode;
  
!   if (!avr_opt.all_opcodes && (opcode->isa & avr_mcu->isa) != opcode->isa)
!     as_bad (_("illegal opcode %s for mcu %s"), opcode->name, avr_mcu->name);
  
    /* We used to set input_line_pointer to the result of get_operands,
       but that is wrong.  Our caller assumes we don't change it.  */
*************** md_assemble (str)
*** 1032,1038 ****
      char *t = input_line_pointer;
      avr_operands (opcode, &str);
      if (*skip_space (str))
!       as_bad (_ ("garbage at end of line"));
      input_line_pointer = t;
    }
  }
--- 1108,1114 ----
      char *t = input_line_pointer;
      avr_operands (opcode, &str);
      if (*skip_space (str))
!       as_bad (_("garbage at end of line"));
      input_line_pointer = t;
    }
  }
*************** avr_ldi_expression (exp)
*** 1090,1096 ****
  		      ++closes;
  		    }
  		  else
! 		    as_bad (_ ("illegal expression"));
  		  if (*str == '-')
  		    {
  		      neg_p = 1;
--- 1166,1172 ----
  		      ++closes;
  		    }
  		  else
! 		    as_bad (_("illegal expression"));
  		  if (*str == '-')
  		    {
  		      neg_p = 1;
*************** avr_ldi_expression (exp)
*** 1112,1118 ****
  		{
  		  if (*input_line_pointer != ')')
  		    {
! 		      as_bad (_ ("`)' required"));
  		      break;
  		    }
  		  input_line_pointer++;
--- 1188,1194 ----
  		{
  		  if (*input_line_pointer != ')')
  		    {
! 		      as_bad (_("`)' required"));
  		      break;
  		    }
  		  input_line_pointer++;
*************** avr_ldi_expression (exp)
*** 1124,1129 ****
--- 1200,1216 ----
      }
    input_line_pointer = tmp;
    expression (exp);
+ 
+   /* Warn about expressions that fail to use lo8().  */
+   if (exp->X_op == O_constant)
+     {
+       int x = exp->X_add_number;
+       if (x < -255 || x > 255)
+ 	as_warn (_("constant out of 8-bit range: %d"), x);
+     }
+   else
+     as_warn (_("expression possibly out of 8-bit range"));
+ 
    return BFD_RELOC_AVR_LO8_LDI;
  }
  
*************** avr_parse_cons_expression (exp, nbytes)
*** 1161,1167 ****
  		++input_line_pointer;
  	      else
  		{
! 		  as_bad (_ ("`)' required"));
  		  exp_mod_pm = 0;
  		}
  	      return;
--- 1248,1254 ----
  		++input_line_pointer;
  	      else
  		{
! 		  as_bad (_("`)' required"));
  		  exp_mod_pm = 0;
  		}
  	      return;
*************** avr_cons_fix_new(frag, where, nbytes, ex
*** 1186,1199 ****
        else if (nbytes == 4)
  	fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_32);
        else
! 	as_bad (_ ("illegal %srelocation size: %d"), "", nbytes);
      }
    else
      {
        if (nbytes == 2)
  	fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_AVR_16_PM);
        else
! 	as_bad (_ ("illegal %srelocation size: %d"), "`pm' ", nbytes);
        exp_mod_pm = 0;
      }
  }
--- 1273,1286 ----
        else if (nbytes == 4)
  	fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_32);
        else
! 	as_bad (_("illegal %srelocation size: %d"), "", nbytes);
      }
    else
      {
        if (nbytes == 2)
  	fix_new_exp (frag, where, nbytes, exp, false, BFD_RELOC_AVR_16_PM);
        else
! 	as_bad (_("illegal %srelocation size: %d"), "`pm' ", nbytes);
        exp_mod_pm = 0;
      }
  }
diff -Nrc3p orig/src/gas/config/tc-avr.h src/gas/config/tc-avr.h
*** orig/src/gas/config/tc-avr.h	Mon Mar 27 10:39:13 2000
--- src/gas/config/tc-avr.h	Mon Jul  3 15:35:46 2000
*************** void avr_cons_fix_new(fragS *frag,int wh
*** 108,113 ****
--- 108,115 ----
       of a PC relative instruction is the next instruction, so this
       macro would return the length of an instruction. */
  
+ extern long md_pcrel_from_section PARAMS ((struct fix *, segT));
+ 
  #define LISTING_WORD_SIZE 2
  /*   The number of bytes to put into a word in a listing.  This affects
       the way the bytes are clumped together in the listing.  For
diff -Nrc3p orig/src/opcodes/avr-dis.c src/opcodes/avr-dis.c
*** orig/src/opcodes/avr-dis.c	Mon Jun 12 07:44:51 2000
--- src/opcodes/avr-dis.c	Mon Jul  3 13:40:59 2000
*************** avr_operand (insn, insn2, pc, constraint
*** 103,109 ****
  	case 0: *buf++ = 'Z'; break;
  	case 2: *buf++ = 'Y'; break;
  	case 3: *buf++ = 'X'; break;
! 	default: buf += sprintf (buf, _ (" unknown register ")); break;
  	}
        if (insn & 0x1)
  	*buf++ = '+';
--- 103,109 ----
  	case 0: *buf++ = 'Z'; break;
  	case 2: *buf++ = 'Y'; break;
  	case 3: *buf++ = 'X'; break;
! 	default: buf += sprintf (buf, _(" unknown register ")); break;
  	}
        if (insn & 0x1)
  	*buf++ = '+';
*************** avr_operand (insn, insn2, pc, constraint
*** 165,171 ****
        break;
  
      case 'n':
!       sprintf (buf, _ ("Internal disassembler error"));
        break;
        
      case 'K':
--- 165,171 ----
        break;
  
      case 'n':
!       sprintf (buf, _("Internal disassembler error"));
        break;
        
      case 'K':
*************** avr_operand (insn, insn2, pc, constraint
*** 205,211 ****
        break;
        
      default:
!       sprintf (buf, _ ("unknown constraint `%c'"), constraint);
      }
  }
  
--- 205,211 ----
        break;
        
      default:
!       sprintf (buf, _("unknown constraint `%c'"), constraint);
      }
  }
  
*************** print_insn_avr(addr, info)
*** 280,285 ****
--- 280,286 ----
        op2[0] = 0;
        comment1[0] = 0;
        comment2[0] = 0;
+       insn2 = 0;
  
        if (opcode->insn_size > 1)
  	{



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