/* tc-mcore.c -- Assemble code for M*Core
-   Copyright (C) 1999 Free Software Foundation.
+   Copyright (C) 1999, 2000 Free Software Foundation.
 
    This file is part of GAS, the GNU Assembler.
 
        ++ op_end;
   
       if (* op_end == ',')
-       /* parse_rt calls frag_more() for us.  */
-       input_line_pointer = parse_rt (op_end + 1, & output, 0, 0);
+       {
+         /* parse_rt calls frag_more() for us.  */
+         input_line_pointer = parse_rt (op_end + 1, & output, 0, 0);
+          op_end = input_line_pointer;
+       }
       else
        {
          as_bad (_("second operand missing"));
     case LJ:
       input_line_pointer = parse_rt (op_end + 1, & output, 1, 0);
       /* parse_rt() calls frag_more() for us.  */
+      op_end = input_line_pointer;
       break;
       
     case RM:
       
     case BR:
       input_line_pointer = parse_exp (op_end + 1, & e);
+      op_end = input_line_pointer;
       
       output = frag_more (2);
       
       
     case JC:
       input_line_pointer = parse_exp (op_end + 1, & e);
+      op_end = input_line_pointer;
       
       output = frag_var (rs_machine_dependent,
                         md_relax_table[C (COND_JUMP, COND32)].rlx_length,
       
     case JU:
       input_line_pointer = parse_exp (op_end + 1, & e);
+      op_end = input_line_pointer;
+
       output = frag_var (rs_machine_dependent,
                         md_relax_table[C (UNCD_JUMP, UNCD32)].rlx_length,
                         md_relax_table[C (UNCD_JUMP, UNCD12)].rlx_length,
       inst = MCORE_INST_JSRI;          /* jsri */
       input_line_pointer = parse_rt (op_end + 1, & output, 1, & e);
       /* parse_rt() calls frag_more for us.  */
+      op_end = input_line_pointer;
       
       /* Only do this if we know how to do it ... */
       if (e.X_op != O_absent && do_jsri2bsr)
     default:
       as_bad (_("unimplemented opcode \"%s\""), name);
     }
+
+  /* Drop whitespace after all the operands have been parsed.  */
+  while (isspace (* op_end))
+    op_end ++;
+
+  /* Give warning message if the insn has more operands than required. */
+  if (strcmp (op_end, opcode->name) && strcmp (op_end, ""))
+    as_warn (_("ignoring operands: %s "), op_end);
   
   output[0] = INST_BYTE0 (inst);
   output[1] = INST_BYTE1 (inst);
        as_bad_where (file, fixP->fx_line,
                      _("pcrel for branch to %s too far (0x%x)"),
                      symname, val);
-        buf[0] |= ((val >> 8) & 0x7);
-        buf[1] |= (val & 0xff);
+         buf[0] |= ((val >> 8) & 0x7);
+         buf[1] |= (val & 0xff);
       break;
 
     case BFD_RELOC_MCORE_PCREL_IMM8BY4:        /* lower 8 bits of 2 byte opcode */
        as_bad_where (file, fixP->fx_line,
                      _("pcrel for loopt too far (0x%x)"), val);
       val /= 2;
-        buf[1] |= (val & 0xf);
+       buf[1] |= (val & 0xf);
       break;
 
     case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2:
 {
   if (   fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT
       || fix->fx_r_type == BFD_RELOC_VTABLE_ENTRY
-      || fixP->fx_r_type == BFD_RELOC_RVA)
+      || fix->fx_r_type == BFD_RELOC_RVA)
     return 1;
 
   return 0;