1 /* tc-mn10300.c -- Assembler code for the Matsushita 10300
3 Copyright (C) 1996 Free Software Foundation.
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"
28 /* Structure to hold information about predefined registers. */
35 /* Generic assembler global variables which must be defined by all targets. */
37 /* Characters which always start a comment. */
38 const char comment_chars
[] = "#";
40 /* Characters which start a comment at the beginning of a line. */
41 const char line_comment_chars
[] = ";#";
43 /* Characters which may be used to separate multiple commands on a
45 const char line_separator_chars
[] = ";";
47 /* Characters which are used to indicate an exponent in a floating
49 const char EXP_CHARS
[] = "eE";
51 /* Characters which mean that a number is a floating point constant,
53 const char FLT_CHARS
[] = "dD";
57 static void mn10300_insert_operand
PARAMS ((unsigned long *, unsigned long *,
58 const struct mn10300_operand
*,
59 offsetT
, char *, unsigned,
61 static unsigned long check_operand
PARAMS ((unsigned long,
62 const struct mn10300_operand
*,
64 static int reg_name_search
PARAMS ((const struct reg_name
*, int, const char *));
65 static boolean data_register_name
PARAMS ((expressionS
*expressionP
));
66 static boolean address_register_name
PARAMS ((expressionS
*expressionP
));
67 static boolean other_register_name
PARAMS ((expressionS
*expressionP
));
71 #define MAX_INSN_FIXUPS (5)
76 bfd_reloc_code_real_type reloc
;
78 struct mn10300_fixup fixups
[MAX_INSN_FIXUPS
];
81 const char *md_shortopts
= "";
82 struct option md_longopts
[] = {
83 {NULL
, no_argument
, NULL
, 0}
85 size_t md_longopts_size
= sizeof(md_longopts
);
87 /* The target specific pseudo-ops which we support. */
88 const pseudo_typeS md_pseudo_table
[] =
93 /* Opcode hash table. */
94 static struct hash_control
*mn10300_hash
;
96 /* This table is sorted. Suitable for searching by a binary search. */
97 static const struct reg_name data_registers
[] =
104 #define DATA_REG_NAME_CNT (sizeof(data_registers) / sizeof(struct reg_name))
106 static const struct reg_name address_registers
[] =
113 #define ADDRESS_REG_NAME_CNT (sizeof(address_registers) / sizeof(struct reg_name))
115 static const struct reg_name other_registers
[] =
121 #define OTHER_REG_NAME_CNT (sizeof(other_registers) / sizeof(struct reg_name))
123 /* reg_name_search does a binary search of the given register table
124 to see if "name" is a valid regiter name. Returns the register
125 number from the array on success, or -1 on failure. */
128 reg_name_search (regs
, regcount
, name
)
129 const struct reg_name
*regs
;
133 int middle
, low
, high
;
141 middle
= (low
+ high
) / 2;
142 cmp
= strcasecmp (name
, regs
[middle
].name
);
148 return regs
[middle
].value
;
155 /* Summary of register_name().
157 * in: Input_line_pointer points to 1st char of operand.
159 * out: A expressionS.
160 * The operand may have been a register: in this case, X_op == O_register,
161 * X_add_number is set to the register number, and truth is returned.
162 * Input_line_pointer->(next non-blank) char after operand, or is in
163 * its original state.
166 data_register_name (expressionP
)
167 expressionS
*expressionP
;
174 /* Find the spelling of the operand */
175 start
= name
= input_line_pointer
;
177 c
= get_symbol_end ();
178 reg_number
= reg_name_search (data_registers
, DATA_REG_NAME_CNT
, name
);
180 /* look to see if it's in the register table */
183 expressionP
->X_op
= O_register
;
184 expressionP
->X_add_number
= reg_number
;
186 /* make the rest nice */
187 expressionP
->X_add_symbol
= NULL
;
188 expressionP
->X_op_symbol
= NULL
;
189 *input_line_pointer
= c
; /* put back the delimiting char */
194 /* reset the line as if we had not done anything */
195 *input_line_pointer
= c
; /* put back the delimiting char */
196 input_line_pointer
= start
; /* reset input_line pointer */
201 /* Summary of register_name().
203 * in: Input_line_pointer points to 1st char of operand.
205 * out: A expressionS.
206 * The operand may have been a register: in this case, X_op == O_register,
207 * X_add_number is set to the register number, and truth is returned.
208 * Input_line_pointer->(next non-blank) char after operand, or is in
209 * its original state.
212 address_register_name (expressionP
)
213 expressionS
*expressionP
;
220 /* Find the spelling of the operand */
221 start
= name
= input_line_pointer
;
223 c
= get_symbol_end ();
224 reg_number
= reg_name_search (address_registers
, ADDRESS_REG_NAME_CNT
, name
);
226 /* look to see if it's in the register table */
229 expressionP
->X_op
= O_register
;
230 expressionP
->X_add_number
= reg_number
;
232 /* make the rest nice */
233 expressionP
->X_add_symbol
= NULL
;
234 expressionP
->X_op_symbol
= NULL
;
235 *input_line_pointer
= c
; /* put back the delimiting char */
240 /* reset the line as if we had not done anything */
241 *input_line_pointer
= c
; /* put back the delimiting char */
242 input_line_pointer
= start
; /* reset input_line pointer */
247 /* Summary of register_name().
249 * in: Input_line_pointer points to 1st char of operand.
251 * out: A expressionS.
252 * The operand may have been a register: in this case, X_op == O_register,
253 * X_add_number is set to the register number, and truth is returned.
254 * Input_line_pointer->(next non-blank) char after operand, or is in
255 * its original state.
258 other_register_name (expressionP
)
259 expressionS
*expressionP
;
266 /* Find the spelling of the operand */
267 start
= name
= input_line_pointer
;
269 c
= get_symbol_end ();
270 reg_number
= reg_name_search (other_registers
, OTHER_REG_NAME_CNT
, name
);
272 /* look to see if it's in the register table */
275 expressionP
->X_op
= O_register
;
276 expressionP
->X_add_number
= reg_number
;
278 /* make the rest nice */
279 expressionP
->X_add_symbol
= NULL
;
280 expressionP
->X_op_symbol
= NULL
;
281 *input_line_pointer
= c
; /* put back the delimiting char */
286 /* reset the line as if we had not done anything */
287 *input_line_pointer
= c
; /* put back the delimiting char */
288 input_line_pointer
= start
; /* reset input_line pointer */
294 md_show_usage (stream
)
297 fprintf(stream
, "MN10300 options:\n\
302 md_parse_option (c
, arg
)
310 md_undefined_symbol (name
)
317 md_atof (type
, litp
, sizep
)
323 LITTLENUM_TYPE words
[4];
339 return "bad call to md_atof";
342 t
= atof_ieee (input_line_pointer
, type
, words
);
344 input_line_pointer
= t
;
348 for (i
= prec
- 1; i
>= 0; i
--)
350 md_number_to_chars (litp
, (valueT
) words
[i
], 2);
359 md_convert_frag (abfd
, sec
, fragP
)
364 /* printf ("call to md_convert_frag \n"); */
369 md_section_align (seg
, addr
)
373 int align
= bfd_get_section_alignment (stdoutput
, seg
);
374 return ((addr
+ (1 << align
) - 1) & (-1 << align
));
380 char *prev_name
= "";
381 register const struct mn10300_opcode
*op
;
383 mn10300_hash
= hash_new();
385 /* Insert unique names into hash table. The MN10300 instruction set
386 has many identical opcode names that have different opcodes based
387 on the operands. This hash table then provides a quick index to
388 the first opcode with a particular name in the opcode table. */
390 op
= mn10300_opcodes
;
393 if (strcmp (prev_name
, op
->name
))
395 prev_name
= (char *) op
->name
;
396 hash_insert (mn10300_hash
, op
->name
, (char *) op
);
401 /* This is both a simplification (we don't have to write md_apply_fix)
402 and support for future optimizations (branch shortening and similar
403 stuff in the linker. */
412 struct mn10300_opcode
*opcode
;
413 struct mn10300_opcode
*next_opcode
;
414 const unsigned char *opindex_ptr
;
416 unsigned long insn
, extension
, size
= 0;
421 /* Get the opcode. */
422 for (s
= str
; *s
!= '\0' && ! isspace (*s
); s
++)
427 /* find the first opcode with the proper name */
428 opcode
= (struct mn10300_opcode
*)hash_find (mn10300_hash
, str
);
431 as_bad ("Unrecognized opcode: `%s'", str
);
436 while (isspace (*str
))
439 input_line_pointer
= str
;
443 const char *errmsg
= NULL
;
451 insn
= opcode
->opcode
;
453 for (op_idx
= 1, opindex_ptr
= opcode
->operands
;
455 opindex_ptr
++, op_idx
++)
457 const struct mn10300_operand
*operand
;
460 if (next_opindex
== 0)
462 operand
= &mn10300_operands
[*opindex_ptr
];
466 operand
= &mn10300_operands
[next_opindex
];
472 while (*str
== ' ' || *str
== ',')
475 /* Gather the operand. */
476 hold
= input_line_pointer
;
477 input_line_pointer
= str
;
479 if (operand
->flags
& MN10300_OPERAND_PAREN
)
481 if (*input_line_pointer
!= ')' && *input_line_pointer
!= '(')
483 input_line_pointer
= hold
;
487 input_line_pointer
++;
490 /* See if we can match the operands. */
491 else if (operand
->flags
& MN10300_OPERAND_DREG
)
493 if (!data_register_name (&ex
))
495 input_line_pointer
= hold
;
500 else if (operand
->flags
& MN10300_OPERAND_AREG
)
502 if (!address_register_name (&ex
))
504 input_line_pointer
= hold
;
509 else if (operand
->flags
& MN10300_OPERAND_SP
)
511 char *start
= input_line_pointer
;
512 char c
= get_symbol_end ();
514 if (strcmp (start
, "sp") != 0)
516 *input_line_pointer
= c
;
517 input_line_pointer
= hold
;
521 *input_line_pointer
= c
;
524 else if (operand
->flags
& MN10300_OPERAND_PSW
)
526 char *start
= input_line_pointer
;
527 char c
= get_symbol_end ();
529 if (strcmp (start
, "psw") != 0)
531 *input_line_pointer
= c
;
532 input_line_pointer
= hold
;
536 *input_line_pointer
= c
;
539 else if (operand
->flags
& MN10300_OPERAND_MDR
)
541 char *start
= input_line_pointer
;
542 char c
= get_symbol_end ();
544 if (strcmp (start
, "mdr") != 0)
546 *input_line_pointer
= c
;
547 input_line_pointer
= hold
;
551 *input_line_pointer
= c
;
554 else if (operand
->flags
& MN10300_OPERAND_REG_LIST
)
556 unsigned int value
= 0;
557 if (*input_line_pointer
!= '[')
559 input_line_pointer
= hold
;
565 input_line_pointer
++;
567 /* A null register list can not be specified. */
568 if (*input_line_pointer
== ']')
570 input_line_pointer
= hold
;
575 while (*input_line_pointer
!= ']')
580 if (*input_line_pointer
== ',')
581 input_line_pointer
++;
583 start
= input_line_pointer
;
584 c
= get_symbol_end ();
586 if (strcmp (start
, "d2") == 0)
589 *input_line_pointer
= c
;
591 else if (strcmp (start
, "d3") == 0)
594 *input_line_pointer
= c
;
596 else if (strcmp (start
, "a2") == 0)
599 *input_line_pointer
= c
;
601 else if (strcmp (start
, "a3") == 0)
604 *input_line_pointer
= c
;
606 else if (strcmp (start
, "other") == 0)
609 *input_line_pointer
= c
;
613 input_line_pointer
= hold
;
618 input_line_pointer
++;
619 mn10300_insert_operand (&insn
, &extension
, operand
,
620 value
, (char *) NULL
, 0, 0);
624 else if (data_register_name (&ex
))
626 input_line_pointer
= hold
;
630 else if (address_register_name (&ex
))
632 input_line_pointer
= hold
;
636 else if (other_register_name (&ex
))
638 input_line_pointer
= hold
;
642 else if (*str
== ')' || *str
== '(')
644 input_line_pointer
= hold
;
656 errmsg
= "illegal operand";
659 errmsg
= "missing operand";
663 & (MN10300_OPERAND_DREG
| MN10300_OPERAND_AREG
)) == 0)
665 input_line_pointer
= hold
;
670 if (opcode
->format
== FMT_D1
|| opcode
->format
== FMT_S1
)
672 else if (opcode
->format
== FMT_D2
|| opcode
->format
== FMT_D4
673 || opcode
->format
== FMT_S2
|| opcode
->format
== FMT_S4
674 || opcode
->format
== FMT_S6
|| opcode
->format
== FMT_D5
)
679 mn10300_insert_operand (&insn
, &extension
, operand
,
680 ex
.X_add_number
, (char *) NULL
,
686 /* If this operand can be promoted, and it doesn't
687 fit into the allocated bitfield for this insn,
688 then promote it (ie this opcode does not match). */
689 if (operand
->flags
& MN10300_OPERAND_PROMOTE
690 && ! check_operand (insn
, operand
, ex
.X_add_number
))
692 input_line_pointer
= hold
;
697 mn10300_insert_operand (&insn
, &extension
, operand
,
698 ex
.X_add_number
, (char *) NULL
,
703 /* If this operand can be promoted, then this opcode didn't
704 match since we can't know if it needed promotion! */
705 if (operand
->flags
& MN10300_OPERAND_PROMOTE
)
707 input_line_pointer
= hold
;
712 /* We need to generate a fixup for this expression. */
713 if (fc
>= MAX_INSN_FIXUPS
)
714 as_fatal ("too many fixups");
716 fixups
[fc
].opindex
= *opindex_ptr
;
717 fixups
[fc
].reloc
= BFD_RELOC_UNUSED
;
723 str
= input_line_pointer
;
724 input_line_pointer
= hold
;
726 while (*str
== ' ' || *str
== ',')
731 /* Make sure we used all the operands! */
738 next_opcode
= opcode
+ 1;
739 if (!strcmp(next_opcode
->name
, opcode
->name
))
741 opcode
= next_opcode
;
745 as_bad ("%s", errmsg
);
751 while (isspace (*str
))
755 as_bad ("junk at end of line: `%s'", str
);
757 input_line_pointer
= str
;
759 /* Determine the size of the instruction. */
760 if (opcode
->format
== FMT_S0
)
763 if (opcode
->format
== FMT_S1
|| opcode
->format
== FMT_D0
)
766 if (opcode
->format
== FMT_S2
|| opcode
->format
== FMT_D1
)
769 if (opcode
->format
== FMT_S4
)
772 if (opcode
->format
== FMT_S6
|| opcode
->format
== FMT_D5
)
775 if (opcode
->format
== FMT_D2
)
778 if (opcode
->format
== FMT_D4
)
781 /* Allocate space for the instruction. */
782 f
= frag_more (size
);
784 /* Fill in bytes for the instruction. Note that opcode fields
785 are written big-endian, 16 & 32bit immediates are written
786 little endian. Egad. */
787 if (opcode
->format
== FMT_S0
788 || opcode
->format
== FMT_S1
789 || opcode
->format
== FMT_D0
790 || opcode
->format
== FMT_D1
)
792 number_to_chars_bigendian (f
, insn
, size
);
794 else if (opcode
->format
== FMT_S2
795 && opcode
->opcode
!= 0xdf0000
796 && opcode
->opcode
!= 0xde0000)
798 /* A format S2 instruction that is _not_ "ret" and "retf". */
799 number_to_chars_bigendian (f
, (insn
>> 16) & 0xff, 1);
800 number_to_chars_littleendian (f
+ 1, insn
& 0xffff, 2);
802 else if (opcode
->format
== FMT_S2
)
804 /* This must be a ret or retf, which is written entirely in big-endian
806 number_to_chars_bigendian (f
, insn
, 3);
808 else if (opcode
->format
== FMT_S4
809 && opcode
->opcode
!= 0xdc000000)
811 /* This must be a format S4 "call" instruction. What a pain. */
812 unsigned long temp
= (insn
>> 8) & 0xffff;
813 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
814 number_to_chars_littleendian (f
+ 1, temp
, 2);
815 number_to_chars_bigendian (f
+ 3, insn
& 0xff, 1);
816 number_to_chars_bigendian (f
+ 4, extension
& 0xff, 1);
818 else if (opcode
->format
== FMT_S4
)
820 /* This must be a format S4 "jmp" instruction. */
821 unsigned long temp
= ((insn
& 0xffffff) << 8) | (extension
& 0xff);
822 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
823 number_to_chars_littleendian (f
+ 1, temp
, 4);
825 else if (opcode
->format
== FMT_S6
)
827 unsigned long temp
= ((insn
& 0xffffff) << 8)
828 | ((extension
>> 16) & 0xff);
829 number_to_chars_bigendian (f
, (insn
>> 24) & 0xff, 1);
830 number_to_chars_littleendian (f
+ 1, temp
, 4);
831 number_to_chars_bigendian (f
+ 5, (extension
>> 8) & 0xff, 1);
832 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
834 else if (opcode
->format
== FMT_D2
835 && opcode
->opcode
!= 0xfaf80000
836 && opcode
->opcode
!= 0xfaf00000
837 && opcode
->opcode
!= 0xfaf40000)
839 /* A format D2 instruction where the 16bit immediate is
840 really a single 16bit value, not two 8bit values. */
841 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
842 number_to_chars_littleendian (f
+ 2, insn
& 0xffff, 2);
844 else if (opcode
->format
== FMT_D2
)
846 /* A format D2 instruction where the 16bit immediate
847 is really two 8bit immediates. */
848 number_to_chars_bigendian (f
, insn
, 4);
850 else if (opcode
->format
== FMT_D4
)
852 unsigned long temp
= ((insn
& 0xffff) << 16) | (extension
& 0xffff);
853 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
854 number_to_chars_littleendian (f
+ 2, temp
, 4);
856 else if (opcode
->format
== FMT_D5
)
858 unsigned long temp
= ((insn
& 0xffff) << 16) | ((extension
>> 8) & 0xffff);
859 number_to_chars_bigendian (f
, (insn
>> 16) & 0xffff, 2);
860 number_to_chars_littleendian (f
+ 2, temp
, 4);
861 number_to_chars_bigendian (f
+ 6, extension
& 0xff, 1);
864 /* Create any fixups. */
865 for (i
= 0; i
< fc
; i
++)
867 const struct mn10300_operand
*operand
;
869 operand
= &mn10300_operands
[fixups
[i
].opindex
];
870 if (fixups
[i
].reloc
!= BFD_RELOC_UNUSED
)
872 reloc_howto_type
*reloc_howto
;
877 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, fixups
[i
].reloc
);
882 size
= bfd_get_reloc_size (reloc_howto
);
884 if (size
< 1 || size
> 4)
888 fixP
= fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
, size
,
890 reloc_howto
->pc_relative
,
895 int reloc
, pcrel
, reloc_size
, offset
;
897 reloc
= BFD_RELOC_NONE
;
898 /* How big is the reloc? Remember SPLIT relocs are
899 implicitly 32bits. */
900 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
903 reloc_size
= operand
->bits
;
905 /* Is the reloc pc-relative? */
906 pcrel
= (operand
->flags
& MN10300_OPERAND_PCREL
) != 0;
908 /* Gross. This disgusting hack is to make sure we
909 get the right offset for the 16/32 bit reloc in
910 "call" instructions. Basically they're a pain
911 because the reloc isn't at the end of the instruction. */
912 if ((size
== 5 || size
== 7)
913 && (((insn
>> 24) & 0xff) == 0xcd
914 || ((insn
>> 24) & 0xff) == 0xdd))
917 /* Similarly for certain bit instructions which don't
918 hav their 32bit reloc at the tail of the instruction. */
920 && (((insn
>> 16) & 0xffff) == 0xfe00
921 || ((insn
>> 16) & 0xffff) == 0xfe01
922 || ((insn
>> 16) & 0xffff) == 0xfe02))
925 offset
= size
- reloc_size
/ 8;
927 /* Choose a proper BFD relocation type. */
931 reloc
= BFD_RELOC_MN10300_32_PCREL
;
933 reloc
= BFD_RELOC_MN10300_16_PCREL
;
934 else if (reloc_size
== 32)
935 reloc
= BFD_RELOC_32_PCREL
;
936 else if (reloc_size
== 16)
937 reloc
= BFD_RELOC_16_PCREL
;
938 else if (reloc_size
== 8)
939 reloc
= BFD_RELOC_8_PCREL
;
945 if (reloc_size
== 32)
947 else if (reloc_size
== 16)
949 else if (reloc_size
== 8)
955 /* Convert the size of the reloc into what fix_new_exp wants. */
956 reloc_size
= reloc_size
/ 8;
959 else if (reloc_size
== 16)
961 else if (reloc_size
== 32)
964 fix_new_exp (frag_now
, f
- frag_now
->fr_literal
+ offset
, reloc_size
,
965 &fixups
[i
].exp
, pcrel
,
966 ((bfd_reloc_code_real_type
) reloc
));
972 /* if while processing a fixup, a reloc really needs to be created */
973 /* then it is done here */
976 tc_gen_reloc (seg
, fixp
)
981 reloc
= (arelent
*) bfd_alloc_by_size_t (stdoutput
, sizeof (arelent
));
982 reloc
->sym_ptr_ptr
= &fixp
->fx_addsy
->bsym
;
983 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
984 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
985 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
987 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
988 "reloc %d not supported by object file format", (int)fixp
->fx_r_type
);
991 reloc
->addend
= fixp
->fx_offset
;
992 /* printf("tc_gen_reloc: addr=%x addend=%x\n", reloc->address, reloc->addend); */
997 md_estimate_size_before_relax (fragp
, seg
)
1005 md_pcrel_from (fixp
)
1008 return fixp
->fx_frag
->fr_address
;
1010 if (fixp
->fx_addsy
!= (symbolS
*) NULL
&& ! S_IS_DEFINED (fixp
->fx_addsy
))
1012 /* The symbol is undefined. Let the linker figure it out. */
1015 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
1020 md_apply_fix3 (fixp
, valuep
, seg
)
1025 /* We shouldn't ever get here because linkrelax is nonzero. */
1031 /* Insert an operand value into an instruction. */
1034 mn10300_insert_operand (insnp
, extensionp
, operand
, val
, file
, line
, shift
)
1035 unsigned long *insnp
;
1036 unsigned long *extensionp
;
1037 const struct mn10300_operand
*operand
;
1043 /* No need to check 32bit operands for a bit. Note that
1044 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
1045 if (operand
->bits
!= 32
1046 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
1051 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
1053 max
= (1 << (operand
->bits
- 1)) - 1;
1054 min
= - (1 << (operand
->bits
- 1));
1058 max
= (1 << operand
->bits
) - 1;
1065 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)
1068 "operand out of range (%s not between %ld and %ld)";
1071 sprint_value (buf
, test
);
1072 if (file
== (char *) NULL
)
1073 as_warn (err
, buf
, min
, max
);
1075 as_warn_where (file
, line
, err
, buf
, min
, max
);
1079 if ((operand
->flags
& MN10300_OPERAND_SPLIT
) != 0)
1081 *insnp
|= (val
>> (32 - operand
->bits
)) & ((1 << operand
->bits
) - 1);
1082 *extensionp
|= ((val
& ((1 << (32 - operand
->bits
)) - 1))
1085 else if ((operand
->flags
& MN10300_OPERAND_EXTENDED
) == 0)
1087 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
1088 << (operand
->shift
+ shift
));
1090 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
1091 *insnp
|= (((long) val
& ((1 << operand
->bits
) - 1))
1092 << (operand
->shift
+ shift
+ 2));
1096 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
1097 << (operand
->shift
+ shift
));
1099 if ((operand
->flags
& MN10300_OPERAND_REPEATED
) != 0)
1100 *extensionp
|= (((long) val
& ((1 << operand
->bits
) - 1))
1101 << (operand
->shift
+ shift
+ 2));
1105 static unsigned long
1106 check_operand (insn
, operand
, val
)
1108 const struct mn10300_operand
*operand
;
1111 /* No need to check 32bit operands for a bit. Note that
1112 MN10300_OPERAND_SPLIT is an implicit 32bit operand. */
1113 if (operand
->bits
!= 32
1114 && (operand
->flags
& MN10300_OPERAND_SPLIT
) == 0)
1119 if ((operand
->flags
& MN10300_OPERAND_SIGNED
) != 0)
1121 max
= (1 << (operand
->bits
- 1)) - 1;
1122 min
= - (1 << (operand
->bits
- 1));
1126 max
= (1 << operand
->bits
) - 1;
1133 if (test
< (offsetT
) min
|| test
> (offsetT
) max
)