1 /* tc-mn10300.c -- Assembler code for the Matsushita 10300
2 Copyright 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "opcode/mn10300.h"
27 #include "dwarf2dbg.h"
29 /* Structure to hold information about predefined registers. */
36 /* Generic assembler global variables which must be defined by all
39 /* Characters which always start a comment. */
40 const char comment_chars
[] = "#";
42 /* Characters which start a comment at the beginning of a line. */
43 const char line_comment_chars
[] = ";#";
45 /* Characters which may be used to separate multiple commands on a
47 const char line_separator_chars
[] = ";";
49 /* Characters which are used to indicate an exponent in a floating
51 const char EXP_CHARS
[] = "eE";
53 /* Characters which mean that a number is a floating point constant,
55 const char FLT_CHARS
[] = "dD";
57 const relax_typeS md_relax_table
[] = {
60 {0x7fff, -0x8000, 5, 2},
61 {0x7fffffff, -0x80000000, 7, 0},
63 /* bCC relaxing (uncommon cases) */
65 {0x7fff, -0x8000, 6, 5},
66 {0x7fffffff, -0x80000000, 8, 0},
69 {0x7fff, -0x8000, 5, 7},
70 {0x7fffffff, -0x80000000, 7, 0},
73 {0x7fff, -0x8000, 4, 9},
74 {0x7fffffff, -0x80000000, 6, 0},
78 {0x7fff, -0x8000, 3, 12},
79 {0x7fffffff, -0x80000000, 5, 0},
83 /* Local functions. */
84 static void mn10300_insert_operand
PARAMS ((unsigned long *, unsigned long *,
85 const struct mn10300_operand
*,
86 offsetT
, char *, unsigned,
88 static unsigned long check_operand
PARAMS ((unsigned long,
89 const struct mn10300_operand
*,
91 static int reg_name_search
PARAMS ((const struct reg_name
*, int, const char *));
92 static boolean data_register_name
PARAMS ((expressionS
*expressionP
));
93 static boolean address_register_name
PARAMS ((expressionS
*expressionP
));
94 static boolean other_register_name
PARAMS ((expressionS
*expressionP
));
95 static void set_arch_mach
PARAMS ((int));
97 /* Set linkrelax here to avoid fixups in most sections. */
100 static int current_machine
;
103 #define MAX_INSN_FIXUPS (5)
108 bfd_reloc_code_real_type reloc
;
110 struct mn10300_fixup fixups
[MAX_INSN_FIXUPS
];
113 /* We must store the value of each register operand so that we can
114 verify that certain registers do not match. */
115 int mn10300_reg_operands
[MN10300_MAX_OPERANDS
];
117 const char *md_shortopts
= "";
118 struct option md_longopts
[] = {
119 {NULL
, no_argument
, NULL
, 0}
121 size_t md_longopts_size
= sizeof (md_longopts
);
123 /* The target specific pseudo-ops which we support. */
124 const pseudo_typeS md_pseudo_table
[] =
126 { "file", dwarf2_directive_file
, 0 },
127 { "loc", dwarf2_directive_loc
, 0 },
128 { "am30", set_arch_mach
, AM30
},
129 { "am33", set_arch_mach
, AM33
},
130 { "mn10300", set_arch_mach
, MN103
},
134 #define HAVE_AM33 (current_machine == AM33)
135 #define HAVE_AM30 (current_machine == AM30)
137 /* Opcode hash table. */
138 static struct hash_control
*mn10300_hash
;
140 /* This table is sorted. Suitable for searching by a binary search. */
141 static const struct reg_name data_registers
[] =
148 #define DATA_REG_NAME_CNT \
149 (sizeof (data_registers) / sizeof (struct reg_name))
151 static const struct reg_name address_registers
[] =
159 #define ADDRESS_REG_NAME_CNT \
160 (sizeof (address_registers) / sizeof (struct reg_name))
162 static const struct reg_name r_registers
[] =
206 #define R_REG_NAME_CNT \
207 (sizeof (r_registers) / sizeof (struct reg_name))
209 static const struct reg_name xr_registers
[] =
234 #define XR_REG_NAME_CNT \
235 (sizeof (xr_registers) / sizeof (struct reg_name))
237 static const struct reg_name other_registers
[] =
244 #define OTHER_REG_NAME_CNT \
245 (sizeof (other_registers) / sizeof (struct reg_name))
247 /* reg_name_search does a binary search of the given register table
248 to see if "name" is a valid regiter name. Returns the register
249 number from the array on success, or -1 on failure. */
252 reg_name_search (regs
, regcount
, name
)
253 const struct reg_name
*regs
;
257 int middle
, low
, high
;
265 middle
= (low
+ high
) / 2;
266 cmp
= strcasecmp (name
, regs
[middle
].name
);
272 return regs
[middle
].value
;
278 /* Summary of register_name().
280 * in: Input_line_pointer points to 1st char of operand.
282 * out: A expressionS.
283 * The operand may have been a register: in this case, X_op == O_register,
284 * X_add_number is set to the register number, and truth is returned.
285 * Input_line_pointer->(next non-blank) char after operand, or is in
286 * its original state.
290 r_register_name (expressionP
)
291 expressionS
*expressionP
;
298 /* Find the spelling of the operand. */
299 start
= name
= input_line_pointer
;
301 c
= get_symbol_end ();
302 reg_number
= reg_name_search (r_registers
, R_REG_NAME_CNT
, name
);
304 /* Look to see if it's in the register table. */
307 expressionP
->X_op
= O_register
;
308 expressionP
->X_add_number
= reg_number
;
310 /* Make the rest nice. */
311 expressionP
->X_add_symbol
= NULL
;
312 expressionP
->X_op_symbol
= NULL
;
314 /* Put back the delimiting char. */
315 *input_line_pointer
= c
;
320 /* Reset the line as if we had not done anything. */
321 /* Put back the delimiting char. */
322 *input_line_pointer
= c
;
324 /* Reset input_line pointer. */
325 input_line_pointer
= start
;
330 /* Summary of register_name().
332 * in: Input_line_pointer points to 1st char of operand.
334 * out: A expressionS.
335 * The operand may have been a register: in this case, X_op == O_register,
336 * X_add_number is set to the register number, and truth is returned.
337 * Input_line_pointer->(next non-blank) char after operand, or is in
338 * its original state.
342 xr_register_name (expressionP
)
343 expressionS
*expressionP
;
350 /* Find the spelling of the operand. */
351 start
= name
= input_line_pointer
;
353 c
= get_symbol_end ();
354 reg_number
= reg_name_search (xr_registers
, XR_REG_NAME_CNT
, name
);
356 /* Look to see if it's in the register table. */
359 expressionP
->X_op
= O_register
;
360 expressionP
->X_add_number
= reg_number
;
362 /* Make the rest nice. */
363 expressionP
->X_add_symbol
= NULL
;
364 expressionP
->X_op_symbol
= NULL
;
366 /* Put back the delimiting char. */
367 *input_line_pointer
= c
;
372 /* Reset the line as if we had not done anything. */
373 /* Put back the delimiting char. */
374 *input_line_pointer
= c
;
376 /* Reset input_line pointer. */
377 input_line_pointer
= start
;
382 /* Summary of register_name().
384 * in: Input_line_pointer points to 1st char of operand.
386 * out: A expressionS.
387 * The operand may have been a register: in this case, X_op == O_register,
388 * X_add_number is set to the register number, and truth is returned.
389 * Input_line_pointer->(next non-blank) char after operand, or is in
390 * its original state.
394 data_register_name (expressionP
)
395 expressionS
*expressionP
;
402 /* Find the spelling of the operand. */
403 start
= name
= input_line_pointer
;
405 c
= get_symbol_end ();
406 reg_number
= reg_name_search (data_registers
, DATA_REG_NAME_CNT
, name
);
408 /* Look to see if it's in the register table. */
411 expressionP
->X_op
= O_register
;
412 expressionP
->X_add_number
= reg_number
;
414 /* Make the rest nice. */
415 expressionP
->X_add_symbol
= NULL
;
416 expressionP
->X_op_symbol
= NULL
;
418 /* Put back the delimiting char. */
419 *input_line_pointer
= c
;
424 /* Reset the line as if we had not done anything. */
425 /* Put back the delimiting char. */
426 *input_line_pointer
= c
;
428 /* Reset input_line pointer. */
429 input_line_pointer
= start
;
434 /* Summary of register_name().
436 * in: Input_line_pointer points to 1st char of operand.
438 * out: A expressionS.
439 * The operand may have been a register: in this case, X_op == O_register,
440 * X_add_number is set to the register number, and truth is returned.
441 * Input_line_pointer->(next non-blank) char after operand, or is in
442 * its original state.
446 address_register_name (expressionP
)
447 expressionS
*expressionP
;
454 /* Find the spelling of the operand. */
455 start
= name
= input_line_pointer
;
457 c
= get_symbol_end ();
458 reg_number
= reg_name_search (address_registers
, ADDRESS_REG_NAME_CNT
, name
);
460 /* Look to see if it's in the register table. */
463 expressionP
->X_op
= O_register
;
464 expressionP
->X_add_number
= reg_number
;
466 /* Make the rest nice. */
467 expressionP
->X_add_symbol
= NULL
;
468 expressionP
->X_op_symbol
= NULL
;
470 /* Put back the delimiting char. */
471 *input_line_pointer
= c
;
476 /* Reset the line as if we had not done anything. */
477 /* Put back the delimiting char. */
478 *input_line_pointer
= c
;
480 /* Reset input_line pointer. */
481 input_line_pointer
= start
;
487 /* Summary of register_name().
489 * in: Input_line_pointer points to 1st char of operand.
491 * out: A expressionS.
492 * The operand may have been a register: in this case, X_op == O_register,
493 * X_add_number is set to the register number, and truth is returned.
494 * Input_line_pointer->(next non-blank) char after operand, or is in
495 * its original state.
499 other_register_name (expressionP
)
500 expressionS
*expressionP
;
507 /* Find the spelling of the operand. */
508 start
= name
= input_line_pointer
;
510 c
= get_symbol_end ();
511 reg_number
= reg_name_search (other_registers
, OTHER_REG_NAME_CNT
, name
);
513 /* Look to see if it's in the register table. */
516 expressionP
->X_op
= O_register
;
517 expressionP
->X_add_number
= reg_number
;
519 /* Make the rest nice. */
520 expressionP
->X_add_symbol
= NULL
;
521 expressionP
->X_op_symbol
= NULL
;
523 /* Put back the delimiting char. */
524 *input_line_pointer
= c
;
529 /* Reset the line as if we had not done anything. */
530 /* Put back the delimiting char. */
531 *input_line_pointer
= c
;
533 /* Reset input_line pointer. */
534 input_line_pointer
= start
;
540 md_show_usage (stream
)
543 fprintf (stream
, _("MN10300 options:\n\
548 md_parse_option (c
, arg
)
549 int c ATTRIBUTE_UNUSED
;
550 char *arg ATTRIBUTE_UNUSED
;
556 md_undefined_symbol (name
)
557 char *name ATTRIBUTE_UNUSED
;
563 md_atof (type
, litp
, sizep
)
569 LITTLENUM_TYPE words
[4];
585 return "bad call to md_atof";
588 t
= atof_ieee (input_line_pointer
, type
, words
);
590 input_line_pointer
= t
;
594 for (i
= prec
- 1; i
>= 0; i
--)
596 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
604 md_convert_frag (abfd
, sec
, fragP
)
605 bfd
*abfd ATTRIBUTE_UNUSED
;
609 static unsigned long label_count
= 0;
612 subseg_change (sec
, 0);
613 if (fragP
->fr_subtype
== 0)
615 fix_new (fragP
, fragP
->fr_fix
+ 1, 1, fragP
->fr_symbol
,
616 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
620 else if (fragP
->fr_subtype
== 1)
622 /* Reverse the condition of the first branch. */
623 int offset
= fragP
->fr_fix
;
624 int opcode
= fragP
->fr_literal
[offset
] & 0xff;
661 fragP
->fr_literal
[offset
] = opcode
;
663 /* Create a fixup for the reversed conditional branch. */
664 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
665 fix_new (fragP
, fragP
->fr_fix
+ 1, 1,
666 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
667 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
669 /* Now create the unconditional branch + fixup to the
671 fragP
->fr_literal
[offset
+ 2] = 0xcc;
672 fix_new (fragP
, fragP
->fr_fix
+ 3, 2, fragP
->fr_symbol
,
673 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
677 else if (fragP
->fr_subtype
== 2)
679 /* Reverse the condition of the first branch. */
680 int offset
= fragP
->fr_fix
;
681 int opcode
= fragP
->fr_literal
[offset
] & 0xff;
718 fragP
->fr_literal
[offset
] = opcode
;
720 /* Create a fixup for the reversed conditional branch. */
721 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
722 fix_new (fragP
, fragP
->fr_fix
+ 1, 1,
723 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
724 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
726 /* Now create the unconditional branch + fixup to the
728 fragP
->fr_literal
[offset
+ 2] = 0xdc;
729 fix_new (fragP
, fragP
->fr_fix
+ 3, 4, fragP
->fr_symbol
,
730 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
734 else if (fragP
->fr_subtype
== 3)
736 fix_new (fragP
, fragP
->fr_fix
+ 2, 1, fragP
->fr_symbol
,
737 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
741 else if (fragP
->fr_subtype
== 4)
743 /* Reverse the condition of the first branch. */
744 int offset
= fragP
->fr_fix
;
745 int opcode
= fragP
->fr_literal
[offset
+ 1] & 0xff;
764 fragP
->fr_literal
[offset
+ 1] = opcode
;
766 /* Create a fixup for the reversed conditional branch. */
767 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
768 fix_new (fragP
, fragP
->fr_fix
+ 2, 1,
769 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
770 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
772 /* Now create the unconditional branch + fixup to the
774 fragP
->fr_literal
[offset
+ 3] = 0xcc;
775 fix_new (fragP
, fragP
->fr_fix
+ 4, 2, fragP
->fr_symbol
,
776 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
780 else if (fragP
->fr_subtype
== 5)
782 /* Reverse the condition of the first branch. */
783 int offset
= fragP
->fr_fix
;
784 int opcode
= fragP
->fr_literal
[offset
+ 1] & 0xff;
800 fragP
->fr_literal
[offset
+ 1] = opcode
;
802 /* Create a fixup for the reversed conditional branch. */
803 sprintf (buf
, ".%s_%ld", FAKE_LABEL_NAME
, label_count
++);
804 fix_new (fragP
, fragP
->fr_fix
+ 2, 1,
805 symbol_new (buf
, sec
, 0, fragP
->fr_next
),
806 fragP
->fr_offset
+ 2, 1, BFD_RELOC_8_PCREL
);
808 /* Now create the unconditional branch + fixup to the
810 fragP
->fr_literal
[offset
+ 3] = 0xdc;
811 fix_new (fragP
, fragP
->fr_fix
+ 4, 4, fragP
->fr_symbol
,
812 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
816 else if (fragP
->fr_subtype
== 6)
818 int offset
= fragP
->fr_fix
;
819 fragP
->fr_literal
[offset
] = 0xcd;
820 fix_new (fragP
, fragP
->fr_fix
+ 1, 2, fragP
->fr_symbol
,
821 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
825 else if (fragP
->fr_subtype
== 7)
827 int offset
= fragP
->fr_fix
;
828 fragP
->fr_literal
[offset
] = 0xdd;
829 fragP
->fr_literal
[offset
+ 5] = fragP
->fr_literal
[offset
+ 3];
830 fragP
->fr_literal
[offset
+ 6] = fragP
->fr_literal
[offset
+ 4];
832 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
833 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
837 else if (fragP
->fr_subtype
== 8)
839 int offset
= fragP
->fr_fix
;
840 fragP
->fr_literal
[offset
] = 0xfa;
841 fragP
->fr_literal
[offset
+ 1] = 0xff;
842 fix_new (fragP
, fragP
->fr_fix
+ 2, 2, fragP
->fr_symbol
,
843 fragP
->fr_offset
+ 2, 1, BFD_RELOC_16_PCREL
);
847 else if (fragP
->fr_subtype
== 9)
849 int offset
= fragP
->fr_fix
;
850 fragP
->fr_literal
[offset
] = 0xfc;
851 fragP
->fr_literal
[offset
+ 1] = 0xff;
853 fix_new (fragP
, fragP
->fr_fix
+ 2, 4, fragP
->fr_symbol
,
854 fragP
->fr_offset
+ 2, 1, BFD_RELOC_32_PCREL
);
858 else if (fragP
->fr_subtype
== 10)
860 fragP
->fr_literal
[fragP
->fr_fix
] = 0xca;
861 fix_new (fragP
, fragP
->fr_fix
+ 1, 1, fragP
->fr_symbol
,
862 fragP
->fr_offset
+ 1, 1, BFD_RELOC_8_PCREL
);
866 else if (fragP
->fr_subtype
== 11)
868 int offset
= fragP
->fr_fix
;
869 fragP
->fr_literal
[offset
] = 0xcc;
871 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
872 fragP
->fr_offset
+ 1, 1, BFD_RELOC_16_PCREL
);
876 else if (fragP
->fr_subtype
== 12)
878 int offset
= fragP
->fr_fix
;
879 fragP
->fr_literal
[offset
] = 0xdc;
881 fix_new (fragP
, fragP
->fr_fix
+ 1, 4, fragP
->fr_symbol
,
882 fragP
->fr_offset
+ 1, 1, BFD_RELOC_32_PCREL
);
891 md_section_align (seg
, addr
)
895 int align
= bfd_get_section_alignment (stdoutput
, seg
);
896 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
902 char *prev_name
= "";
903 register const struct mn10300_opcode
*op
;
905 mn10300_hash
= hash_new ();
907 /* Insert unique names into hash table. The MN10300 instruction set
908 has many identical opcode names that have different opcodes based
909 on the operands. This hash table then provides a quick index to
910 the first opcode with a particular name in the opcode table. */
912 op
= mn10300_opcodes
;
915 if (strcmp (prev_name
, op
->name
))
917 prev_name
= (char *) op
->name
;
918 hash_insert (mn10300_hash
, op
->name
, (char *) op
);
923 /* Set the default machine type. */
924 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_mn10300
, MN103
))
925 as_warn (_("could not set architecture and machine"));
927 current_machine
= MN103
;
935 struct mn10300_opcode
*opcode
;
936 struct mn10300_opcode
*next_opcode
;
937 const unsigned char *opindex_ptr
;
938 int next_opindex
, relaxable
;
939 unsigned long insn
, extension
, size
= 0, real_size
;
944 /* Get the opcode. */
945 for (s
= str
; *s
!= '\0' && !isspace (*s
); s
++)
950 /* Find the first opcode with the proper name. */
951 opcode
= (struct mn10300_opcode
*) hash_find (mn10300_hash
, str
);
954 as_bad (_("Unrecognized opcode: `%s'"), str
);
959 while (isspace (*str
))
962 input_line_pointer
= str
;
971 errmsg
= _("Invalid opcode/operands");
973 /* Reset the array of register operands. */
974 memset (mn10300_reg_operands
, -1, sizeof (mn10300_reg_operands
));
980 insn
= opcode
->opcode
;
983 /* If the instruction is not available on the current machine
984 then it can not possibly match. */
986 && !(opcode
->machine
== AM33
&& HAVE_AM33
)
987 && !(opcode
->machine
== AM30
&& HAVE_AM30
))
990 for (op_idx
= 1, opindex_ptr
= opcode
->operands
;
992 opindex_ptr
++, op_idx
++)
994 const struct mn10300_operand
*operand
;
997 if (next_opindex
== 0)
999 operand
= &mn10300_operands
[*opindex_ptr
];
1003 operand
= &mn10300_operands
[next_opindex
];
1007 while (*str
== ' ' || *str
== ',')
1010 if (operand
->flags
& MN10300_OPERAND_RELAX
)
1013 /* Gather the operand. */
1014 hold
= input_line_pointer
;
1015 input_line_pointer
= str
;
1017 if (operand
->flags
& MN10300_OPERAND_PAREN
)
1019 if (*input_line_pointer
!= ')' && *input_line_pointer
!= '(')
1021 input_line_pointer
= hold
;
1025 input_line_pointer
++;
1028 /* See if we can match the operands. */
1029 else if (operand
->flags
& MN10300_OPERAND_DREG
)
1031 if (!data_register_name (&ex
))
1033 input_line_pointer
= hold
;
1038 else if (operand
->flags
& MN10300_OPERAND_AREG
)
1040 if (!address_register_name (&ex
))
1042 input_line_pointer
= hold
;
1047 else if (operand
->flags
& MN10300_OPERAND_SP
)
1049 char *start
= input_line_pointer
;
1050 char c
= get_symbol_end ();
1052 if (strcasecmp (start
, "sp") != 0)
1054 *input_line_pointer
= c
;
1055 input_line_pointer
= hold
;
1059 *input_line_pointer
= c
;
1062 else if (operand
->flags
& MN10300_OPERAND_RREG
)
1064 if (!r_register_name (&ex
))
1066 input_line_pointer
= hold
;
1071 else if (operand
->flags
& MN10300_OPERAND_XRREG
)
1073 if (!xr_register_name (&ex
))
1075 input_line_pointer
= hold
;
1080 else if (operand
->flags
& MN10300_OPERAND_USP
)
1082 char *start
= input_line_pointer
;
1083 char c
= get_symbol_end ();
1085 if (strcasecmp (start
, "usp") != 0)
1087 *input_line_pointer
= c
;
1088 input_line_pointer
= hold
;
1092 *input_line_pointer
= c
;
1095 else if (operand
->flags
& MN10300_OPERAND_SSP
)
1097 char *start
= input_line_pointer
;
1098 char c
= get_symbol_end ();
1100 if (strcasecmp (start
, "ssp") != 0)
1102 *input_line_pointer
= c
;
1103 input_line_pointer
= hold
;
1107 *input_line_pointer
= c
;
1110 else if (operand
->flags
& MN10300_OPERAND_MSP
)
1112 char *start
= input_line_pointer
;
1113 char c
= get_symbol_end ();
1115 if (strcasecmp (start
, "msp") != 0)
1117 *input_line_pointer
= c
;
1118 input_line_pointer
= hold
;
1122 *input_line_pointer
= c
;
1125 else if (operand
->flags
& MN10300_OPERAND_PC
)
1127 char *start
= input_line_pointer
;
1128 char c
= get_symbol_end ();
1130 if (strcasecmp (start
, "pc") != 0)
1132 *input_line_pointer
= c
;
1133 input_line_pointer
= hold
;
1137 *input_line_pointer
= c
;
1140 else if (operand
->flags
& MN10300_OPERAND_EPSW
)
1142 char *start
= input_line_pointer
;
1143 char c
= get_symbol_end ();
1145 if (strcasecmp (start
, "epsw") != 0)
1147 *input_line_pointer
= c
;
1148 input_line_pointer
= hold
;
1152 *input_line_pointer
= c
;
1155 else if (operand
->flags
& MN10300_OPERAND_PLUS
)
1157 if (*input_line_pointer
!= '+')
1159 input_line_pointer
= hold
;
1163 input_line_pointer
++;
1166 else if (operand
->flags
& MN10300_OPERAND_PSW
)
1168 char *start
= input_line_pointer
;
1169 char c
= get_symbol_end ();
1171 if (strcasecmp (start
, "psw") != 0)
1173 *input_line_pointer
= c
;
1174 input_line_pointer
= hold
;
1178 *input_line_pointer
= c
;
1181 else if (operand
->flags
& MN10300_OPERAND_MDR
)
1183 char *start
= input_line_pointer
;
1184 char c
= get_symbol_end ();
1186 if (strcasecmp (start
, "mdr") != 0)
1188 *input_line_pointer
= c
;
1189 input_line_pointer
= hold
;
1193 *input_line_pointer
= c
;
1196 else if (operand
->flags
& MN10300_OPERAND_REG_LIST
)
1198 unsigned int value
= 0;
1199 if (*input_line_pointer
!= '[')
1201 input_line_pointer
= hold
;
1207 input_line_pointer
++;
1209 /* We used to reject a null register list here; however,
1210 we accept it now so the compiler can emit "call"
1211 instructions for all calls to named functions.
1213 The linker can then fill in the appropriate bits for the
1214 register list and stack size or change the instruction
1215 into a "calls" if using "call" is not profitable. */
1216 while (*input_line_pointer
!= ']')
1221 if (*input_line_pointer
== ',')
1222 input_line_pointer
++;
1224 start
= input_line_pointer
;
1225 c
= get_symbol_end ();
1227 if (strcasecmp (start
, "d2") == 0)
1230 *input_line_pointer
= c
;
1232 else if (strcasecmp (start
, "d3") == 0)
1235 *input_line_pointer
= c
;
1237 else if (strcasecmp (start
, "a2") == 0)
1240 *input_line_pointer
= c
;
1242 else if (strcasecmp (start
, "a3") == 0)
1245 *input_line_pointer
= c
;
1247 else if (strcasecmp (start
, "other") == 0)
1250 *input_line_pointer
= c
;
1253 && strcasecmp (start
, "exreg0") == 0)
1256 *input_line_pointer
= c
;
1259 && strcasecmp (start
, "exreg1") == 0)
1262 *input_line_pointer
= c
;
1265 && strcasecmp (start
, "exother") == 0)
1268 *input_line_pointer
= c
;
1271 && strcasecmp (start
, "all") == 0)
1274 *input_line_pointer
= c
;
1278 input_line_pointer
= hold
;
1283 input_line_pointer
++;
1284 mn10300_insert_operand (&insn
, &extension
, operand
,
1285 value
, (char *) NULL
, 0, 0);
1289 else if (data_register_name (&ex
))
1291 input_line_pointer
= hold
;
1295 else if (address_register_name (&ex
))
1297 input_line_pointer
= hold
;
1301 else if (other_register_name (&ex
))
1303 input_line_pointer
= hold
;
1307 else if (HAVE_AM33
&& r_register_name (&ex
))
1309 input_line_pointer
= hold
;
1313 else if (HAVE_AM33
&& xr_register_name (&ex
))
1315 input_line_pointer
= hold
;
1319 else if (*str
== ')' || *str
== '(')
1321 input_line_pointer
= hold
;
1333 errmsg
= _("illegal operand");
1336 errmsg
= _("missing operand");
1342 mask
= MN10300_OPERAND_DREG
| MN10300_OPERAND_AREG
;
1344 mask
|= MN10300_OPERAND_RREG
| MN10300_OPERAND_XRREG
;
1345 if ((operand
->flags
& mask
) == 0)
1347 input_line_pointer
= hold
;
1352 if (opcode
->format
== FMT_D1
|| opcode
->format
== FMT_S1
)
1354 else if (opcode
->format
== FMT_D2
1355 || opcode
->format
== FMT_D4
1356 || opcode
->format
== FMT_S2
1357 || opcode
->format
== FMT_S4
1358 || opcode
->format
== FMT_S6
1359 || opcode
->format
== FMT_D5
)
1361 else if (opcode
->format
== FMT_D7
)
1363 else if (opcode
->format
== FMT_D8
|| opcode
->format
== FMT_D9
)
1368 mn10300_insert_operand (&insn
, &extension
, operand
,
1369 ex
.X_add_number
, (char *) NULL
,
1372 /* And note the register number in the register array. */
1373 mn10300_reg_operands
[op_idx
- 1] = ex
.X_add_number
;
1378 /* If this operand can be promoted, and it doesn't
1379 fit into the allocated bitfield for this insn,
1380 then promote it (ie this opcode does not match). */
1382 & (MN10300_OPERAND_PROMOTE
| MN10300_OPERAND_RELAX
)
1383 && !check_operand (insn
, operand
, ex
.X_add_number
))
1385 input_line_pointer
= hold
;
1390 mn10300_insert_operand (&insn
, &extension
, operand
,
1391 ex
.X_add_number
, (char *) NULL
,
1396 /* If this operand can be promoted, then this opcode didn't
1397 match since we can't know if it needed promotion! */
1398 if (operand
->flags
& MN10300_OPERAND_PROMOTE
)
1400 input_line_pointer
= hold
;
1405 /* We need to generate a fixup for this expression. */
1406 if (fc
>= MAX_INSN_FIXUPS
)
1407 as_fatal (_("too many fixups"));
1408 fixups
[fc
].exp
= ex
;
1409 fixups
[fc
].opindex
= *opindex_ptr
;
1410 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
1416 str
= input_line_pointer
;
1417 input_line_pointer
= hold
;
1419 while (*str
== ' ' || *str
== ',')
1424 /* Make sure we used all the operands! */
1428 /* If this instruction has registers that must not match, verify
1429 that they do indeed not match. */
1430 if (opcode
->no_match_operands
)
1434 /* Look at each operand to see if it's marked. */
1435 for (i
= 0; i
< MN10300_MAX_OPERANDS
; i
++)
1437 if ((1 << i
) & opcode
->no_match_operands
)
1441 /* operand I is marked. Check that it does not match any
1442 operands > I which are marked. */
1443 for (j
= i
+ 1; j
< MN10300_MAX_OPERANDS
; j
++)
1445 if (((1 << j
) & opcode
->no_match_operands
)
1446 && mn10300_reg_operands
[i
] == mn10300_reg_operands
[j
])
1448 errmsg
= _("Invalid register specification.");
1460 next_opcode
= opcode
+ 1;
1461 if (!strcmp (next_opcode
->name
, opcode
->name
))
1463 opcode
= next_opcode
;
1467 as_bad ("%s", errmsg
);
1473 while (isspace (*str
))
1477 as_bad (_("junk at end of line: `%s'"), str
);
1479 input_line_pointer
= str
;
1481 /* Determine the size of the instruction. */
1482 if (opcode
->format
== FMT_S0
)
1485 if (opcode
->format
== FMT_S1
|| opcode
->format
== FMT_D0
)
1488 if (opcode
->format
== FMT_S2
|| opcode
->format
== FMT_D1
)
1491 if (opcode
->format
== FMT_D6
)
1494 if (opcode
->format
== FMT_D7
|| opcode
->format
== FMT_D10
)
1497 if (opcode
->format
== FMT_D8
)
1500 if (opcode
->format
== FMT_D9
)
1503 if (opcode
->format
== FMT_S4
)
1506 if (opcode
->format
== FMT_S6
|| opcode
->format
== FMT_D5
)
1509 if (opcode
->format
== FMT_D2
)
1512 if (opcode
->format
== FMT_D4
)
1517 if (relaxable
&& fc
> 0)
1524 /* Handle bra specially. Basically treat it like jmp so
1525 that we automatically handle 8, 16 and 32 bit offsets
1526 correctly as well as jumps to an undefined address.
1528 It is also important to not treat it like other bCC
1529 instructions since the long forms of bra is different
1530 from other bCC instructions. */
1531 if (opcode
->opcode
== 0xca00)
1543 else if (size
== 3 && opcode
->opcode
== 0xcc0000)
1545 /* bCC (uncommon cases) */
1549 f
= frag_var (rs_machine_dependent
, 8, 8 - size
, type
,
1550 fixups
[0].exp
.X_add_symbol
,
1551 fixups
[0].exp
.X_add_number
,
1552 (char *)fixups
[0].opindex
);
1554 /* This is pretty hokey. We basically just care about the
1555 opcode, so we have to write out the first word big endian.
1557 The exception is "call", which has two operands that we
1560 The first operand (the register list) happens to be in the
1561 first instruction word, and will be in the right place if
1562 we output the first word in big endian mode.
1564 The second operand (stack size) is in the extension word,
1565 and we want it to appear as the first character in the extension
1566 word (as it appears in memory). Luckily, writing the extension
1567 word in big endian format will do what we want. */
1568 number_to_chars_bigendian (f
, insn
, size
> 4 ? 4 : size
);
1571 number_to_chars_bigendian (f
+ 4, extension
, 4);
1572 number_to_chars_bigendian (f
+ 8, 0, size
- 8);
1575 number_to_chars_bigendian (f
+ 4, extension
, size
- 4);
1579 /* Allocate space for the instruction. */
1580 f
= frag_more (size
);
1582 /* Fill in bytes for the instruction. Note that opcode fields
1583 are written big-endian, 16 & 32bit immediates are written
1584 little endian. Egad. */
1585 if (opcode
->format
== FMT_S0
1586 || opcode
->format
== FMT_S1
1587 || opcode
->format
== FMT_D0
1588 || opcode
->format
== FMT_D6
1589 || opcode
->format
== FMT_D7
1590 || opcode
->format
== FMT_D10
1591 || opcode
->format
== FMT_D1
)
1593 number_to_chars_bigendian (f
, insn
, size
);
1595 else if (opcode
->format
== FMT_S2
1596 && opcode
->opcode
!= 0xdf0000
1597 && opcode
->opcode
!= 0xde0000)
1599 /* A format S2 instruction that is _not_ "ret" and "retf". */
1600 number_to_chars_bigendian (f
, (insn
>> 16) & 0xff, 1);
1601 number_to_chars_littleendian (f
+ 1, insn
& 0xffff, 2);
1603 else if (opcode
->format
== FMT_S2
)
1605 /* This must be a ret or retf, which is written entirely in
1606 big-endian format. */
1607 number_to_chars_bigendian (f
, insn
, 3);
1609 else if (opcode
->format
== FMT_S4
1610 && opcode
->opcode
!= 0xdc000000)
1612 /* This must be a format S4 "call" instruction. What a pain. */
1613 unsigned long temp
= (insn
>> 8) & 0xffff;
1614 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1615 number_to_chars_littleendian (f
+ 1, temp
, 2);
1616 number_to_chars_bigendian (f
+ 3, insn
& 0xff, 1);
1617 number_to_chars_bigendian (f
+ 4, extension
& 0xff, 1);
1619 else if (opcode
->format
== FMT_S4
)
1621 /* This must be a format S4 "jmp" instruction. */
1622 unsigned long temp
= ((insn
& 0xffffff) << 8) | (extension
& 0xff);
1623 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1624 number_to_chars_littleendian (f
+ 1, temp
, 4);
1626 else if (opcode
->format
== FMT_S6
)
1628 unsigned long temp
= ((insn
& 0xffffff) << 8)
1629 | ((extension
>> 16) & 0xff);
1630 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
1631 number_to_chars_littleendian (f
+ 1, temp
, 4);
1632 number_to_chars_bigendian (f
+ 5, (extension
>> 8) & 0xff, 1);
1633 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
1635 else if (opcode
->format
== FMT_D2
1636 && opcode
->opcode
!= 0xfaf80000
1637 && opcode
->opcode
!= 0xfaf00000
1638 && opcode
->opcode
!= 0xfaf40000)
1640 /* A format D2 instruction where the 16bit immediate is
1641 really a single 16bit value, not two 8bit values. */
1642 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1643 number_to_chars_littleendian (f
+ 2, insn
& 0xffff, 2);
1645 else if (opcode
->format
== FMT_D2
)
1647 /* A format D2 instruction where the 16bit immediate
1648 is really two 8bit immediates. */
1649 number_to_chars_bigendian (f
, insn
, 4);
1651 else if (opcode
->format
== FMT_D4
)
1653 unsigned long temp
= ((insn
& 0xffff) << 16) | (extension
& 0xffff);
1655 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1656 number_to_chars_littleendian (f
+ 2, temp
, 4);
1658 else if (opcode
->format
== FMT_D5
)
1660 unsigned long temp
= (((insn
& 0xffff) << 16)
1661 | ((extension
>> 8) & 0xffff));
1663 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
1664 number_to_chars_littleendian (f
+ 2, temp
, 4);
1665 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
1667 else if (opcode
->format
== FMT_D8
)
1669 unsigned long temp
= ((insn
& 0xff) << 16) | (extension
& 0xffff);
1671 number_to_chars_bigendian (f
, (insn
>> 8) & 0xffffff, 3);
1672 number_to_chars_bigendian (f
+ 3, (temp
& 0xff), 1);
1673 number_to_chars_littleendian (f
+ 4, temp
>> 8, 2);
1675 else if (opcode
->format
== FMT_D9
)
1677 unsigned long temp
= ((insn
& 0xff) << 24) | (extension
& 0xffffff);
1679 number_to_chars_bigendian (f
, (insn
>> 8) & 0xffffff, 3);
1680 number_to_chars_littleendian (f
+ 3, temp
, 4);
1683 /* Create any fixups. */
1684 for (i
= 0; i
< fc
; i
++)
1686 const struct mn10300_operand
*operand
;
1688 operand
= &mn10300_operands
[fixups
[i
].opindex
];
1689 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
1691 reloc_howto_type
*reloc_howto
;
1696 reloc_howto
= bfd_reloc_type_lookup (stdoutput
,
1702 size
= bfd_get_reloc_size (reloc_howto
);
1704 if (size
< 1 || size
> 4)
1708 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
,
1709 size
, &fixups
[i
].exp
,
1710 reloc_howto
->pc_relative
,
1715 int reloc
, pcrel
, reloc_size
, offset
;
1718 reloc
= BFD_RELOC_NONE
;
1719 /* How big is the reloc? Remember SPLIT relocs are
1720 implicitly 32bits. */
1721 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
1723 else if ((operand
->flags
& MN10300_OPERAND_24BIT
) != 0)
1726 reloc_size
= operand
->bits
;
1728 /* Is the reloc pc-relative? */
1729 pcrel
= (operand
->flags
& MN10300_OPERAND_PCREL
) != 0;
1731 /* Gross. This disgusting hack is to make sure we
1732 get the right offset for the 16/32 bit reloc in
1733 "call" instructions. Basically they're a pain
1734 because the reloc isn't at the end of the instruction. */
1735 if ((size
== 5 || size
== 7)
1736 && (((insn
>> 24) & 0xff) == 0xcd
1737 || ((insn
>> 24) & 0xff) == 0xdd))
1740 /* Similarly for certain bit instructions which don't
1741 hav their 32bit reloc at the tail of the instruction. */
1743 && (((insn
>> 16) & 0xffff) == 0xfe00
1744 || ((insn
>> 16) & 0xffff) == 0xfe01
1745 || ((insn
>> 16) & 0xffff) == 0xfe02))
1748 offset
= size
- reloc_size
/ 8;
1750 /* Choose a proper BFD relocation type. */
1753 if (reloc_size
== 32)
1754 reloc
= BFD_RELOC_32_PCREL
;
1755 else if (reloc_size
== 16)
1756 reloc
= BFD_RELOC_16_PCREL
;
1757 else if (reloc_size
== 8)
1758 reloc
= BFD_RELOC_8_PCREL
;
1764 if (reloc_size
== 32)
1765 reloc
= BFD_RELOC_32
;
1766 else if (reloc_size
== 16)
1767 reloc
= BFD_RELOC_16
;
1768 else if (reloc_size
== 8)
1769 reloc
= BFD_RELOC_8
;
1774 /* Convert the size of the reloc into what fix_new_exp wants. */
1775 reloc_size
= reloc_size
/ 8;
1776 if (reloc_size
== 8)
1778 else if (reloc_size
== 16)
1780 else if (reloc_size
== 32)
1783 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
,
1784 reloc_size
, &fixups
[i
].exp
, pcrel
,
1785 ((bfd_reloc_code_real_type
) reloc
));
1788 fixP
->fx_offset
+= offset
;
1793 dwarf2_emit_insn (real_size
);
1796 /* If while processing a fixup, a reloc really needs to be created
1797 then it is done here. */
1800 tc_gen_reloc (seg
, fixp
)
1801 asection
*seg ATTRIBUTE_UNUSED
;
1805 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
1807 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
1808 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
1810 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1811 _("reloc %d not supported by object file format"),
1812 (int) fixp
->fx_r_type
);
1815 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1817 if (fixp
->fx_addsy
&& fixp
->fx_subsy
)
1820 if ((S_GET_SEGMENT (fixp
->fx_addsy
) != S_GET_SEGMENT (fixp
->fx_subsy
))
1821 || S_GET_SEGMENT (fixp
->fx_addsy
) == undefined_section
)
1823 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1824 "Difference of symbols in different sections is not supported");
1828 reloc
->sym_ptr_ptr
= (asymbol
**) &bfd_abs_symbol
;
1829 reloc
->addend
= (S_GET_VALUE (fixp
->fx_addsy
)
1830 - S_GET_VALUE (fixp
->fx_subsy
) + fixp
->fx_offset
);
1834 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
1835 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
1836 reloc
->addend
= fixp
->fx_offset
;
1842 md_estimate_size_before_relax (fragp
, seg
)
1846 if (fragp
->fr_subtype
== 0)
1848 if (fragp
->fr_subtype
== 3)
1850 if (fragp
->fr_subtype
== 6)
1852 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1853 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1855 fragp
->fr_subtype
= 7;
1861 if (fragp
->fr_subtype
== 8)
1863 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1864 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1866 fragp
->fr_subtype
= 9;
1872 if (fragp
->fr_subtype
== 10)
1874 if (!S_IS_DEFINED (fragp
->fr_symbol
)
1875 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
))
1877 fragp
->fr_subtype
= 12;
1887 md_pcrel_from (fixp
)
1890 if (fixp
->fx_addsy
!= (symbolS
*) NULL
&& !S_IS_DEFINED (fixp
->fx_addsy
))
1892 /* The symbol is undefined. Let the linker figure it out. */
1895 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1899 md_apply_fix3 (fixp
, valuep
, seg
)
1904 char *fixpos
= fixp
->fx_where
+ fixp
->fx_frag
->fr_literal
;
1908 assert (fixp
->fx_r_type
< BFD_RELOC_UNUSED
);
1910 /* This should never happen. */
1911 if (seg
->flags
& SEC_ALLOC
)
1914 /* The value we are passed in *valuep includes the symbol values.
1915 Since we are using BFD_ASSEMBLER, if we are doing this relocation
1916 the code in write.c is going to call bfd_install_relocation, which
1917 is also going to use the symbol value. That means that if the
1918 reloc is fully resolved we want to use *valuep since
1919 bfd_install_relocation is not being used.
1921 However, if the reloc is not fully resolved we do not want to use
1922 *valuep, and must use fx_offset instead. However, if the reloc
1923 is PC relative, we do want to use *valuep since it includes the
1924 result of md_pcrel_from. */
1925 if (fixp
->fx_addsy
== (symbolS
*) NULL
|| fixp
->fx_pcrel
)
1928 value
= fixp
->fx_offset
;
1930 /* If the fix is relative to a symbol which is not defined, or not
1931 in the same segment as the fix, we cannot resolve it here. */
1932 if (fixp
->fx_addsy
!= NULL
1933 && (! S_IS_DEFINED (fixp
->fx_addsy
)
1934 || (S_GET_SEGMENT (fixp
->fx_addsy
) != seg
)))
1940 switch (fixp
->fx_r_type
)
1954 case BFD_RELOC_VTABLE_INHERIT
:
1955 case BFD_RELOC_VTABLE_ENTRY
:
1959 case BFD_RELOC_NONE
:
1961 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
1962 _("Bad relocation fixup type (%d)"), fixp
->fx_r_type
);
1965 md_number_to_chars (fixpos
, value
, size
);
1967 /* If a symbol remains, pass the fixup, as a reloc, onto the linker. */
1968 if (fixp
->fx_addsy
== NULL
)
1974 /* Return nonzero if the fixup in FIXP will require a relocation,
1975 even it if appears that the fixup could be completely handled
1979 mn10300_force_relocation (fixp
)
1982 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
1983 || fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
1989 /* Return zero if the fixup in fixp should be left alone and not
1993 mn10300_fix_adjustable (fixp
)
1996 /* Prevent all adjustments to global symbols. */
1997 if (S_IS_EXTERN (fixp
->fx_addsy
) || S_IS_WEAK (fixp
->fx_addsy
))
2000 if (fixp
->fx_r_type
== BFD_RELOC_VTABLE_INHERIT
2001 || fixp
->fx_r_type
== BFD_RELOC_VTABLE_ENTRY
)
2007 /* Insert an operand value into an instruction. */
2010 mn10300_insert_operand (insnp
, extensionp
, operand
, val
, file
, line
, shift
)
2011 unsigned long *insnp
;
2012 unsigned long *extensionp
;
2013 const struct mn10300_operand
*operand
;
2019 /* No need to check 32bit operands for a bit. Note that
2020 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
2021 if (operand
->bits
!= 32
2022 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
2028 bits
= operand
->bits
;
2029 if (operand
->flags
& MN10300_OPERAND_24BIT
)
2032 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
2034 max
= (1 << (bits
- 1)) - 1;
2035 min
= - (1 << (bits
- 1));
2039 max
= (1 << bits
) - 1;
2045 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
2048 _("operand out of range (%s not between %ld and %ld)");
2051 sprint_value (buf
, test
);
2052 if (file
== (char *) NULL
)
2053 as_warn (err
, buf
, min
, max
);
2055 as_warn_where (file
, line
, err
, buf
, min
, max
);
2059 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
2061 *insnp
|= (val
>> (32 - operand
->bits
)) & ((1 << operand
->bits
) - 1);
2062 *extensionp
|= ((val
& ((1 << (32 - operand
->bits
)) - 1))
2065 else if ((operand
->flags
& MN10300_OPERAND_24BIT
) != 0)
2067 *insnp
|= (val
>> (24 - operand
->bits
)) & ((1 << operand
->bits
) - 1);
2068 *extensionp
|= ((val
& ((1 << (24 - operand
->bits
)) - 1))
2071 else if ((operand
->flags
& MN10300_OPERAND_EXTENDED
) == 0)
2073 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2074 << (operand
->shift
+ shift
));
2076 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
2077 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2078 << (operand
->shift
+ shift
+ operand
->bits
));
2082 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2083 << (operand
->shift
+ shift
));
2085 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
2086 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
2087 << (operand
->shift
+ shift
+ operand
->bits
));
2091 static unsigned long
2092 check_operand (insn
, operand
, val
)
2093 unsigned long insn ATTRIBUTE_UNUSED
;
2094 const struct mn10300_operand
*operand
;
2097 /* No need to check 32bit operands for a bit. Note that
2098 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
2099 if (operand
->bits
!= 32
2100 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
2106 bits
= operand
->bits
;
2107 if (operand
->flags
& MN10300_OPERAND_24BIT
)
2110 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
2112 max
= (1 << (bits
- 1)) - 1;
2113 min
= - (1 << (bits
- 1));
2117 max
= (1 << bits
) - 1;
2123 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
2132 set_arch_mach (mach
)
2135 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_mn10300
, mach
))
2136 as_warn (_("could not set architecture and machine"));
2138 current_machine
= mach
;