1 /* tc-mn10300.c -- Assembler code for the Matsushita 10300
2 Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
25 #include "opcode/mn10300.h"
26 #include "dwarf2dbg.h"
28 /* Structure to hold information about predefined registers. */
35 struct dwarf2_line_info debug_line
;
37 /* Generic assembler global variables which must be defined by all
40 /* Characters which always start a comment. */
41 const char comment_chars
[] = "#";
43 /* Characters which start a comment at the beginning of a line. */
44 const char line_comment_chars
[] = ";#";
46 /* Characters which may be used to separate multiple commands on a
48 const char line_separator_chars
[] = ";";
50 /* Characters which are used to indicate an exponent in a floating
52 const char EXP_CHARS
[] = "eE";
54 /* Characters which mean that a number is a floating point constant,
56 const char FLT_CHARS
[] = "dD";
58 const relax_typeS md_relax_table
[] = {
61 {0x7fff, -0x8000, 5, 2},
62 {0x7fffffff, -0x80000000, 7, 0},
64 /* bCC relaxing (uncommon cases) */
66 {0x7fff, -0x8000, 6, 5},
67 {0x7fffffff, -0x80000000, 8, 0},
70 {0x7fff, -0x8000, 5, 7},
71 {0x7fffffff, -0x80000000, 7, 0},
74 {0x7fff, -0x8000, 4, 9},
75 {0x7fffffff, -0x80000000, 6, 0},
79 {0x7fff, -0x8000, 3, 12},
80 {0x7fffffff, -0x80000000, 5, 0},
84 /* Local functions. */
85 static void mn10300_insert_operand
PARAMS ((unsigned long *, unsigned long *,
86 const struct mn10300_operand
*,
87 offsetT
, char *, unsigned,
89 static unsigned long check_operand
PARAMS ((unsigned long,
90 const struct mn10300_operand
*,
92 static int reg_name_search
PARAMS ((const struct reg_name
*, int, const char *));
93 static boolean data_register_name
PARAMS ((expressionS
*expressionP
));
94 static boolean address_register_name
PARAMS ((expressionS
*expressionP
));
95 static boolean other_register_name
PARAMS ((expressionS
*expressionP
));
96 static void set_arch_mach
PARAMS ((int));
98 /* Set linkrelax here to avoid fixups in most sections. */
101 static int current_machine
;
104 #define MAX_INSN_FIXUPS (5)
109 bfd_reloc_code_real_type reloc
;
111 struct mn10300_fixup fixups
[MAX_INSN_FIXUPS
];
114 /* We must store the value of each register operand so that we can
115 verify that certain registers do not match. */
116 int mn10300_reg_operands
[MN10300_MAX_OPERANDS
];
118 const char *md_shortopts
= "";
119 struct option md_longopts
[] = {
120 {NULL
, no_argument
, NULL
, 0}
122 size_t md_longopts_size
= sizeof (md_longopts
);
124 /* The target specific pseudo-ops which we support. */
125 const pseudo_typeS md_pseudo_table
[] =
127 { "file", dwarf2_directive_file
, 0 },
128 { "loc", dwarf2_directive_loc
, 0 },
129 { "am30", set_arch_mach
, AM30
},
130 { "am33", set_arch_mach
, AM33
},
131 { "mn10300", set_arch_mach
, MN103
},
135 #define HAVE_AM33 (current_machine == AM33)
136 #define HAVE_AM30 (current_machine == AM30)
138 /* Opcode hash table. */
139 static struct hash_control
*mn10300_hash
;
141 /* This table is sorted. Suitable for searching by a binary search. */
142 static const struct reg_name data_registers
[] =
149 #define DATA_REG_NAME_CNT \
150 (sizeof (data_registers) / sizeof (struct reg_name))
152 static const struct reg_name address_registers
[] =
160 #define ADDRESS_REG_NAME_CNT \
161 (sizeof (address_registers) / sizeof (struct reg_name))
163 static const struct reg_name r_registers
[] =
207 #define R_REG_NAME_CNT \
208 (sizeof (r_registers) / sizeof (struct reg_name))
210 static const struct reg_name xr_registers
[] =
235 #define XR_REG_NAME_CNT \
236 (sizeof (xr_registers) / sizeof (struct reg_name))
238 static const struct reg_name other_registers
[] =
245 #define OTHER_REG_NAME_CNT \
246 (sizeof (other_registers) / sizeof (struct reg_name))
248 /* reg_name_search does a binary search of the given register table
249 to see if "name" is a valid regiter name. Returns the register
250 number from the array on success, or -1 on failure. */
253 reg_name_search (regs
, regcount
, name
)
254 const struct reg_name
*regs
;
258 int middle
, low
, high
;
266 middle
= (low
+ high
) / 2;
267 cmp
= strcasecmp (name
, regs
[middle
].name
);
273 return regs
[middle
].value
;
279 /* Summary of register_name().
281 * in: Input_line_pointer points to 1st char of operand.
283 * out: A expressionS.
284 * The operand may have been a register: in this case, X_op == O_register,
285 * X_add_number is set to the register number, and truth is returned.
286 * Input_line_pointer->(next non-blank) char after operand, or is in
287 * its original state.
291 r_register_name (expressionP
)
292 expressionS
*expressionP
;
299 /* Find the spelling of the operand. */
300 start
= name
= input_line_pointer
;
302 c
= get_symbol_end ();
303 reg_number
= reg_name_search (r_registers
, R_REG_NAME_CNT
, name
);
305 /* Look to see if it's in the register table. */
308 expressionP
->X_op
= O_register
;
309 expressionP
->X_add_number
= reg_number
;
311 /* Make the rest nice. */
312 expressionP
->X_add_symbol
= NULL
;
313 expressionP
->X_op_symbol
= NULL
;
315 /* Put back the delimiting char. */
316 *input_line_pointer
= c
;
321 /* Reset the line as if we had not done anything. */
322 /* Put back the delimiting char. */
323 *input_line_pointer
= c
;
325 /* Reset input_line pointer. */
326 input_line_pointer
= start
;
331 /* Summary of register_name().
333 * in: Input_line_pointer points to 1st char of operand.
335 * out: A expressionS.
336 * The operand may have been a register: in this case, X_op == O_register,
337 * X_add_number is set to the register number, and truth is returned.
338 * Input_line_pointer->(next non-blank) char after operand, or is in
339 * its original state.
343 xr_register_name (expressionP
)
344 expressionS
*expressionP
;
351 /* Find the spelling of the operand. */
352 start
= name
= input_line_pointer
;
354 c
= get_symbol_end ();
355 reg_number
= reg_name_search (xr_registers
, XR_REG_NAME_CNT
, name
);
357 /* Look to see if it's in the register table. */
360 expressionP
->X_op
= O_register
;
361 expressionP
->X_add_number
= reg_number
;
363 /* Make the rest nice. */
364 expressionP
->X_add_symbol
= NULL
;
365 expressionP
->X_op_symbol
= NULL
;
367 /* Put back the delimiting char. */
368 *input_line_pointer
= c
;
373 /* Reset the line as if we had not done anything. */
374 /* Put back the delimiting char. */
375 *input_line_pointer
= c
;
377 /* Reset input_line pointer. */
378 input_line_pointer
= start
;
383 /* Summary of register_name().
385 * in: Input_line_pointer points to 1st char of operand.
387 * out: A expressionS.
388 * The operand may have been a register: in this case, X_op == O_register,
389 * X_add_number is set to the register number, and truth is returned.
390 * Input_line_pointer->(next non-blank) char after operand, or is in
391 * its original state.
395 data_register_name (expressionP
)
396 expressionS
*expressionP
;
403 /* Find the spelling of the operand. */
404 start
= name
= input_line_pointer
;
406 c
= get_symbol_end ();
407 reg_number
= reg_name_search (data_registers
, DATA_REG_NAME_CNT
, name
);
409 /* Look to see if it's in the register table. */
412 expressionP
->X_op
= O_register
;
413 expressionP
->X_add_number
= reg_number
;
415 /* Make the rest nice. */
416 expressionP
->X_add_symbol
= NULL
;
417 expressionP
->X_op_symbol
= NULL
;
419 /* Put back the delimiting char. */
420 *input_line_pointer
= c
;
425 /* Reset the line as if we had not done anything. */
426 /* Put back the delimiting char. */
427 *input_line_pointer
= c
;
429 /* Reset input_line pointer. */
430 input_line_pointer
= start
;
435 /* Summary of register_name().
437 * in: Input_line_pointer points to 1st char of operand.
439 * out: A expressionS.
440 * The operand may have been a register: in this case, X_op == O_register,
441 * X_add_number is set to the register number, and truth is returned.
442 * Input_line_pointer->(next non-blank) char after operand, or is in
443 * its original state.
447 address_register_name (expressionP
)
448 expressionS
*expressionP
;
455 /* Find the spelling of the operand. */
456 start
= name
= input_line_pointer
;
458 c
= get_symbol_end ();
459 reg_number
= reg_name_search (address_registers
, ADDRESS_REG_NAME_CNT
, name
);
461 /* Look to see if it's in the register table. */
464 expressionP
->X_op
= O_register
;
465 expressionP
->X_add_number
= reg_number
;
467 /* Make the rest nice. */
468 expressionP
->X_add_symbol
= NULL
;
469 expressionP
->X_op_symbol
= NULL
;
471 /* Put back the delimiting char. */
472 *input_line_pointer
= c
;
477 /* Reset the line as if we had not done anything. */
478 /* Put back the delimiting char. */
479 *input_line_pointer
= c
;
481 /* Reset input_line pointer. */
482 input_line_pointer
= start
;
488 /* Summary of register_name().
490 * in: Input_line_pointer points to 1st char of operand.
492 * out: A expressionS.
493 * The operand may have been a register: in this case, X_op == O_register,
494 * X_add_number is set to the register number, and truth is returned.
495 * Input_line_pointer->(next non-blank) char after operand, or is in
496 * its original state.
500 other_register_name (expressionP
)
501 expressionS
*expressionP
;
508 /* Find the spelling of the operand. */
509 start
= name
= input_line_pointer
;
511 c
= get_symbol_end ();
512 reg_number
= reg_name_search (other_registers
, OTHER_REG_NAME_CNT
, name
);
514 /* Look to see if it's in the register table. */
517 expressionP
->X_op
= O_register
;
518 expressionP
->X_add_number
= reg_number
;
520 /* Make the rest nice. */
521 expressionP
->X_add_symbol
= NULL
;
522 expressionP
->X_op_symbol
= NULL
;
524 /* Put back the delimiting char. */
525 *input_line_pointer
= c
;
530 /* Reset the line as if we had not done anything. */
531 /* Put back the delimiting char. */
532 *input_line_pointer
= c
;
534 /* Reset input_line pointer. */
535 input_line_pointer
= start
;
541 md_show_usage (stream
)
544 fprintf (stream
, _("MN10300 options:\n\
549 md_parse_option (c
, arg
)
550 int c ATTRIBUTE_UNUSED
;
551 char *arg ATTRIBUTE_UNUSED
;
557 md_undefined_symbol (name
)
558 char *name ATTRIBUTE_UNUSED
;
564 md_atof (type
, litp
, sizep
)
570 LITTLENUM_TYPE words
[4];
586 return "bad call to md_atof";
589 t
= atof_ieee (input_line_pointer
, type
, words
);
591 input_line_pointer
= t
;
595 for (i
= prec
- 1; i
>= 0; i
--)
597 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
605 md_convert_frag (abfd
, sec
, fragP
)
606 bfd
*abfd ATTRIBUTE_UNUSED
;
610 static unsigned long label_count
= 0;
613 subseg_change (sec
, 0);
614 if (fragP
->fr_subtype
== 0)
616 fix_new (fragP
, fragP
->fr_fix
+ 1, 1, fragP
->fr_symbol
,
617 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
621 else if (fragP
->fr_subtype
== 1)
623 /* Reverse the condition of the first branch. */
624 int offset
= fragP
->fr_fix
;
625 int opcode
= fragP
->fr_literal
[offset
] & 0xff;
662 fragP
->fr_literal
[offset
] = opcode
;
664 /* Create a fixup for the reversed conditional branch. */
665 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
666 fix_new (fragP
, fragP
->fr_fix
+ 1, 1,
667 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
668 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
670 /* Now create the unconditional branch + fixup to the
672 fragP
->fr_literal
[offset
+ 2] = 0xcc;
673 fix_new (fragP
, fragP
->fr_fix
+ 3, 2, fragP
->fr_symbol
,
674 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
678 else if (fragP
->fr_subtype
== 2)
680 /* Reverse the condition of the first branch. */
681 int offset
= fragP
->fr_fix
;
682 int opcode
= fragP
->fr_literal
[offset
] & 0xff;
719 fragP
->fr_literal
[offset
] = opcode
;
721 /* Create a fixup for the reversed conditional branch. */
722 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
723 fix_new (fragP
, fragP
->fr_fix
+ 1, 1,
724 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
725 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
727 /* Now create the unconditional branch + fixup to the
729 fragP
->fr_literal
[offset
+ 2] = 0xdc;
730 fix_new (fragP
, fragP
->fr_fix
+ 3, 4, fragP
->fr_symbol
,
731 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
735 else if (fragP
->fr_subtype
== 3)
737 fix_new (fragP
, fragP
->fr_fix
+ 2, 1, fragP
->fr_symbol
,
738 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
742 else if (fragP
->fr_subtype
== 4)
744 /* Reverse the condition of the first branch. */
745 int offset
= fragP
->fr_fix
;
746 int opcode
= fragP
->fr_literal
[offset
+ 1] & 0xff;
765 fragP
->fr_literal
[offset
+ 1] = opcode
;
767 /* Create a fixup for the reversed conditional branch. */
768 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
769 fix_new (fragP
, fragP
->fr_fix
+ 2, 1,
770 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
771 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
773 /* Now create the unconditional branch + fixup to the
775 fragP
->fr_literal
[offset
+ 3] = 0xcc;
776 fix_new (fragP
, fragP
->fr_fix
+ 4, 2, fragP
->fr_symbol
,
777 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
781 else if (fragP
->fr_subtype
== 5)
783 /* Reverse the condition of the first branch. */
784 int offset
= fragP
->fr_fix
;
785 int opcode
= fragP
->fr_literal
[offset
+ 1] & 0xff;
801 fragP
->fr_literal
[offset
+ 1] = opcode
;
803 /* Create a fixup for the reversed conditional branch. */
804 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
805 fix_new (fragP
, fragP
->fr_fix
+ 2, 1,
806 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
807 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
809 /* Now create the unconditional branch + fixup to the
811 fragP
->fr_literal
[offset
+ 3] = 0xdc;
812 fix_new (fragP
, fragP
->fr_fix
+ 4, 4, fragP
->fr_symbol
,
813 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
817 else if (fragP
->fr_subtype
== 6)
819 int offset
= fragP
->fr_fix
;
820 fragP
->fr_literal
[offset
] = 0xcd;
821 fix_new (fragP
, fragP
->fr_fix
+ 1, 2, fragP
->fr_symbol
,
822 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
826 else if (fragP
->fr_subtype
== 7)
828 int offset
= fragP
->fr_fix
;
829 fragP
->fr_literal
[offset
] = 0xdd;
830 fragP
->fr_literal
[offset
+ 5] = fragP
->fr_literal
[offset
+ 3];
831 fragP
->fr_literal
[offset
+ 6] = fragP
->fr_literal
[offset
+ 4];
833 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
834 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
838 else if (fragP
->fr_subtype
== 8)
840 int offset
= fragP
->fr_fix
;
841 fragP
->fr_literal
[offset
] = 0xfa;
842 fragP
->fr_literal
[offset
+ 1] = 0xff;
843 fix_new (fragP
, fragP
->fr_fix
+ 2, 2, fragP
->fr_symbol
,
844 fragP
->fr_offset
+ 2, 1, BFD_RELOC_16_PCREL
);
848 else if (fragP
->fr_subtype
== 9)
850 int offset
= fragP
->fr_fix
;
851 fragP
->fr_literal
[offset
] = 0xfc;
852 fragP
->fr_literal
[offset
+ 1] = 0xff;
854 fix_new (fragP
, fragP
->fr_fix
+ 2, 4, fragP
->fr_symbol
,
855 fragP
->fr_offset
+ 2, 1, BFD_RELOC_32_PCREL
);
859 else if (fragP
->fr_subtype
== 10)
861 fragP
->fr_literal
[fragP
->fr_fix
] = 0xca;
862 fix_new (fragP
, fragP
->fr_fix
+ 1, 1, fragP
->fr_symbol
,
863 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
867 else if (fragP
->fr_subtype
== 11)
869 int offset
= fragP
->fr_fix
;
870 fragP
->fr_literal
[offset
] = 0xcc;
872 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
873 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
877 else if (fragP
->fr_subtype
== 12)
879 int offset
= fragP
->fr_fix
;
880 fragP
->fr_literal
[offset
] = 0xdc;
882 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
883 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
892 md_section_align (seg
, addr
)
896 int align
= bfd_get_section_alignment (stdoutput
, seg
);
897 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
903 char *prev_name
= "";
904 register const struct mn10300_opcode
*op
;
906 mn10300_hash
= hash_new ();
908 /* Insert unique names into hash table. The MN10300 instruction set
909 has many identical opcode names that have different opcodes based
910 on the operands. This hash table then provides a quick index to
911 the first opcode with a particular name in the opcode table. */
913 op
= mn10300_opcodes
;
916 if (strcmp (prev_name
, op
->name
))
918 prev_name
= (char *) op
->name
;
919 hash_insert (mn10300_hash
, op
->name
, (char *) op
);
924 /* Set the default machine type. */
925 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_mn10300
, MN103
))
926 as_warn (_("could not set architecture and machine"));
928 current_machine
= MN103
;
936 struct mn10300_opcode
*opcode
;
937 struct mn10300_opcode
*next_opcode
;
938 const unsigned char *opindex_ptr
;
939 int next_opindex
, relaxable
;
940 unsigned long insn
, extension
, size
= 0, real_size
;
945 /* Get the opcode. */
946 for (s
= str
; *s
!= '\0' && !isspace (*s
); s
++)
951 /* Find the first opcode with the proper name. */
952 opcode
= (struct mn10300_opcode
*) hash_find (mn10300_hash
, str
);
955 as_bad (_("Unrecognized opcode: `%s'"), str
);
960 while (isspace (*str
))
963 input_line_pointer
= str
;
972 errmsg
= _("Invalid opcode/operands");
974 /* Reset the array of register operands. */
975 memset (mn10300_reg_operands
, -1, sizeof (mn10300_reg_operands
));
981 insn
= opcode
->opcode
;
984 /* If the instruction is not available on the current machine
985 then it can not possibly match. */
987 && !(opcode
->machine
== AM33
&& HAVE_AM33
)
988 && !(opcode
->machine
== AM30
&& HAVE_AM30
))
991 for (op_idx
= 1, opindex_ptr
= opcode
->operands
;
993 opindex_ptr
++, op_idx
++)
995 const struct mn10300_operand
*operand
;
998 if (next_opindex
== 0)
1000 operand
= &mn10300_operands
[*opindex_ptr
];
1004 operand
= &mn10300_operands
[next_opindex
];
1008 while (*str
== ' ' || *str
== ',')
1011 if (operand
->flags
& MN10300_OPERAND_RELAX
)
1014 /* Gather the operand. */
1015 hold
= input_line_pointer
;
1016 input_line_pointer
= str
;
1018 if (operand
->flags
& MN10300_OPERAND_PAREN
)
1020 if (*input_line_pointer
!= ')' && *input_line_pointer
!= '(')
1022 input_line_pointer
= hold
;
1026 input_line_pointer
++;
1029 /* See if we can match the operands. */
1030 else if (operand
->flags
& MN10300_OPERAND_DREG
)
1032 if (!data_register_name (&ex
))
1034 input_line_pointer
= hold
;
1039 else if (operand
->flags
& MN10300_OPERAND_AREG
)
1041 if (!address_register_name (&ex
))
1043 input_line_pointer
= hold
;
1048 else if (operand
->flags
& MN10300_OPERAND_SP
)
1050 char *start
= input_line_pointer
;
1051 char c
= get_symbol_end ();
1053 if (strcasecmp (start
, "sp") != 0)
1055 *input_line_pointer
= c
;
1056 input_line_pointer
= hold
;
1060 *input_line_pointer
= c
;
1063 else if (operand
->flags
& MN10300_OPERAND_RREG
)
1065 if (!r_register_name (&ex
))
1067 input_line_pointer
= hold
;
1072 else if (operand
->flags
& MN10300_OPERAND_XRREG
)
1074 if (!xr_register_name (&ex
))
1076 input_line_pointer
= hold
;
1081 else if (operand
->flags
& MN10300_OPERAND_USP
)
1083 char *start
= input_line_pointer
;
1084 char c
= get_symbol_end ();
1086 if (strcasecmp (start
, "usp") != 0)
1088 *input_line_pointer
= c
;
1089 input_line_pointer
= hold
;
1093 *input_line_pointer
= c
;
1096 else if (operand
->flags
& MN10300_OPERAND_SSP
)
1098 char *start
= input_line_pointer
;
1099 char c
= get_symbol_end ();
1101 if (strcasecmp (start
, "ssp") != 0)
1103 *input_line_pointer
= c
;
1104 input_line_pointer
= hold
;
1108 *input_line_pointer
= c
;
1111 else if (operand
->flags
& MN10300_OPERAND_MSP
)
1113 char *start
= input_line_pointer
;
1114 char c
= get_symbol_end ();
1116 if (strcasecmp (start
, "msp") != 0)
1118 *input_line_pointer
= c
;
1119 input_line_pointer
= hold
;
1123 *input_line_pointer
= c
;
1126 else if (operand
->flags
& MN10300_OPERAND_PC
)
1128 char *start
= input_line_pointer
;
1129 char c
= get_symbol_end ();
1131 if (strcasecmp (start
, "pc") != 0)
1133 *input_line_pointer
= c
;
1134 input_line_pointer
= hold
;
1138 *input_line_pointer
= c
;
1141 else if (operand
->flags
& MN10300_OPERAND_EPSW
)
1143 char *start
= input_line_pointer
;
1144 char c
= get_symbol_end ();
1146 if (strcasecmp (start
, "epsw") != 0)
1148 *input_line_pointer
= c
;
1149 input_line_pointer
= hold
;
1153 *input_line_pointer
= c
;
1156 else if (operand
->flags
& MN10300_OPERAND_PLUS
)
1158 if (*input_line_pointer
!= '+')
1160 input_line_pointer
= hold
;
1164 input_line_pointer
++;
1167 else if (operand
->flags
& MN10300_OPERAND_PSW
)
1169 char *start
= input_line_pointer
;
1170 char c
= get_symbol_end ();
1172 if (strcasecmp (start
, "psw") != 0)
1174 *input_line_pointer
= c
;
1175 input_line_pointer
= hold
;
1179 *input_line_pointer
= c
;
1182 else if (operand
->flags
& MN10300_OPERAND_MDR
)
1184 char *start
= input_line_pointer
;
1185 char c
= get_symbol_end ();
1187 if (strcasecmp (start
, "mdr") != 0)
1189 *input_line_pointer
= c
;
1190 input_line_pointer
= hold
;
1194 *input_line_pointer
= c
;
1197 else if (operand
->flags
& MN10300_OPERAND_REG_LIST
)
1199 unsigned int value
= 0;
1200 if (*input_line_pointer
!= '[')
1202 input_line_pointer
= hold
;
1208 input_line_pointer
++;
1210 /* We used to reject a null register list here; however,
1211 we accept it now so the compiler can emit "call"
1212 instructions for all calls to named functions.
1214 The linker can then fill in the appropriate bits for the
1215 register list and stack size or change the instruction
1216 into a "calls" if using "call" is not profitable. */
1217 while (*input_line_pointer
!= ']')
1222 if (*input_line_pointer
== ',')
1223 input_line_pointer
++;
1225 start
= input_line_pointer
;
1226 c
= get_symbol_end ();
1228 if (strcasecmp (start
, "d2") == 0)
1231 *input_line_pointer
= c
;
1233 else if (strcasecmp (start
, "d3") == 0)
1236 *input_line_pointer
= c
;
1238 else if (strcasecmp (start
, "a2") == 0)
1241 *input_line_pointer
= c
;
1243 else if (strcasecmp (start
, "a3") == 0)
1246 *input_line_pointer
= c
;
1248 else if (strcasecmp (start
, "other") == 0)
1251 *input_line_pointer
= c
;
1254 && strcasecmp (start
, "exreg0") == 0)
1257 *input_line_pointer
= c
;
1260 && strcasecmp (start
, "exreg1") == 0)
1263 *input_line_pointer
= c
;
1266 && strcasecmp (start
, "exother") == 0)
1269 *input_line_pointer
= c
;
1272 && strcasecmp (start
, "all") == 0)
1275 *input_line_pointer
= c
;
1279 input_line_pointer
= hold
;
1284 input_line_pointer
++;
1285 mn10300_insert_operand (&insn
, &extension
, operand
,
1286 value
, (char *) NULL
, 0, 0);
1290 else if (data_register_name (&ex
))
1292 input_line_pointer
= hold
;
1296 else if (address_register_name (&ex
))
1298 input_line_pointer
= hold
;
1302 else if (other_register_name (&ex
))
1304 input_line_pointer
= hold
;
1308 else if (HAVE_AM33
&& r_register_name (&ex
))
1310 input_line_pointer
= hold
;
1314 else if (HAVE_AM33
&& xr_register_name (&ex
))
1316 input_line_pointer
= hold
;
1320 else if (*str
== ')' || *str
== '(')
1322 input_line_pointer
= hold
;
1334 errmsg
= _("illegal operand");
1337 errmsg
= _("missing operand");
1343 mask
= MN10300_OPERAND_DREG
| MN10300_OPERAND_AREG
;
1345 mask
|= MN10300_OPERAND_RREG
| MN10300_OPERAND_XRREG
;
1346 if ((operand
->flags
& mask
) == 0)
1348 input_line_pointer
= hold
;
1353 if (opcode
->format
== FMT_D1
|| opcode
->format
== FMT_S1
)
1355 else if (opcode
->format
== FMT_D2
1356 || opcode
->format
== FMT_D4
1357 || opcode
->format
== FMT_S2
1358 || opcode
->format
== FMT_S4
1359 || opcode
->format
== FMT_S6
1360 || opcode
->format
== FMT_D5
)
1362 else if (opcode
->format
== FMT_D7
)
1364 else if (opcode
->format
== FMT_D8
|| opcode
->format
== FMT_D9
)
1369 mn10300_insert_operand (&insn
, &extension
, operand
,
1370 ex
.X_add_number
, (char *) NULL
,
1373 /* And note the register number in the register array. */
1374 mn10300_reg_operands
[op_idx
- 1] = ex
.X_add_number
;
1379 /* If this operand can be promoted, and it doesn't
1380 fit into the allocated bitfield for this insn,
1381 then promote it (ie this opcode does not match). */
1383 & (MN10300_OPERAND_PROMOTE
| MN10300_OPERAND_RELAX
)
1384 && !check_operand (insn
, operand
, ex
.X_add_number
))
1386 input_line_pointer
= hold
;
1391 mn10300_insert_operand (&insn
, &extension
, operand
,
1392 ex
.X_add_number
, (char *) NULL
,
1397 /* If this operand can be promoted, then this opcode didn't
1398 match since we can't know if it needed promotion! */
1399 if (operand
->flags
& MN10300_OPERAND_PROMOTE
)
1401 input_line_pointer
= hold
;
1406 /* We need to generate a fixup for this expression. */
1407 if (fc
>= MAX_INSN_FIXUPS
)
1408 as_fatal (_("too many fixups"));
1409 fixups
[fc
].exp
= ex
;
1410 fixups
[fc
].opindex
= *opindex_ptr
;
1411 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
1417 str
= input_line_pointer
;
1418 input_line_pointer
= hold
;
1420 while (*str
== ' ' || *str
== ',')
1425 /* Make sure we used all the operands! */
1429 /* If this instruction has registers that must not match, verify
1430 that they do indeed not match. */
1431 if (opcode
->no_match_operands
)
1435 /* Look at each operand to see if it's marked. */
1436 for (i
= 0; i
< MN10300_MAX_OPERANDS
; i
++)
1438 if ((1 << i
) & opcode
->no_match_operands
)
1442 /* operand I is marked. Check that it does not match any
1443 operands > I which are marked. */
1444 for (j
= i
+ 1; j
< MN10300_MAX_OPERANDS
; j
++)
1446 if (((1 << j
) & opcode
->no_match_operands
)
1447 && mn10300_reg_operands
[i
] == mn10300_reg_operands
[j
])
1449 errmsg
= _("Invalid register specification.");
1461 next_opcode
= opcode
+ 1;
1462 if (!strcmp (next_opcode
->name
, opcode
->name
))
1464 opcode
= next_opcode
;
1468 as_bad ("%s", errmsg
);
1474 while (isspace (*str
))
1478 as_bad (_("junk at end of line: `%s'"), str
);
1480 input_line_pointer
= str
;
1482 /* Determine the size of the instruction. */
1483 if (opcode
->format
== FMT_S0
)
1486 if (opcode
->format
== FMT_S1
|| opcode
->format
== FMT_D0
)
1489 if (opcode
->format
== FMT_S2
|| opcode
->format
== FMT_D1
)
1492 if (opcode
->format
== FMT_D6
)
1495 if (opcode
->format
== FMT_D7
|| opcode
->format
== FMT_D10
)
1498 if (opcode
->format
== FMT_D8
)
1501 if (opcode
->format
== FMT_D9
)
1504 if (opcode
->format
== FMT_S4
)
1507 if (opcode
->format
== FMT_S6
|| opcode
->format
== FMT_D5
)
1510 if (opcode
->format
== FMT_D2
)
1513 if (opcode
->format
== FMT_D4
)
1518 if (relaxable
&& fc
> 0)
1525 /* Handle bra specially. Basically treat it like jmp so
1526 that we automatically handle 8, 16 and 32 bit offsets
1527 correctly as well as jumps to an undefined address.
1529 It is also important to not treat it like other bCC
1530 instructions since the long forms of bra is different
1531 from other bCC instructions. */
1532 if (opcode
->opcode
== 0xca00)
1544 else if (size
== 3 && opcode
->opcode
== 0xcc0000)
1546 /* bCC (uncommon cases) */
1550 f
= frag_var (rs_machine_dependent
, 8, 8 - size
, type
,
1551 fixups
[0].exp
.X_add_symbol
,
1552 fixups
[0].exp
.X_add_number
,
1553 (char *)fixups
[0].opindex
);
1555 /* This is pretty hokey. We basically just care about the
1556 opcode, so we have to write out the first word big endian.
1558 The exception is "call", which has two operands that we
1561 The first operand (the register list) happens to be in the
1562 first instruction word, and will be in the right place if
1563 we output the first word in big endian mode.
1565 The second operand (stack size) is in the extension word,
1566 and we want it to appear as the first character in the extension
1567 word (as it appears in memory). Luckily, writing the extension
1568 word in big endian format will do what we want. */
1569 number_to_chars_bigendian (f
, insn
, size
> 4 ? 4 : size
);
1572 number_to_chars_bigendian (f
+ 4, extension
, 4);
1573 number_to_chars_bigendian (f
+ 8, 0, size
- 8);
1576 number_to_chars_bigendian (f
+ 4, extension
, size
- 4);
1580 /* Allocate space for the instruction. */
1581 f
= frag_more (size
);
1583 /* Fill in bytes for the instruction. Note that opcode fields
1584 are written big-endian, 16 & 32bit immediates are written
1585 little endian. Egad. */
1586 if (opcode
->format
== FMT_S0
1587 || opcode
->format
== FMT_S1
1588 || opcode
->format
== FMT_D0
1589 || opcode
->format
== FMT_D6
1590 || opcode
->format
== FMT_D7
1591 || opcode
->format
== FMT_D10
1592 || opcode
->format
== FMT_D1
)
1594 number_to_chars_bigendian (f
, insn
, size
);
1596 else if (opcode
->format
== FMT_S2
1597 && opcode
->opcode
!= 0xdf0000
1598 && opcode
->opcode
!= 0xde0000)
1600 /* A format S2 instruction that is _not_ "ret" and "retf". */
1601 number_to_chars_bigendian (f
, (insn
>> 16) & 0xff, 1);
1602 number_to_chars_littleendian (f
+ 1, insn
& 0xffff, 2);
1604 else if (opcode
->format
== FMT_S2
)
1606 /* This must be a ret or retf, which is written entirely in
1607 big-endian format. */
1608 number_to_chars_bigendian (f
, insn
, 3);
1610 else if (opcode
->format
== FMT_S4
1611 && opcode
->opcode
!= 0xdc000000)
1613 /* This must be a format S4 "call" instruction. What a pain. */
1614 unsigned long temp
= (insn
>> 8) & 0xffff;
1615 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1616 number_to_chars_littleendian (f
+ 1, temp
, 2);
1617 number_to_chars_bigendian (f
+ 3, insn
& 0xff, 1);
1618 number_to_chars_bigendian (f
+ 4, extension
& 0xff, 1);
1620 else if (opcode
->format
== FMT_S4
)
1622 /* This must be a format S4 "jmp" instruction. */
1623 unsigned long temp
= ((insn
& 0xffffff) << 8) | (extension
& 0xff);
1624 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1625 number_to_chars_littleendian (f
+ 1, temp
, 4);
1627 else if (opcode
->format
== FMT_S6
)
1629 unsigned long temp
= ((insn
& 0xffffff) << 8)
1630 | ((extension
>> 16) & 0xff);
1631 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1632 number_to_chars_littleendian (f
+ 1, temp
, 4);
1633 number_to_chars_bigendian (f
+ 5, (extension
>> 8) & 0xff, 1);
1634 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
1636 else if (opcode
->format
== FMT_D2
1637 && opcode
->opcode
!= 0xfaf80000
1638 && opcode
->opcode
!= 0xfaf00000
1639 && opcode
->opcode
!= 0xfaf40000)
1641 /* A format D2 instruction where the 16bit immediate is
1642 really a single 16bit value, not two 8bit values. */
1643 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1644 number_to_chars_littleendian (f
+ 2, insn
& 0xffff, 2);
1646 else if (opcode
->format
== FMT_D2
)
1648 /* A format D2 instruction where the 16bit immediate
1649 is really two 8bit immediates. */
1650 number_to_chars_bigendian (f
, insn
, 4);
1652 else if (opcode
->format
== FMT_D4
)
1654 unsigned long temp
= ((insn
& 0xffff) << 16) | (extension
& 0xffff);
1656 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1657 number_to_chars_littleendian (f
+ 2, temp
, 4);
1659 else if (opcode
->format
== FMT_D5
)
1661 unsigned long temp
= (((insn
& 0xffff) << 16)
1662 | ((extension
>> 8) & 0xffff));
1664 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1665 number_to_chars_littleendian (f
+ 2, temp
, 4);
1666 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
1668 else if (opcode
->format
== FMT_D8
)
1670 unsigned long temp
= ((insn
& 0xff) << 16) | (extension
& 0xffff);
1672 number_to_chars_bigendian (f
, (insn
>> 8) & 0xffffff, 3);
1673 number_to_chars_bigendian (f
+ 3, (temp
& 0xff), 1);
1674 number_to_chars_littleendian (f
+ 4, temp
>> 8, 2);
1676 else if (opcode
->format
== FMT_D9
)
1678 unsigned long temp
= ((insn
& 0xff) << 24) | (extension
& 0xffffff);
1680 number_to_chars_bigendian (f
, (insn
>> 8) & 0xffffff, 3);
1681 number_to_chars_littleendian (f
+ 3, temp
, 4);
1684 /* Create any fixups. */
1685 for (i
= 0; i
< fc
; i
++)
1687 const struct mn10300_operand
*operand
;
1689 operand
= &mn10300_operands
[fixups
[i
].opindex
];
1690 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
1692 reloc_howto_type
*reloc_howto
;
1697 reloc_howto
= bfd_reloc_type_lookup (stdoutput
,
1703 size
= bfd_get_reloc_size (reloc_howto
);
1705 if (size
< 1 || size
> 4)
1709 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
,
1710 size
, &fixups
[i
].exp
,
1711 reloc_howto
->pc_relative
,
1716 int reloc
, pcrel
, reloc_size
, offset
;
1719 reloc
= BFD_RELOC_NONE
;
1720 /* How big is the reloc? Remember SPLIT relocs are
1721 implicitly 32bits. */
1722 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
1724 else if ((operand
->flags
& MN10300_OPERAND_24BIT
) != 0)
1727 reloc_size
= operand
->bits
;
1729 /* Is the reloc pc-relative? */
1730 pcrel
= (operand
->flags
& MN10300_OPERAND_PCREL
) != 0;
1732 /* Gross. This disgusting hack is to make sure we
1733 get the right offset for the 16/32 bit reloc in
1734 "call" instructions. Basically they're a pain
1735 because the reloc isn't at the end of the instruction. */
1736 if ((size
== 5 || size
== 7)
1737 && (((insn
>> 24) & 0xff) == 0xcd
1738 || ((insn
>> 24) & 0xff) == 0xdd))
1741 /* Similarly for certain bit instructions which don't
1742 hav their 32bit reloc at the tail of the instruction. */
1744 && (((insn
>> 16) & 0xffff) == 0xfe00
1745 || ((insn
>> 16) & 0xffff) == 0xfe01
1746 || ((insn
>> 16) & 0xffff) == 0xfe02))
1749 offset
= size
- reloc_size
/ 8;
1751 /* Choose a proper BFD relocation type. */
1754 if (reloc_size
== 32)
1755 reloc
= BFD_RELOC_32_PCREL
;
1756 else if (reloc_size
== 16)
1757 reloc
= BFD_RELOC_16_PCREL
;
1758 else if (reloc_size
== 8)
1759 reloc
= BFD_RELOC_8_PCREL
;
1765 if (reloc_size
== 32)
1766 reloc
= BFD_RELOC_32
;
1767 else if (reloc_size
== 16)
1768 reloc
= BFD_RELOC_16
;
1769 else if (reloc_size
== 8)
1770 reloc
= BFD_RELOC_8
;
1775 /* Convert the size of the reloc into what fix_new_exp wants. */
1776 reloc_size
= reloc_size
/ 8;
1777 if (reloc_size
== 8)
1779 else if (reloc_size
== 16)
1781 else if (reloc_size
== 32)
1784 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
,
1785 reloc_size
, &fixups
[i
].exp
, pcrel
,
1786 ((bfd_reloc_code_real_type
) reloc
));
1789 fixP
->fx_offset
+= offset
;
1794 if (debug_type
== DEBUG_DWARF2
)
1798 /* First update the notion of the current source line. */
1799 dwarf2_where (&debug_line
);
1801 /* We want the offset of the start of this instruction within the
1802 the current frag. */
1803 addr
= frag_now
->fr_address
+ frag_now_fix () - real_size
;
1805 /* And record the information. */
1806 dwarf2_gen_line_info (addr
, &debug_line
);
1810 /* If while processing a fixup, a reloc really needs to be created
1811 then it is done here. */
1814 tc_gen_reloc (seg
, fixp
)
1815 asection
*seg ATTRIBUTE_UNUSED
;
1819 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1821 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
1822 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
1824 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1825 _("reloc %d not supported by object file format"),
1826 (int) fixp
->fx_r_type
);
1829 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1831 if (fixp
->fx_addsy
&& fixp
->fx_subsy
)
1834 if ((S_GET_SEGMENT (fixp
->fx_addsy
) != S_GET_SEGMENT (fixp
->fx_subsy
))
1835 || S_GET_SEGMENT (fixp
->fx_addsy
) == undefined_section
)
1837 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1838 "Difference of symbols in different sections is not supported");
1842 reloc
->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
1843 reloc
->addend
= (S_GET_VALUE (fixp
->fx_addsy
)
1844 - S_GET_VALUE (fixp
->fx_subsy
) + fixp
->fx_offset
);
1848 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1849 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1850 reloc
->addend
= fixp
->fx_offset
;
1856 md_estimate_size_before_relax (fragp
, seg
)
1860 if (fragp
->fr_subtype
== 0)
1862 if (fragp
->fr_subtype
== 3)
1864 if (fragp
->fr_subtype
== 6)
1866 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1867 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1869 fragp
->fr_subtype
= 7;
1875 if (fragp
->fr_subtype
== 8)
1877 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1878 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1880 fragp
->fr_subtype
= 9;
1886 if (fragp
->fr_subtype
== 10)
1888 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1889 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1891 fragp
->fr_subtype
= 12;
1901 md_pcrel_from (fixp
)
1904 if (fixp
->fx_addsy
!= (symbolS
*) NULL
&& !S_IS_DEFINED (fixp
->fx_addsy
))
1906 /* The symbol is undefined. Let the linker figure it out. */
1909 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1913 md_apply_fix3 (fixp
, valuep
, seg
)
1918 char *fixpos
= fixp
->fx_where
+ fixp
->fx_frag
->fr_literal
;
1922 assert (fixp
->fx_r_type
< BFD_RELOC_UNUSED
);
1924 /* This should never happen. */
1925 if (seg
->flags
& SEC_ALLOC
)
1928 /* The value we are passed in *valuep includes the symbol values.
1929 Since we are using BFD_ASSEMBLER, if we are doing this relocation
1930 the code in write.c is going to call bfd_install_relocation, which
1931 is also going to use the symbol value. That means that if the
1932 reloc is fully resolved we want to use *valuep since
1933 bfd_install_relocation is not being used.
1935 However, if the reloc is not fully resolved we do not want to use
1936 *valuep, and must use fx_offset instead. However, if the reloc
1937 is PC relative, we do want to use *valuep since it includes the
1938 result of md_pcrel_from. */
1939 if (fixp
->fx_addsy
== (symbolS
*) NULL
|| fixp
->fx_pcrel
)
1942 value
= fixp
->fx_offset
;
1945 /* If the fix is relative to a symbol which is not defined, or not
1946 in the same segment as the fix, we cannot resolve it here. */
1947 if (fixp
->fx_addsy
!= NULL
1948 && (! S_IS_DEFINED (fixp
->fx_addsy
)
1949 || (S_GET_SEGMENT (fixp
->fx_addsy
) != seg
)))
1955 switch (fixp
->fx_r_type
)
1969 case BFD_RELOC_VTABLE_INHERIT
:
1970 case BFD_RELOC_VTABLE_ENTRY
:
1974 case BFD_RELOC_NONE
:
1976 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1977 _("Bad relocation fixup type (%d)"), fixp
->fx_r_type
);
1980 md_number_to_chars (fixpos
, value
, size
);
1987 /* Return nonzero if the fixup in FIXP will require a relocation,
1988 even it if appears that the fixup could be completely handled
1992 mn10300_force_relocation (fixp
)
1995 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
1996 || fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
2002 /* Return zero if the fixup in fixp should be left alone and not
2006 mn10300_fix_adjustable (fixp
)
2009 /* Prevent all adjustments to global symbols. */
2010 if (S_IS_EXTERN (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
))
2013 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
2014 || fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
2020 /* Insert an operand value into an instruction. */
2023 mn10300_insert_operand (insnp
, extensionp
, operand
, val
, file
, line
, shift
)
2024 unsigned long *insnp
;
2025 unsigned long *extensionp
;
2026 const struct mn10300_operand
*operand
;
2032 /* No need to check 32bit operands for a bit. Note that
2033 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
2034 if (operand
->bits
!= 32
2035 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
2041 bits
= operand
->bits
;
2042 if (operand
->flags
& MN10300_OPERAND_24BIT
)
2045 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
2047 max
= (1 << (bits
- 1)) - 1;
2048 min
= - (1 << (bits
- 1));
2052 max
= (1 << bits
) - 1;
2058 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
2061 _("operand out of range (%s not between %ld and %ld)");
2064 sprint_value (buf
, test
);
2065 if (file
== (char *) NULL
)
2066 as_warn (err
, buf
, min
, max
);
2068 as_warn_where (file
, line
, err
, buf
, min
, max
);
2072 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
2074 *insnp
|= (val
>> (32 - operand
->bits
)) & ((1 << operand
->bits
) - 1);
2075 *extensionp
|= ((val
& ((1 << (32 - operand
->bits
)) - 1))
2078 else if ((operand
->flags
& MN10300_OPERAND_24BIT
) != 0)
2080 *insnp
|= (val
>> (24 - operand
->bits
)) & ((1 << operand
->bits
) - 1);
2081 *extensionp
|= ((val
& ((1 << (24 - operand
->bits
)) - 1))
2084 else if ((operand
->flags
& MN10300_OPERAND_EXTENDED
) == 0)
2086 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2087 << (operand
->shift
+ shift
));
2089 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
2090 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2091 << (operand
->shift
+ shift
+ operand
->bits
));
2095 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2096 << (operand
->shift
+ shift
));
2098 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
2099 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2100 << (operand
->shift
+ shift
+ operand
->bits
));
2104 static unsigned long
2105 check_operand (insn
, operand
, val
)
2106 unsigned long insn ATTRIBUTE_UNUSED
;
2107 const struct mn10300_operand
*operand
;
2110 /* No need to check 32bit operands for a bit. Note that
2111 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
2112 if (operand
->bits
!= 32
2113 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
2119 bits
= operand
->bits
;
2120 if (operand
->flags
& MN10300_OPERAND_24BIT
)
2123 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
2125 max
= (1 << (bits
- 1)) - 1;
2126 min
= - (1 << (bits
- 1));
2130 max
= (1 << bits
) - 1;
2136 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
2145 set_arch_mach (mach
)
2148 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_mn10300
, mach
))
2149 as_warn (_("could not set architecture and machine"));
2151 current_machine
= mach
;
2157 if (debug_type
== DEBUG_DWARF2
)