1 /* tc-cr16.c -- Assembler code for the CR16 CPU core.
2 Copyright 2007, 2008, 2009, 2010, 2011
3 Free Software Foundation, Inc.
5 Contributed by M R Swami Reddy <MR.Swami.Reddy@nsc.com>
7 This file is part of GAS, the GNU Assembler.
9 GAS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
14 GAS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GAS; see the file COPYING. If not, write to the
21 Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
25 #include "safe-ctype.h"
26 #include "dwarf2dbg.h"
27 #include "opcode/cr16.h"
31 /* Word is considered here as a 16-bit unsigned short int. */
34 /* Register is 2-byte size. */
37 /* Maximum size of a single instruction (in words). */
38 #define INSN_MAX_SIZE 3
40 /* Maximum bits which may be set in a `mask16' operand. */
41 #define MAX_REGS_IN_MASK16 8
43 /* Assign a number NUM, shifted by SHIFT bytes, into a location
44 pointed by index BYTE of array 'output_opcode'. */
45 #define CR16_PRINT(BYTE, NUM, SHIFT) output_opcode[BYTE] |= (NUM << SHIFT)
50 OP_LEGAL
= 0, /* Legal operand. */
51 OP_OUT_OF_RANGE
, /* Operand not within permitted range. */
52 OP_NOT_EVEN
/* Operand is Odd number, should be even. */
56 /* Opcode mnemonics hash table. */
57 static struct hash_control
*cr16_inst_hash
;
58 /* CR16 registers hash table. */
59 static struct hash_control
*reg_hash
;
60 /* CR16 register pair hash table. */
61 static struct hash_control
*regp_hash
;
62 /* CR16 processor registers hash table. */
63 static struct hash_control
*preg_hash
;
64 /* CR16 processor registers 32 bit hash table. */
65 static struct hash_control
*pregp_hash
;
66 /* Current instruction we're assembling. */
67 const inst
*instruction
;
70 static int code_label
= 0;
72 /* Global variables. */
74 /* Array to hold an instruction encoding. */
75 long output_opcode
[2];
77 /* Nonzero means a relocatable symbol. */
80 /* A copy of the original instruction (used in error messages). */
81 char ins_parse
[MAX_INST_LEN
];
83 /* The current processed argument number. */
86 /* Generic assembler global variables which must be defined by all targets. */
88 /* Characters which always start a comment. */
89 const char comment_chars
[] = "#";
91 /* Characters which start a comment at the beginning of a line. */
92 const char line_comment_chars
[] = "#";
94 /* This array holds machine specific line separator characters. */
95 const char line_separator_chars
[] = ";";
97 /* Chars that can be used to separate mant from exp in floating point nums. */
98 const char EXP_CHARS
[] = "eE";
100 /* Chars that mean this number is a floating point constant as in 0f12.456 */
101 const char FLT_CHARS
[] = "f'";
104 /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */
105 symbolS
* GOT_symbol
;
108 /* Target-specific multicharacter options, not const-declared at usage. */
109 const char *md_shortopts
= "";
110 struct option md_longopts
[] =
112 {NULL
, no_argument
, NULL
, 0}
114 size_t md_longopts_size
= sizeof (md_longopts
);
122 #ifdef md_flush_pending_output
123 md_flush_pending_output ();
126 if (is_it_end_of_statement ())
128 demand_empty_rest_of_line ();
132 #ifdef TC_ADDRESS_BYTES
134 nbytes
= TC_ADDRESS_BYTES ();
138 md_cons_align (nbytes
);
144 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
145 char *hold
= input_line_pointer
;
149 if (*input_line_pointer
== ':')
158 if (*input_line_pointer
!= ':')
160 input_line_pointer
= hold
;
163 if (exp
.X_op
== O_absent
)
165 as_warn (_("using a bit field width of zero"));
166 exp
.X_add_number
= 0;
167 exp
.X_op
= O_constant
;
170 if (exp
.X_op
!= O_constant
)
172 *input_line_pointer
= '\0';
173 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
174 *input_line_pointer
= ':';
175 demand_empty_rest_of_line ();
179 if ((width
= exp
.X_add_number
) >
180 (unsigned int)(BITS_PER_CHAR
* nbytes
))
182 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"), width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
183 width
= BITS_PER_CHAR
* nbytes
;
187 if (width
> bits_available
)
189 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
190 input_line_pointer
= hold
;
191 exp
.X_add_number
= value
;
196 hold
= ++input_line_pointer
;
199 if (exp
.X_op
!= O_constant
)
201 char cache
= *input_line_pointer
;
203 *input_line_pointer
= '\0';
204 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
205 *input_line_pointer
= cache
;
206 demand_empty_rest_of_line ();
210 value
|= ((~(-1 << width
) & exp
.X_add_number
)
211 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
213 if ((bits_available
-= width
) == 0
214 || is_it_end_of_statement ()
215 || *input_line_pointer
!= ',')
218 hold
= ++input_line_pointer
;
222 exp
.X_add_number
= value
;
223 exp
.X_op
= O_constant
;
227 if ((*(input_line_pointer
) == '@') && (*(input_line_pointer
+1) == 'c'))
229 emit_expr (&exp
, (unsigned int) nbytes
);
231 if ((*(input_line_pointer
) == '@') && (*(input_line_pointer
+1) == 'c'))
233 input_line_pointer
+=3;
237 while ((*input_line_pointer
++ == ','));
239 /* Put terminator back into stream. */
240 input_line_pointer
--;
242 demand_empty_rest_of_line ();
245 /* This table describes all the machine specific pseudo-ops
246 the assembler has to support. The fields are:
247 *** Pseudo-op name without dot.
248 *** Function to call to execute this pseudo-op.
249 *** Integer arg to pass to the function. */
251 const pseudo_typeS md_pseudo_table
[] =
253 /* In CR16 machine, align is in bytes (not a ptwo boundary). */
254 {"align", s_align_bytes
, 0},
255 {"long", l_cons
, 4 },
256 {"4byte", l_cons
, 4 },
260 /* CR16 relaxation table. */
261 const relax_typeS md_relax_table
[] =
264 {0x7f, -0x80, 2, 1}, /* 8 */
265 {0xfffe, -0x10000, 4, 2}, /* 16 */
266 {0xfffffe, -0x1000000, 6, 0}, /* 24 */
269 /* Return the bit size for a given operand. */
272 get_opbits (operand_type op
)
275 return cr16_optab
[op
].bit_size
;
280 /* Return the argument type of a given operand. */
283 get_optype (operand_type op
)
286 return cr16_optab
[op
].arg_type
;
291 /* Return the flags of a given operand. */
294 get_opflags (operand_type op
)
297 return cr16_optab
[op
].flags
;
302 /* Get the cc code. */
305 get_cc (char *cc_name
)
309 for (i
= 0; i
< cr16_num_cc
; i
++)
310 if (strcmp (cc_name
, cr16_b_cond_tab
[i
]) == 0)
316 /* Get the core processor register 'reg_name'. */
319 get_register (char *reg_name
)
321 const reg_entry
*rreg
;
323 rreg
= (const reg_entry
*) hash_find (reg_hash
, reg_name
);
326 return rreg
->value
.reg_val
;
330 /* Get the core processor register-pair 'reg_name'. */
333 get_register_pair (char *reg_name
)
335 const reg_entry
*rreg
;
336 char tmp_rp
[16]="\0";
338 /* Add '(' and ')' to the reg pair, if its not present. */
339 if (reg_name
[0] != '(')
342 strcat (tmp_rp
, reg_name
);
344 rreg
= (const reg_entry
*) hash_find (regp_hash
, tmp_rp
);
347 rreg
= (const reg_entry
*) hash_find (regp_hash
, reg_name
);
350 return rreg
->value
.reg_val
;
355 /* Get the index register 'reg_name'. */
358 get_index_register (char *reg_name
)
360 const reg_entry
*rreg
;
362 rreg
= (const reg_entry
*) hash_find (reg_hash
, reg_name
);
365 && ((rreg
->value
.reg_val
== 12) || (rreg
->value
.reg_val
== 13)))
366 return rreg
->value
.reg_val
;
370 /* Get the core processor index register-pair 'reg_name'. */
373 get_index_register_pair (char *reg_name
)
375 const reg_entry
*rreg
;
377 rreg
= (const reg_entry
*) hash_find (regp_hash
, reg_name
);
381 if ((rreg
->value
.reg_val
!= 1) || (rreg
->value
.reg_val
!= 7)
382 || (rreg
->value
.reg_val
!= 9) || (rreg
->value
.reg_val
> 10))
383 return rreg
->value
.reg_val
;
385 as_bad (_("Unknown register pair - index relative mode: `%d'"), rreg
->value
.reg_val
);
391 /* Get the processor register 'preg_name'. */
394 get_pregister (char *preg_name
)
396 const reg_entry
*prreg
;
398 prreg
= (const reg_entry
*) hash_find (preg_hash
, preg_name
);
401 return prreg
->value
.preg_val
;
403 return nullpregister
;
406 /* Get the processor register 'preg_name 32 bit'. */
409 get_pregisterp (char *preg_name
)
411 const reg_entry
*prreg
;
413 prreg
= (const reg_entry
*) hash_find (pregp_hash
, preg_name
);
416 return prreg
->value
.preg_val
;
418 return nullpregister
;
422 /* Round up a section size to the appropriate boundary. */
425 md_section_align (segT seg
, valueT val
)
427 /* Round .text section to a multiple of 2. */
428 if (seg
== text_section
)
429 return (val
+ 1) & ~1;
433 /* Parse an operand that is machine-specific (remove '*'). */
436 md_operand (expressionS
* exp
)
438 char c
= *input_line_pointer
;
443 input_line_pointer
++;
451 /* Reset global variables before parsing a new instruction. */
454 reset_vars (char *op
)
456 cur_arg_num
= relocatable
= 0;
457 memset (& output_opcode
, '\0', sizeof (output_opcode
));
459 /* Save a copy of the original OP (used in error messages). */
460 strncpy (ins_parse
, op
, sizeof ins_parse
- 1);
461 ins_parse
[sizeof ins_parse
- 1] = 0;
464 /* This macro decides whether a particular reloc is an entry in a
465 switch table. It is used when relaxing, because the linker needs
466 to know about all such entries so that it can adjust them if
469 #define SWITCH_TABLE(fix) \
470 ( (fix)->fx_addsy != NULL \
471 && (fix)->fx_subsy != NULL \
472 && S_GET_SEGMENT ((fix)->fx_addsy) == \
473 S_GET_SEGMENT ((fix)->fx_subsy) \
474 && S_GET_SEGMENT (fix->fx_addsy) != undefined_section \
475 && ( (fix)->fx_r_type == BFD_RELOC_CR16_NUM8 \
476 || (fix)->fx_r_type == BFD_RELOC_CR16_NUM16 \
477 || (fix)->fx_r_type == BFD_RELOC_CR16_NUM32 \
478 || (fix)->fx_r_type == BFD_RELOC_CR16_NUM32a))
480 /* See whether we need to force a relocation into the output file.
481 This is used to force out switch and PC relative relocations when
485 cr16_force_relocation (fixS
*fix
)
487 if (generic_force_reloc (fix
) || SWITCH_TABLE (fix
))
493 /* Record a fixup for a cons expression. */
496 cr16_cons_fix_new (fragS
*frag
, int offset
, int len
, expressionS
*exp
)
498 int rtype
= BFD_RELOC_UNUSED
;
502 default: rtype
= BFD_RELOC_NONE
; break;
503 case 1: rtype
= BFD_RELOC_CR16_NUM8
; break;
504 case 2: rtype
= BFD_RELOC_CR16_NUM16
; break;
508 rtype
= BFD_RELOC_CR16_NUM32a
;
512 rtype
= BFD_RELOC_CR16_NUM32
;
516 fix_new_exp (frag
, offset
, len
, exp
, 0, rtype
);
519 /* Generate a relocation entry for a fixup. */
522 tc_gen_reloc (asection
*section ATTRIBUTE_UNUSED
, fixS
* fixP
)
525 bfd_reloc_code_real_type code
;
527 /* If symbols are local and resolved, then no relocation needed. */
528 if ( ((fixP
->fx_addsy
)
529 && (S_GET_SEGMENT (fixP
->fx_addsy
) == absolute_section
))
531 && (S_GET_SEGMENT (fixP
->fx_subsy
) == absolute_section
)))
534 reloc
= xmalloc (sizeof (arelent
));
535 reloc
->sym_ptr_ptr
= xmalloc (sizeof (asymbol
*));
536 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixP
->fx_addsy
);
537 reloc
->address
= fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
538 reloc
->addend
= fixP
->fx_offset
;
540 if (fixP
->fx_subsy
!= NULL
)
542 if (SWITCH_TABLE (fixP
))
544 /* Keep the current difference in the addend. */
545 reloc
->addend
= (S_GET_VALUE (fixP
->fx_addsy
)
546 - S_GET_VALUE (fixP
->fx_subsy
) + fixP
->fx_offset
);
548 switch (fixP
->fx_r_type
)
550 case BFD_RELOC_CR16_NUM8
:
551 fixP
->fx_r_type
= BFD_RELOC_CR16_SWITCH8
;
553 case BFD_RELOC_CR16_NUM16
:
554 fixP
->fx_r_type
= BFD_RELOC_CR16_SWITCH16
;
556 case BFD_RELOC_CR16_NUM32
:
557 fixP
->fx_r_type
= BFD_RELOC_CR16_SWITCH32
;
559 case BFD_RELOC_CR16_NUM32a
:
560 fixP
->fx_r_type
= BFD_RELOC_CR16_NUM32a
;
569 /* We only resolve difference expressions in the same section. */
570 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
571 _("can't resolve `%s' {%s section} - `%s' {%s section}"),
572 fixP
->fx_addsy
? S_GET_NAME (fixP
->fx_addsy
) : "0",
573 segment_name (fixP
->fx_addsy
574 ? S_GET_SEGMENT (fixP
->fx_addsy
)
576 S_GET_NAME (fixP
->fx_subsy
),
577 segment_name (S_GET_SEGMENT (fixP
->fx_addsy
)));
581 if ((fixP
->fx_r_type
== BFD_RELOC_CR16_GOT_REGREL20
)
583 && fixP
->fx_addsy
== GOT_symbol
)
585 code
= BFD_RELOC_CR16_GOT_REGREL20
;
586 reloc
->addend
= fixP
->fx_offset
= reloc
->address
;
588 else if ((fixP
->fx_r_type
== BFD_RELOC_CR16_GOTC_REGREL20
)
590 && fixP
->fx_addsy
== GOT_symbol
)
592 code
= BFD_RELOC_CR16_GOTC_REGREL20
;
593 reloc
->addend
= fixP
->fx_offset
= reloc
->address
;
597 gas_assert ((int) fixP
->fx_r_type
> 0);
598 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixP
->fx_r_type
);
600 if (reloc
->howto
== NULL
)
602 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
603 _("internal error: reloc %d (`%s') not supported by object file format"),
605 bfd_get_reloc_code_name (fixP
->fx_r_type
));
608 gas_assert (!fixP
->fx_pcrel
== !reloc
->howto
->pc_relative
);
613 /* Prepare machine-dependent frags for relaxation. */
616 md_estimate_size_before_relax (fragS
*fragp
, asection
*seg
)
618 /* If symbol is undefined or located in a different section,
619 select the largest supported relocation. */
620 relax_substateT subtype
;
621 relax_substateT rlx_state
[] = {0, 2};
623 for (subtype
= 0; subtype
< ARRAY_SIZE (rlx_state
); subtype
+= 2)
625 if (fragp
->fr_subtype
== rlx_state
[subtype
]
626 && (!S_IS_DEFINED (fragp
->fr_symbol
)
627 || seg
!= S_GET_SEGMENT (fragp
->fr_symbol
)))
629 fragp
->fr_subtype
= rlx_state
[subtype
+ 1];
634 if (fragp
->fr_subtype
>= ARRAY_SIZE (md_relax_table
))
637 return md_relax_table
[fragp
->fr_subtype
].rlx_length
;
641 md_convert_frag (bfd
*abfd ATTRIBUTE_UNUSED
, asection
*sec
, fragS
*fragP
)
643 /* 'opcode' points to the start of the instruction, whether
644 we need to change the instruction's fixed encoding. */
645 char *opcode
= fragP
->fr_literal
+ fragP
->fr_fix
;
646 bfd_reloc_code_real_type reloc
;
648 subseg_change (sec
, 0);
650 switch (fragP
->fr_subtype
)
653 reloc
= BFD_RELOC_CR16_DISP8
;
656 /* If the subtype is not changed due to :m operand qualifier,
657 then no need to update the opcode value. */
658 if ((int)opcode
[1] != 0x18)
660 opcode
[0] = (opcode
[0] & 0xf0);
663 reloc
= BFD_RELOC_CR16_DISP16
;
666 /* If the subtype is not changed due to :l operand qualifier,
667 then no need to update the opcode value. */
668 if ((int)opcode
[1] != 0)
670 opcode
[2] = opcode
[0];
671 opcode
[0] = opcode
[1];
674 reloc
= BFD_RELOC_CR16_DISP24
;
680 fix_new (fragP
, fragP
->fr_fix
,
681 bfd_get_reloc_size (bfd_reloc_type_lookup (stdoutput
, reloc
)),
682 fragP
->fr_symbol
, fragP
->fr_offset
, 1, reloc
);
684 fragP
->fr_fix
+= md_relax_table
[fragP
->fr_subtype
].rlx_length
;
688 md_undefined_symbol (char *name
)
690 if (*name
== '_' && *(name
+ 1) == 'G'
691 && strcmp (name
, "_GLOBAL_OFFSET_TABLE_") == 0)
695 if (symbol_find (name
))
696 as_bad (_("GOT already in symbol table"));
697 GOT_symbol
= symbol_new (name
, undefined_section
,
698 (valueT
) 0, &zero_address_frag
);
705 /* Process machine-dependent command line options. Called once for
706 each option on the command line that the machine-independent part of
707 GAS does not understand. */
710 md_parse_option (int c ATTRIBUTE_UNUSED
, char *arg ATTRIBUTE_UNUSED
)
715 /* Machine-dependent usage-output. */
718 md_show_usage (FILE *stream ATTRIBUTE_UNUSED
)
724 md_atof (int type
, char *litP
, int *sizeP
)
726 return ieee_md_atof (type
, litP
, sizeP
, target_big_endian
);
729 /* Apply a fixS (fixup of an instruction or data that we didn't have
730 enough info to complete immediately) to the data in a frag.
731 Since linkrelax is nonzero and TC_LINKRELAX_FIXUP is defined to disable
732 relaxation of debug sections, this function is called only when
733 fixuping relocations of debug sections. */
736 md_apply_fix (fixS
*fixP
, valueT
*valP
, segT seg
)
740 if (fixP
->fx_addsy
== NULL
741 && fixP
->fx_pcrel
== 0)
743 else if (fixP
->fx_pcrel
== 1
744 && fixP
->fx_addsy
!= NULL
745 && S_GET_SEGMENT (fixP
->fx_addsy
) == seg
)
750 if (fixP
->fx_addsy
!= NULL
&& !fixP
->fx_pcrel
)
752 val
= fixP
->fx_offset
;
758 char *buf
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
762 switch (fixP
->fx_r_type
)
764 case BFD_RELOC_CR16_NUM8
:
765 bfd_put_8 (stdoutput
, (unsigned char) val
, buf
);
767 case BFD_RELOC_CR16_NUM16
:
768 bfd_put_16 (stdoutput
, val
, buf
);
770 case BFD_RELOC_CR16_NUM32
:
771 bfd_put_32 (stdoutput
, val
, buf
);
773 case BFD_RELOC_CR16_NUM32a
:
774 bfd_put_32 (stdoutput
, val
, buf
);
777 /* We shouldn't ever get here because linkrelax is nonzero. */
784 fixP
->fx_offset
= * valP
;
787 /* The location from which a PC relative jump should be calculated,
788 given a PC relative reloc. */
791 md_pcrel_from (fixS
*fixp
)
793 return fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
797 initialise_reg_hash_table (struct hash_control
** hash_table
,
798 const reg_entry
* register_table
,
799 const unsigned int num_entries
)
801 const reg_entry
* rreg
;
804 if ((* hash_table
= hash_new ()) == NULL
)
805 as_fatal (_("Virtual memory exhausted"));
807 for (rreg
= register_table
;
808 rreg
< (register_table
+ num_entries
);
811 hashret
= hash_insert (* hash_table
, rreg
->name
, (char *) rreg
);
813 as_fatal (_("Internal Error: Can't hash %s: %s"),
814 rreg
->name
, hashret
);
818 /* This function is called once, at assembler startup time. This should
819 set up all the tables, etc that the MD part of the assembler needs. */
826 /* Set up a hash table for the instructions. */
827 if ((cr16_inst_hash
= hash_new ()) == NULL
)
828 as_fatal (_("Virtual memory exhausted"));
830 while (cr16_instruction
[i
].mnemonic
!= NULL
)
833 const char *mnemonic
= cr16_instruction
[i
].mnemonic
;
835 hashret
= hash_insert (cr16_inst_hash
, mnemonic
,
836 (char *)(cr16_instruction
+ i
));
838 if (hashret
!= NULL
&& *hashret
!= '\0')
839 as_fatal (_("Can't hash `%s': %s\n"), cr16_instruction
[i
].mnemonic
,
840 *hashret
== 0 ? _("(unknown reason)") : hashret
);
842 /* Insert unique names into hash table. The CR16 instruction set
843 has many identical opcode names that have different opcodes based
844 on the operands. This hash table then provides a quick index to
845 the first opcode with a particular name in the opcode table. */
850 while (cr16_instruction
[i
].mnemonic
!= NULL
851 && streq (cr16_instruction
[i
].mnemonic
, mnemonic
));
854 /* Initialize reg_hash hash table. */
855 initialise_reg_hash_table (& reg_hash
, cr16_regtab
, NUMREGS
);
856 /* Initialize regp_hash hash table. */
857 initialise_reg_hash_table (& regp_hash
, cr16_regptab
, NUMREGPS
);
858 /* Initialize preg_hash hash table. */
859 initialise_reg_hash_table (& preg_hash
, cr16_pregtab
, NUMPREGS
);
860 /* Initialize pregp_hash hash table. */
861 initialise_reg_hash_table (& pregp_hash
, cr16_pregptab
, NUMPREGPS
);
863 /* Set linkrelax here to avoid fixups in most sections. */
867 /* Process constants (immediate/absolute)
868 and labels (jump targets/Memory locations). */
871 process_label_constant (char *str
, ins
* cr16_ins
)
873 char *saved_input_line_pointer
;
874 int symbol_with_at
= 0;
875 int symbol_with_s
= 0;
876 int symbol_with_m
= 0;
877 int symbol_with_l
= 0;
878 int symbol_with_at_got
= 0;
879 int symbol_with_at_gotc
= 0;
880 argument
*cur_arg
= cr16_ins
->arg
+ cur_arg_num
; /* Current argument. */
882 saved_input_line_pointer
= input_line_pointer
;
883 input_line_pointer
= str
;
885 expression (&cr16_ins
->exp
);
887 switch (cr16_ins
->exp
.X_op
)
891 /* Missing or bad expr becomes absolute 0. */
892 as_bad (_("missing or invalid displacement expression `%s' taken as 0"),
894 cr16_ins
->exp
.X_op
= O_constant
;
895 cr16_ins
->exp
.X_add_number
= 0;
896 cr16_ins
->exp
.X_add_symbol
= NULL
;
897 cr16_ins
->exp
.X_op_symbol
= NULL
;
901 cur_arg
->X_op
= O_constant
;
902 cur_arg
->constant
= cr16_ins
->exp
.X_add_number
;
908 cur_arg
->X_op
= O_symbol
;
909 cur_arg
->constant
= cr16_ins
->exp
.X_add_number
;
910 cr16_ins
->exp
.X_add_number
= 0;
911 cr16_ins
->rtype
= BFD_RELOC_NONE
;
914 if (strneq (input_line_pointer
, "@c", 2))
917 if (strneq (input_line_pointer
, "@l", 2)
918 || strneq (input_line_pointer
, ":l", 2))
921 if (strneq (input_line_pointer
, "@m", 2)
922 || strneq (input_line_pointer
, ":m", 2))
925 if (strneq (input_line_pointer
, "@s", 2)
926 || strneq (input_line_pointer
, ":s", 2))
929 if (strneq (input_line_pointer
, "@cGOT", 5)
930 || strneq (input_line_pointer
, "@cgot", 5))
932 if (GOT_symbol
== NULL
)
933 GOT_symbol
= symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME
);
935 symbol_with_at_gotc
= 1;
937 else if (strneq (input_line_pointer
, "@GOT", 4)
938 || strneq (input_line_pointer
, "@got", 4))
940 if ((strneq (input_line_pointer
, "+", 1))
941 || (strneq (input_line_pointer
, "-", 1)))
942 as_warn (_("GOT bad expression with %s."), input_line_pointer
);
944 if (GOT_symbol
== NULL
)
945 GOT_symbol
= symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME
);
947 symbol_with_at_got
= 1;
950 switch (cur_arg
->type
)
953 if (IS_INSN_TYPE (LD_STOR_INS
) || IS_INSN_TYPE (CSTBIT_INS
))
955 if (symbol_with_at_got
)
956 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
957 else if (symbol_with_at_gotc
)
958 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
959 else if (cur_arg
->size
== 20)
960 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20
;
962 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20a
;
967 if (IS_INSN_TYPE (LD_STOR_INS
) || IS_INSN_TYPE (CSTBIT_INS
))
969 if (symbol_with_at_got
)
970 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
971 else if (symbol_with_at_gotc
)
972 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
974 switch (instruction
->size
)
977 switch (cur_arg
->size
)
980 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL0
;
983 if (IS_INSN_MNEMONIC ("loadb") || IS_INSN_MNEMONIC ("storb"))
984 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL4
;
986 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL4a
;
992 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL16
;
995 if (cur_arg
->size
== 20)
996 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20
;
998 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20a
;
1007 if (IS_INSN_TYPE (LD_STOR_INS
) || IS_INSN_TYPE (CSTBIT_INS
))
1009 if (symbol_with_at_got
)
1010 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
1011 else if (symbol_with_at_gotc
)
1012 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
1014 cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20
;
1019 if (IS_INSN_TYPE (LD_STOR_INS
) || IS_INSN_TYPE (CSTBIT_INS
))
1021 if (symbol_with_at_got
)
1022 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
1023 else if (symbol_with_at_gotc
)
1024 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
1026 switch (instruction
->size
)
1028 case 1: cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL0
; break;
1029 case 2: cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL14
; break;
1030 case 3: cr16_ins
->rtype
= BFD_RELOC_CR16_REGREL20
; break;
1038 if (IS_INSN_MNEMONIC ("bal"))
1039 cr16_ins
->rtype
= BFD_RELOC_CR16_DISP24
;
1040 else if (IS_INSN_TYPE (BRANCH_INS
))
1043 cr16_ins
->rtype
= BFD_RELOC_CR16_DISP24
;
1044 else if (symbol_with_m
)
1045 cr16_ins
->rtype
= BFD_RELOC_CR16_DISP16
;
1047 cr16_ins
->rtype
= BFD_RELOC_CR16_DISP8
;
1049 else if (IS_INSN_TYPE (STOR_IMM_INS
) || IS_INSN_TYPE (LD_STOR_INS
)
1050 || IS_INSN_TYPE (CSTBIT_INS
))
1053 as_bad (_("operand %d: illegal use expression: `%s`"), cur_arg_num
+ 1, str
);
1054 if (symbol_with_at_got
)
1055 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
1056 else if (symbol_with_at_gotc
)
1057 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
1058 else if (symbol_with_m
)
1059 cr16_ins
->rtype
= BFD_RELOC_CR16_ABS20
;
1060 else /* Default to (symbol_with_l) */
1061 cr16_ins
->rtype
= BFD_RELOC_CR16_ABS24
;
1063 else if (IS_INSN_TYPE (BRANCH_NEQ_INS
))
1064 cr16_ins
->rtype
= BFD_RELOC_CR16_DISP4
;
1068 if (IS_INSN_TYPE (ARITH_INS
))
1070 if (symbol_with_at_got
)
1071 cr16_ins
->rtype
= BFD_RELOC_CR16_GOT_REGREL20
;
1072 else if (symbol_with_at_gotc
)
1073 cr16_ins
->rtype
= BFD_RELOC_CR16_GOTC_REGREL20
;
1074 else if (symbol_with_s
)
1075 cr16_ins
->rtype
= BFD_RELOC_CR16_IMM4
;
1076 else if (symbol_with_m
)
1077 cr16_ins
->rtype
= BFD_RELOC_CR16_IMM20
;
1078 else if (symbol_with_at
)
1079 cr16_ins
->rtype
= BFD_RELOC_CR16_IMM32a
;
1080 else /* Default to (symbol_with_l) */
1081 cr16_ins
->rtype
= BFD_RELOC_CR16_IMM32
;
1083 else if (IS_INSN_TYPE (ARITH_BYTE_INS
))
1085 cr16_ins
->rtype
= BFD_RELOC_CR16_IMM16
;
1094 cur_arg
->X_op
= cr16_ins
->exp
.X_op
;
1098 input_line_pointer
= saved_input_line_pointer
;
1102 /* Retrieve the opcode image of a given register.
1103 If the register is illegal for the current instruction,
1107 getreg_image (reg r
)
1109 const reg_entry
*rreg
;
1111 int is_procreg
= 0; /* Nonzero means argument should be processor reg. */
1113 /* Check whether the register is in registers table. */
1115 rreg
= cr16_regtab
+ r
;
1116 else /* Register not found. */
1118 as_bad (_("Unknown register: `%d'"), r
);
1122 reg_name
= rreg
->name
;
1124 /* Issue a error message when register is illegal. */
1126 as_bad (_("Illegal register (`%s') in Instruction: `%s'"), \
1127 reg_name, ins_parse); \
1132 case CR16_R_REGTYPE
:
1138 case CR16_P_REGTYPE
:
1149 /* Parsing different types of operands
1150 -> constants Immediate/Absolute/Relative numbers
1151 -> Labels Relocatable symbols
1152 -> (reg pair base) Register pair base
1153 -> (rbase) Register base
1154 -> disp(rbase) Register relative
1155 -> [rinx]disp(reg pair) Register index with reg pair mode
1156 -> disp(rbase,ridx,scl) Register index mode. */
1159 set_operand (char *operand
, ins
* cr16_ins
)
1161 char *operandS
; /* Pointer to start of sub-opearand. */
1162 char *operandE
; /* Pointer to end of sub-opearand. */
1164 argument
*cur_arg
= &cr16_ins
->arg
[cur_arg_num
]; /* Current argument. */
1166 /* Initialize pointers. */
1167 operandS
= operandE
= operand
;
1169 switch (cur_arg
->type
)
1171 case arg_ic
: /* Case $0x18. */
1173 case arg_c
: /* Case 0x18. */
1175 process_label_constant (operandS
, cr16_ins
);
1177 if (cur_arg
->type
!= arg_ic
)
1178 cur_arg
->type
= arg_c
;
1181 case arg_icr
: /* Case $0x18(r1). */
1183 case arg_cr
: /* Case 0x18(r1). */
1184 /* Set displacement constant. */
1185 while (*operandE
!= '(')
1188 process_label_constant (operandS
, cr16_ins
);
1189 operandS
= operandE
;
1190 case arg_rbase
: /* Case (r1) or (r1,r0). */
1192 /* Set register base. */
1193 while (*operandE
!= ')')
1196 if ((cur_arg
->r
= get_register (operandS
)) == nullregister
)
1197 as_bad (_("Illegal register `%s' in Instruction `%s'"),
1198 operandS
, ins_parse
);
1200 /* set the arg->rp, if reg is "r12" or "r13" or "14" or "15" */
1201 if ((cur_arg
->type
!= arg_rbase
)
1202 && ((getreg_image (cur_arg
->r
) == 12)
1203 || (getreg_image (cur_arg
->r
) == 13)
1204 || (getreg_image (cur_arg
->r
) == 14)
1205 || (getreg_image (cur_arg
->r
) == 15)))
1207 cur_arg
->type
= arg_crp
;
1208 cur_arg
->rp
= cur_arg
->r
;
1212 case arg_crp
: /* Case 0x18(r1,r0). */
1213 /* Set displacement constant. */
1214 while (*operandE
!= '(')
1217 process_label_constant (operandS
, cr16_ins
);
1218 operandS
= operandE
;
1220 /* Set register pair base. */
1221 while (*operandE
!= ')')
1224 if ((cur_arg
->rp
= get_register_pair (operandS
)) == nullregister
)
1225 as_bad (_("Illegal register pair `%s' in Instruction `%s'"),
1226 operandS
, ins_parse
);
1230 /* Set register pair base. */
1231 if ((strchr (operandS
,'(') != NULL
))
1233 while ((*operandE
!= '(') && (! ISSPACE (*operandE
)))
1235 if ((cur_arg
->rp
= get_index_register_pair (operandE
)) == nullregister
)
1236 as_bad (_("Illegal register pair `%s' in Instruction `%s'"),
1237 operandS
, ins_parse
);
1239 cur_arg
->type
= arg_idxrp
;
1244 operandE
= operandS
;
1245 /* Set displacement constant. */
1246 while (*operandE
!= ']')
1248 process_label_constant (++operandE
, cr16_ins
);
1250 operandE
= operandS
;
1252 /* Set index register . */
1253 operandS
= strchr (operandE
,'[');
1254 if (operandS
!= NULL
)
1255 { /* Eliminate '[', detach from rest of operand. */
1258 operandE
= strchr (operandS
, ']');
1260 if (operandE
== NULL
)
1261 as_bad (_("unmatched '['"));
1263 { /* Eliminate ']' and make sure it was the last thing
1266 if (*(operandE
+ 1) != '\0')
1267 as_bad (_("garbage after index spec ignored"));
1271 if ((cur_arg
->i_r
= get_index_register (operandS
)) == nullregister
)
1272 as_bad (_("Illegal register `%s' in Instruction `%s'"),
1273 operandS
, ins_parse
);
1283 /* Parse a single operand.
1284 operand - Current operand to parse.
1285 cr16_ins - Current assembled instruction. */
1288 parse_operand (char *operand
, ins
* cr16_ins
)
1291 argument
*cur_arg
= cr16_ins
->arg
+ cur_arg_num
; /* Current argument. */
1293 /* Initialize the type to NULL before parsing. */
1294 cur_arg
->type
= nullargs
;
1296 /* Check whether this is a condition code . */
1297 if ((IS_INSN_MNEMONIC ("b")) && ((ret_val
= get_cc (operand
)) != -1))
1299 cur_arg
->type
= arg_cc
;
1300 cur_arg
->cc
= ret_val
;
1301 cur_arg
->X_op
= O_register
;
1305 /* Check whether this is a general processor register. */
1306 if ((ret_val
= get_register (operand
)) != nullregister
)
1308 cur_arg
->type
= arg_r
;
1309 cur_arg
->r
= ret_val
;
1314 /* Check whether this is a general processor register pair. */
1315 if ((operand
[0] == '(')
1316 && ((ret_val
= get_register_pair (operand
)) != nullregister
))
1318 cur_arg
->type
= arg_rp
;
1319 cur_arg
->rp
= ret_val
;
1320 cur_arg
->X_op
= O_register
;
1324 /* Check whether the operand is a processor register.
1325 For "lprd" and "sprd" instruction, only 32 bit
1326 processor registers used. */
1327 if (!(IS_INSN_MNEMONIC ("lprd") || (IS_INSN_MNEMONIC ("sprd")))
1328 && ((ret_val
= get_pregister (operand
)) != nullpregister
))
1330 cur_arg
->type
= arg_pr
;
1331 cur_arg
->pr
= ret_val
;
1332 cur_arg
->X_op
= O_register
;
1336 /* Check whether this is a processor register - 32 bit. */
1337 if ((ret_val
= get_pregisterp (operand
)) != nullpregister
)
1339 cur_arg
->type
= arg_prp
;
1340 cur_arg
->prp
= ret_val
;
1341 cur_arg
->X_op
= O_register
;
1345 /* Deal with special characters. */
1349 if (strchr (operand
, '(') != NULL
)
1350 cur_arg
->type
= arg_icr
;
1352 cur_arg
->type
= arg_ic
;
1357 cur_arg
->type
= arg_rbase
;
1362 cur_arg
->type
= arg_idxr
;
1370 if (strchr (operand
, '(') != NULL
)
1372 if (strchr (operand
, ',') != NULL
1373 && (strchr (operand
, ',') > strchr (operand
, '(')))
1374 cur_arg
->type
= arg_crp
;
1376 cur_arg
->type
= arg_cr
;
1379 cur_arg
->type
= arg_c
;
1381 /* Parse an operand according to its type. */
1383 cur_arg
->constant
= 0;
1384 set_operand (operand
, cr16_ins
);
1387 /* Parse the various operands. Each operand is then analyzed to fillup
1388 the fields in the cr16_ins data structure. */
1391 parse_operands (ins
* cr16_ins
, char *operands
)
1393 char *operandS
; /* Operands string. */
1394 char *operandH
, *operandT
; /* Single operand head/tail pointers. */
1395 int allocated
= 0; /* Indicates a new operands string was allocated.*/
1396 char *operand
[MAX_OPERANDS
];/* Separating the operands. */
1397 int op_num
= 0; /* Current operand number we are parsing. */
1398 int bracket_flag
= 0; /* Indicates a bracket '(' was found. */
1399 int sq_bracket_flag
= 0; /* Indicates a square bracket '[' was found. */
1401 /* Preprocess the list of registers, if necessary. */
1402 operandS
= operandH
= operandT
= operands
;
1404 while (*operandT
!= '\0')
1406 if (*operandT
== ',' && bracket_flag
!= 1 && sq_bracket_flag
!= 1)
1409 operand
[op_num
++] = strdup (operandH
);
1410 operandH
= operandT
;
1414 if (*operandT
== ' ')
1415 as_bad (_("Illegal operands (whitespace): `%s'"), ins_parse
);
1417 if (*operandT
== '(')
1419 else if (*operandT
== '[')
1420 sq_bracket_flag
= 1;
1422 if (*operandT
== ')')
1427 as_fatal (_("Missing matching brackets : `%s'"), ins_parse
);
1429 else if (*operandT
== ']')
1431 if (sq_bracket_flag
)
1432 sq_bracket_flag
= 0;
1434 as_fatal (_("Missing matching brackets : `%s'"), ins_parse
);
1437 if (bracket_flag
== 1 && *operandT
== ')')
1439 else if (sq_bracket_flag
== 1 && *operandT
== ']')
1440 sq_bracket_flag
= 0;
1445 /* Adding the last operand. */
1446 operand
[op_num
++] = strdup (operandH
);
1447 cr16_ins
->nargs
= op_num
;
1449 /* Verifying correct syntax of operands (all brackets should be closed). */
1450 if (bracket_flag
|| sq_bracket_flag
)
1451 as_fatal (_("Missing matching brackets : `%s'"), ins_parse
);
1453 /* Now we parse each operand separately. */
1454 for (op_num
= 0; op_num
< cr16_ins
->nargs
; op_num
++)
1456 cur_arg_num
= op_num
;
1457 parse_operand (operand
[op_num
], cr16_ins
);
1458 free (operand
[op_num
]);
1465 /* Get the trap index in dispatch table, given its name.
1466 This routine is used by assembling the 'excp' instruction. */
1471 const trap_entry
*trap
;
1473 for (trap
= cr16_traps
; trap
< (cr16_traps
+ NUMTRAPS
); trap
++)
1474 if (strcasecmp (trap
->name
, s
) == 0)
1477 /* To make compatable with CR16 4.1 tools, the below 3-lines of
1478 * code added. Refer: Development Tracker item #123 */
1479 for (trap
= cr16_traps
; trap
< (cr16_traps
+ NUMTRAPS
); trap
++)
1480 if (trap
->entry
== (unsigned int) atoi (s
))
1483 as_bad (_("Unknown exception: `%s'"), s
);
1487 /* Top level module where instruction parsing starts.
1488 cr16_ins - data structure holds some information.
1489 operands - holds the operands part of the whole instruction. */
1492 parse_insn (ins
*insn
, char *operands
)
1496 /* Handle instructions with no operands. */
1497 for (i
= 0; cr16_no_op_insn
[i
] != NULL
; i
++)
1499 if (streq (cr16_no_op_insn
[i
], instruction
->mnemonic
))
1506 /* Handle 'excp' instructions. */
1507 if (IS_INSN_MNEMONIC ("excp"))
1510 insn
->arg
[0].type
= arg_ic
;
1511 insn
->arg
[0].constant
= gettrap (operands
);
1512 insn
->arg
[0].X_op
= O_constant
;
1516 if (operands
!= NULL
)
1517 parse_operands (insn
, operands
);
1520 /* bCC instruction requires special handling. */
1522 get_b_cc (char * op
)
1527 for (i
= 1; i
< strlen (op
); i
++)
1532 for (i
= 0; i
< cr16_num_cc
; i
++)
1533 if (streq (op1
, cr16_b_cond_tab
[i
]))
1534 return (char *) cr16_b_cond_tab
[i
];
1539 /* bCC instruction requires special handling. */
1541 is_bcc_insn (char * op
)
1543 if (!(streq (op
, "bal") || streq (op
, "beq0b") || streq (op
, "bnq0b")
1544 || streq (op
, "beq0w") || streq (op
, "bnq0w")))
1545 if ((op
[0] == 'b') && (get_b_cc (op
) != NULL
))
1550 /* Cinv instruction requires special handling. */
1553 check_cinv_options (char * operand
)
1556 int i_used
= 0, u_used
= 0, d_used
= 0;
1560 if (*p
== ',' || *p
== ' ')
1570 as_bad (_("Illegal `cinv' parameter: `%c'"), *p
);
1576 /* Retrieve the opcode image of a given register pair.
1577 If the register is illegal for the current instruction,
1581 getregp_image (reg r
)
1583 const reg_entry
*rreg
;
1586 /* Check whether the register is in registers table. */
1588 rreg
= cr16_regptab
+ r
;
1589 /* Register not found. */
1592 as_bad (_("Unknown register pair: `%d'"), r
);
1596 reg_name
= rreg
->name
;
1598 /* Issue a error message when register pair is illegal. */
1599 #define RPAIR_IMAGE_ERR \
1600 as_bad (_("Illegal register pair (`%s') in Instruction: `%s'"), \
1601 reg_name, ins_parse); \
1606 case CR16_RP_REGTYPE
:
1615 /* Retrieve the opcode image of a given index register pair.
1616 If the register is illegal for the current instruction,
1620 getidxregp_image (reg r
)
1622 const reg_entry
*rreg
;
1625 /* Check whether the register is in registers table. */
1627 rreg
= cr16_regptab
+ r
;
1628 /* Register not found. */
1631 as_bad (_("Unknown register pair: `%d'"), r
);
1635 reg_name
= rreg
->name
;
1637 /* Issue a error message when register pair is illegal. */
1638 #define IDX_RPAIR_IMAGE_ERR \
1639 as_bad (_("Illegal index register pair (`%s') in Instruction: `%s'"), \
1640 reg_name, ins_parse); \
1642 if (rreg->type == CR16_RP_REGTYPE)
1644 switch (rreg
->image
)
1646 case 0: return 0; break;
1647 case 2: return 1; break;
1648 case 4: return 2; break;
1649 case 6: return 3; break;
1650 case 8: return 4; break;
1651 case 10: return 5; break;
1652 case 3: return 6; break;
1653 case 5: return 7; break;
1659 IDX_RPAIR_IMAGE_ERR
;
1663 /* Retrieve the opcode image of a given processort register.
1664 If the register is illegal for the current instruction,
1667 getprocreg_image (reg r
)
1669 const reg_entry
*rreg
;
1672 /* Check whether the register is in registers table. */
1673 if (r
>= MAX_REG
&& r
< MAX_PREG
)
1674 rreg
= &cr16_pregtab
[r
- MAX_REG
];
1675 /* Register not found. */
1678 as_bad (_("Unknown processor register : `%d'"), r
);
1682 reg_name
= rreg
->name
;
1684 /* Issue a error message when register pair is illegal. */
1685 #define PROCREG_IMAGE_ERR \
1686 as_bad (_("Illegal processor register (`%s') in Instruction: `%s'"), \
1687 reg_name, ins_parse); \
1692 case CR16_P_REGTYPE
:
1701 /* Retrieve the opcode image of a given processort register.
1702 If the register is illegal for the current instruction,
1705 getprocregp_image (reg r
)
1707 const reg_entry
*rreg
;
1709 int pregptab_disp
= 0;
1711 /* Check whether the register is in registers table. */
1712 if (r
>= MAX_REG
&& r
< MAX_PREG
)
1717 case 4: pregptab_disp
= 1; break;
1718 case 6: pregptab_disp
= 2; break;
1722 pregptab_disp
= 3; break;
1724 pregptab_disp
= 4; break;
1726 pregptab_disp
= 5; break;
1729 rreg
= &cr16_pregptab
[r
- pregptab_disp
];
1731 /* Register not found. */
1734 as_bad (_("Unknown processor register (32 bit) : `%d'"), r
);
1738 reg_name
= rreg
->name
;
1740 /* Issue a error message when register pair is illegal. */
1741 #define PROCREGP_IMAGE_ERR \
1742 as_bad (_("Illegal 32 bit - processor register (`%s') in Instruction: `%s'"),\
1743 reg_name, ins_parse); \
1748 case CR16_P_REGTYPE
:
1757 /* Routine used to represent integer X using NBITS bits. */
1760 getconstant (long x
, int nbits
)
1762 /* The following expression avoids overflow if
1763 'nbits' is the number of bits in 'bfd_vma'. */
1764 return (x
& ((((1 << (nbits
- 1)) - 1) << 1) | 1));
1767 /* Print a constant value to 'output_opcode':
1768 ARG holds the operand's type and value.
1769 SHIFT represents the location of the operand to be print into.
1770 NBITS determines the size (in bits) of the constant. */
1773 print_constant (int nbits
, int shift
, argument
*arg
)
1775 unsigned long mask
= 0;
1777 long constant
= getconstant (arg
->constant
, nbits
);
1783 /* mask the upper part of the constant, that is, the bits
1784 going to the lowest byte of output_opcode[0].
1785 The upper part of output_opcode[1] is always filled,
1786 therefore it is always masked with 0xFFFF. */
1787 mask
= (1 << (nbits
- 16)) - 1;
1788 /* Divide the constant between two consecutive words :
1790 +---------+---------+---------+---------+
1791 | | X X X X | x X x X | |
1792 +---------+---------+---------+---------+
1793 output_opcode[0] output_opcode[1] */
1795 CR16_PRINT (0, (constant
>> WORD_SHIFT
) & mask
, 0);
1796 CR16_PRINT (1, (constant
& 0xFFFF), WORD_SHIFT
);
1800 if ((nbits
== 21) && (IS_INSN_TYPE (LD_STOR_INS
))) nbits
= 20;
1804 /* mask the upper part of the constant, that is, the bits
1805 going to the lowest byte of output_opcode[0].
1806 The upper part of output_opcode[1] is always filled,
1807 therefore it is always masked with 0xFFFF. */
1808 mask
= (1 << (nbits
- 16)) - 1;
1809 /* Divide the constant between two consecutive words :
1811 +---------+---------+---------+---------+
1812 | | X X X X | - X - X | |
1813 +---------+---------+---------+---------+
1814 output_opcode[0] output_opcode[1] */
1816 if ((instruction
->size
> 2) && (shift
== WORD_SHIFT
))
1818 if (arg
->type
== arg_idxrp
)
1820 CR16_PRINT (0, ((constant
>> WORD_SHIFT
) & mask
) << 8, 0);
1821 CR16_PRINT (1, (constant
& 0xFFFF), WORD_SHIFT
);
1825 CR16_PRINT (0, (((((constant
>> WORD_SHIFT
) & mask
) << 8) & 0x0f00) | ((((constant
>> WORD_SHIFT
) & mask
) >> 4) & 0xf)),0);
1826 CR16_PRINT (1, (constant
& 0xFFFF), WORD_SHIFT
);
1830 CR16_PRINT (0, constant
, shift
);
1834 if (arg
->type
== arg_idxrp
)
1836 if (instruction
->size
== 2)
1838 CR16_PRINT (0, ((constant
) & 0xf), shift
); /* 0-3 bits. */
1839 CR16_PRINT (0, ((constant
>> 4) & 0x3), (shift
+ 20)); /* 4-5 bits. */
1840 CR16_PRINT (0, ((constant
>> 6) & 0x3), (shift
+ 14)); /* 6-7 bits. */
1841 CR16_PRINT (0, ((constant
>> 8) & 0x3f), (shift
+ 8)); /* 8-13 bits. */
1844 CR16_PRINT (0, constant
, shift
);
1850 /* When instruction size is 3 and 'shift' is 16, a 16-bit constant is
1851 always filling the upper part of output_opcode[1]. If we mistakenly
1852 write it to output_opcode[0], the constant prefix (that is, 'match')
1855 +---------+---------+---------+---------+
1856 | 'match' | | X X X X | |
1857 +---------+---------+---------+---------+
1858 output_opcode[0] output_opcode[1] */
1860 if ((instruction
->size
> 2) && (shift
== WORD_SHIFT
))
1861 CR16_PRINT (1, constant
, WORD_SHIFT
);
1863 CR16_PRINT (0, constant
, shift
);
1867 CR16_PRINT (0, ((constant
/ 2) & 0xf), shift
);
1868 CR16_PRINT (0, ((constant
/ 2) >> 4), (shift
+ 8));
1872 CR16_PRINT (0, constant
, shift
);
1877 /* Print an operand to 'output_opcode', which later on will be
1878 printed to the object file:
1879 ARG holds the operand's type, size and value.
1880 SHIFT represents the printing location of operand.
1881 NBITS determines the size (in bits) of a constant operand. */
1884 print_operand (int nbits
, int shift
, argument
*arg
)
1889 CR16_PRINT (0, arg
->cc
, shift
);
1893 CR16_PRINT (0, getreg_image (arg
->r
), shift
);
1897 CR16_PRINT (0, getregp_image (arg
->rp
), shift
);
1901 CR16_PRINT (0, getprocreg_image (arg
->pr
), shift
);
1905 CR16_PRINT (0, getprocregp_image (arg
->prp
), shift
);
1910 +-----------------------------+
1911 | r_index | disp | rp_base |
1912 +-----------------------------+ */
1914 if (instruction
->size
== 3)
1916 CR16_PRINT (0, getidxregp_image (arg
->rp
), 0);
1917 if (getreg_image (arg
->i_r
) == 12)
1918 CR16_PRINT (0, 0, 3);
1920 CR16_PRINT (0, 1, 3);
1924 CR16_PRINT (0, getidxregp_image (arg
->rp
), 16);
1925 if (getreg_image (arg
->i_r
) == 12)
1926 CR16_PRINT (0, 0, 19);
1928 CR16_PRINT (0, 1, 19);
1930 print_constant (nbits
, shift
, arg
);
1934 if (getreg_image (arg
->i_r
) == 12)
1935 if (IS_INSN_MNEMONIC ("cbitb") || IS_INSN_MNEMONIC ("sbitb")
1936 || IS_INSN_MNEMONIC ("tbitb"))
1937 CR16_PRINT (0, 0, 23);
1938 else CR16_PRINT (0, 0, 24);
1940 if (IS_INSN_MNEMONIC ("cbitb") || IS_INSN_MNEMONIC ("sbitb")
1941 || IS_INSN_MNEMONIC ("tbitb"))
1942 CR16_PRINT (0, 1, 23);
1943 else CR16_PRINT (0, 1, 24);
1945 print_constant (nbits
, shift
, arg
);
1950 print_constant (nbits
, shift
, arg
);
1954 CR16_PRINT (0, getreg_image (arg
->r
), shift
);
1958 print_constant (nbits
, shift
, arg
);
1959 /* Add the register argument to the output_opcode. */
1960 CR16_PRINT (0, getreg_image (arg
->r
), (shift
+16));
1964 print_constant (nbits
, shift
, arg
);
1965 if (instruction
->size
> 1)
1966 CR16_PRINT (0, getregp_image (arg
->rp
), (shift
+ 16));
1967 else if (IS_INSN_TYPE (LD_STOR_INS
) || (IS_INSN_TYPE (CSTBIT_INS
)))
1969 if (instruction
->size
== 2)
1970 CR16_PRINT (0, getregp_image (arg
->rp
), (shift
- 8));
1971 else if (instruction
->size
== 1)
1972 CR16_PRINT (0, getregp_image (arg
->rp
), 16);
1975 CR16_PRINT (0, getregp_image (arg
->rp
), shift
);
1983 /* Retrieve the number of operands for the current assembled instruction. */
1986 get_number_of_operands (void)
1990 for (i
= 0; instruction
->operands
[i
].op_type
&& i
< MAX_OPERANDS
; i
++)
1995 /* Verify that the number NUM can be represented in BITS bits (that is,
1996 within its permitted range), based on the instruction's FLAGS.
1997 If UPDATE is nonzero, update the value of NUM if necessary.
1998 Return OP_LEGAL upon success, actual error type upon failure. */
2001 check_range (long *num
, int bits
, int unsigned flags
, int update
)
2004 int retval
= OP_LEGAL
;
2007 if (bits
== 0 && value
> 0) return OP_OUT_OF_RANGE
;
2009 /* For hosts witah longs bigger than 32-bits make sure that the top
2010 bits of a 32-bit negative value read in by the parser are set,
2011 so that the correct comparisons are made. */
2012 if (value
& 0x80000000)
2013 value
|= (-1L << 31);
2016 /* Verify operand value is even. */
2017 if (flags
& OP_EVEN
)
2030 if (flags
& OP_SHIFT
)
2036 else if (flags
& OP_SHIFT_DEC
)
2038 value
= (value
>> 1) - 1;
2043 if (flags
& OP_ABS20
)
2045 if (value
> 0xEFFFF)
2046 return OP_OUT_OF_RANGE
;
2051 if (value
== 0xB || value
== 0x9)
2052 return OP_OUT_OF_RANGE
;
2053 else if (value
== -1)
2061 if (flags
& OP_ESC1
)
2064 return OP_OUT_OF_RANGE
;
2067 if (flags
& OP_SIGNED
)
2069 max
= (1 << (bits
- 1)) - 1;
2070 min
= - (1 << (bits
- 1));
2071 if ((value
> max
) || (value
< min
))
2072 retval
= OP_OUT_OF_RANGE
;
2074 else if (flags
& OP_UNSIGNED
)
2076 max
= ((((1 << (bits
- 1)) - 1) << 1) | 1);
2078 if (((unsigned long) value
> (unsigned long) max
)
2079 || ((unsigned long) value
< (unsigned long) min
))
2080 retval
= OP_OUT_OF_RANGE
;
2082 else if (flags
& OP_NEG
)
2085 min
= - ((1 << (bits
- 1)) - 1);
2086 if ((value
> max
) || (value
< min
))
2087 retval
= OP_OUT_OF_RANGE
;
2092 /* Bunch of error checkings.
2093 The checks are made after a matching instruction was found. */
2096 warn_if_needed (ins
*insn
)
2098 /* If the post-increment address mode is used and the load/store
2099 source register is the same as rbase, the result of the
2100 instruction is undefined. */
2101 if (IS_INSN_TYPE (LD_STOR_INS_INC
))
2103 /* Enough to verify that one of the arguments is a simple reg. */
2104 if ((insn
->arg
[0].type
== arg_r
) || (insn
->arg
[1].type
== arg_r
))
2105 if (insn
->arg
[0].r
== insn
->arg
[1].r
)
2106 as_bad (_("Same src/dest register is used (`r%d'), result is undefined"), insn
->arg
[0].r
);
2109 if (IS_INSN_MNEMONIC ("pop")
2110 || IS_INSN_MNEMONIC ("push")
2111 || IS_INSN_MNEMONIC ("popret"))
2113 unsigned int count
= insn
->arg
[0].constant
, reg_val
;
2115 /* Check if count operand caused to save/retrive the RA twice
2116 to generate warning message. */
2117 if (insn
->nargs
> 2)
2119 reg_val
= getreg_image (insn
->arg
[1].r
);
2121 if ( ((reg_val
== 9) && (count
> 7))
2122 || ((reg_val
== 10) && (count
> 6))
2123 || ((reg_val
== 11) && (count
> 5))
2124 || ((reg_val
== 12) && (count
> 4))
2125 || ((reg_val
== 13) && (count
> 2))
2126 || ((reg_val
== 14) && (count
> 0)))
2127 as_warn (_("RA register is saved twice."));
2129 /* Check if the third operand is "RA" or "ra" */
2130 if (!(((insn
->arg
[2].r
) == ra
) || ((insn
->arg
[2].r
) == RA
)))
2131 as_bad (_("`%s' Illegal use of registers."), ins_parse
);
2134 if (insn
->nargs
> 1)
2136 reg_val
= getreg_image (insn
->arg
[1].r
);
2138 /* If register is a register pair ie r12/r13/r14 in operand1, then
2139 the count constant should be validated. */
2140 if (((reg_val
== 11) && (count
> 7))
2141 || ((reg_val
== 12) && (count
> 6))
2142 || ((reg_val
== 13) && (count
> 4))
2143 || ((reg_val
== 14) && (count
> 2))
2144 || ((reg_val
== 15) && (count
> 0)))
2145 as_bad (_("`%s' Illegal count-register combination."), ins_parse
);
2149 /* Check if the operand is "RA" or "ra" */
2150 if (!(((insn
->arg
[0].r
) == ra
) || ((insn
->arg
[0].r
) == RA
)))
2151 as_bad (_("`%s' Illegal use of register."), ins_parse
);
2155 /* Some instruction assume the stack pointer as rptr operand.
2156 Issue an error when the register to be loaded is also SP. */
2157 if (instruction
->flags
& NO_SP
)
2159 if (getreg_image (insn
->arg
[1].r
) == getreg_image (sp
))
2160 as_bad (_("`%s' has undefined result"), ins_parse
);
2163 /* If the rptr register is specified as one of the registers to be loaded,
2164 the final contents of rptr are undefined. Thus, we issue an error. */
2165 if (instruction
->flags
& NO_RPTR
)
2167 if ((1 << getreg_image (insn
->arg
[0].r
)) & insn
->arg
[1].constant
)
2168 as_bad (_("Same src/dest register is used (`r%d'),result is undefined"),
2169 getreg_image (insn
->arg
[0].r
));
2173 /* In some cases, we need to adjust the instruction pointer although a
2174 match was already found. Here, we gather all these cases.
2175 Returns 1 if instruction pointer was adjusted, otherwise 0. */
2178 adjust_if_needed (ins
*insn ATTRIBUTE_UNUSED
)
2182 if ((IS_INSN_TYPE (CSTBIT_INS
)) || (IS_INSN_TYPE (LD_STOR_INS
)))
2184 if ((instruction
->operands
[0].op_type
== abs24
)
2185 && ((insn
->arg
[0].constant
) > 0xF00000))
2187 insn
->arg
[0].constant
&= 0xFFFFF;
2196 /* Assemble a single instruction:
2197 INSN is already parsed (that is, all operand values and types are set).
2198 For instruction to be assembled, we need to find an appropriate template in
2199 the instruction table, meeting the following conditions:
2200 1: Has the same number of operands.
2201 2: Has the same operand types.
2202 3: Each operand size is sufficient to represent the instruction's values.
2203 Returns 1 upon success, 0 upon failure. */
2206 assemble_insn (char *mnemonic
, ins
*insn
)
2208 /* Type of each operand in the current template. */
2209 argtype cur_type
[MAX_OPERANDS
];
2210 /* Size (in bits) of each operand in the current template. */
2211 unsigned int cur_size
[MAX_OPERANDS
];
2212 /* Flags of each operand in the current template. */
2213 unsigned int cur_flags
[MAX_OPERANDS
];
2214 /* Instruction type to match. */
2215 unsigned int ins_type
;
2216 /* Boolean flag to mark whether a match was found. */
2219 /* Nonzero if an instruction with same number of operands was found. */
2220 int found_same_number_of_operands
= 0;
2221 /* Nonzero if an instruction with same argument types was found. */
2222 int found_same_argument_types
= 0;
2223 /* Nonzero if a constant was found within the required range. */
2224 int found_const_within_range
= 0;
2225 /* Argument number of an operand with invalid type. */
2226 int invalid_optype
= -1;
2227 /* Argument number of an operand with invalid constant value. */
2228 int invalid_const
= -1;
2229 /* Operand error (used for issuing various constant error messages). */
2230 op_err op_error
, const_err
= OP_LEGAL
;
2232 /* Retrieve data (based on FUNC) for each operand of a given instruction. */
2233 #define GET_CURRENT_DATA(FUNC, ARRAY) \
2234 for (i = 0; i < insn->nargs; i++) \
2235 ARRAY[i] = FUNC (instruction->operands[i].op_type)
2237 #define GET_CURRENT_TYPE GET_CURRENT_DATA (get_optype, cur_type)
2238 #define GET_CURRENT_SIZE GET_CURRENT_DATA (get_opbits, cur_size)
2239 #define GET_CURRENT_FLAGS GET_CURRENT_DATA (get_opflags, cur_flags)
2241 /* Instruction has no operands -> only copy the constant opcode. */
2242 if (insn
->nargs
== 0)
2244 output_opcode
[0] = BIN (instruction
->match
, instruction
->match_bits
);
2248 /* In some case, same mnemonic can appear with different instruction types.
2249 For example, 'storb' is supported with 3 different types :
2250 LD_STOR_INS, LD_STOR_INS_INC, STOR_IMM_INS.
2251 We assume that when reaching this point, the instruction type was
2252 pre-determined. We need to make sure that the type stays the same
2253 during a search for matching instruction. */
2254 ins_type
= CR16_INS_TYPE (instruction
->flags
);
2256 while (/* Check that match is still not found. */
2258 /* Check we didn't get to end of table. */
2259 && instruction
->mnemonic
!= NULL
2260 /* Check that the actual mnemonic is still available. */
2261 && IS_INSN_MNEMONIC (mnemonic
)
2262 /* Check that the instruction type wasn't changed. */
2263 && IS_INSN_TYPE (ins_type
))
2265 /* Check whether number of arguments is legal. */
2266 if (get_number_of_operands () != insn
->nargs
)
2268 found_same_number_of_operands
= 1;
2270 /* Initialize arrays with data of each operand in current template. */
2275 /* Check for type compatibility. */
2276 for (i
= 0; i
< insn
->nargs
; i
++)
2278 if (cur_type
[i
] != insn
->arg
[i
].type
)
2280 if (invalid_optype
== -1)
2281 invalid_optype
= i
+ 1;
2285 found_same_argument_types
= 1;
2287 for (i
= 0; i
< insn
->nargs
; i
++)
2289 /* If 'bal' instruction size is '2' and reg operand is not 'ra'
2290 then goto next instruction. */
2291 if (IS_INSN_MNEMONIC ("bal") && (i
== 0)
2292 && (instruction
->size
== 2) && (insn
->arg
[i
].rp
!= 14))
2295 /* If 'storb' instruction with 'sp' reg and 16-bit disp of
2296 * reg-pair, leads to undifined trap, so this should use
2297 * 20-bit disp of reg-pair. */
2298 if (IS_INSN_MNEMONIC ("storb") && (instruction
->size
== 2)
2299 && (insn
->arg
[i
].r
== 15) && (insn
->arg
[i
+ 1].type
== arg_crp
))
2302 /* Only check range - don't update the constant's value, since the
2303 current instruction may not be the last we try to match.
2304 The constant's value will be updated later, right before printing
2305 it to the object file. */
2306 if ((insn
->arg
[i
].X_op
== O_constant
)
2307 && (op_error
= check_range (&insn
->arg
[i
].constant
, cur_size
[i
],
2310 if (invalid_const
== -1)
2312 invalid_const
= i
+ 1;
2313 const_err
= op_error
;
2317 /* For symbols, we make sure the relocation size (which was already
2318 determined) is sufficient. */
2319 else if ((insn
->arg
[i
].X_op
== O_symbol
)
2320 && ((bfd_reloc_type_lookup (stdoutput
, insn
->rtype
))->bitsize
2324 found_const_within_range
= 1;
2326 /* If we got till here -> Full match is found. */
2330 /* Try again with next instruction. */
2337 /* We haven't found a match - instruction can't be assembled. */
2338 if (!found_same_number_of_operands
)
2339 as_bad (_("Incorrect number of operands"));
2340 else if (!found_same_argument_types
)
2341 as_bad (_("Illegal type of operand (arg %d)"), invalid_optype
);
2342 else if (!found_const_within_range
)
2346 case OP_OUT_OF_RANGE
:
2347 as_bad (_("Operand out of range (arg %d)"), invalid_const
);
2350 as_bad (_("Operand has odd displacement (arg %d)"), invalid_const
);
2353 as_bad (_("Illegal operand (arg %d)"), invalid_const
);
2361 /* Full match - print the encoding to output file. */
2363 /* Make further checkings (such that couldn't be made earlier).
2364 Warn the user if necessary. */
2365 warn_if_needed (insn
);
2367 /* Check whether we need to adjust the instruction pointer. */
2368 if (adjust_if_needed (insn
))
2369 /* If instruction pointer was adjusted, we need to update
2370 the size of the current template operands. */
2373 for (i
= 0; i
< insn
->nargs
; i
++)
2375 int j
= instruction
->flags
& REVERSE_MATCH
?
2380 /* This time, update constant value before printing it. */
2381 if ((insn
->arg
[j
].X_op
== O_constant
)
2382 && (check_range (&insn
->arg
[j
].constant
, cur_size
[j
],
2383 cur_flags
[j
], 1) != OP_LEGAL
))
2384 as_fatal (_("Illegal operand (arg %d)"), j
+1);
2387 /* First, copy the instruction's opcode. */
2388 output_opcode
[0] = BIN (instruction
->match
, instruction
->match_bits
);
2390 for (i
= 0; i
< insn
->nargs
; i
++)
2392 /* For BAL (ra),disp17 instuction only. And also set the
2393 DISP24a relocation type. */
2394 if (IS_INSN_MNEMONIC ("bal") && (instruction
->size
== 2) && i
== 0)
2396 insn
->rtype
= BFD_RELOC_CR16_DISP24a
;
2400 print_operand (cur_size
[i
], instruction
->operands
[i
].shift
,
2408 /* Print the instruction.
2409 Handle also cases where the instruction is relaxable/relocatable. */
2412 print_insn (ins
*insn
)
2414 unsigned int i
, j
, insn_size
;
2416 unsigned short words
[4];
2419 /* Arrange the insn encodings in a WORD size array. */
2420 for (i
= 0, j
= 0; i
< 2; i
++)
2422 words
[j
++] = (output_opcode
[i
] >> 16) & 0xFFFF;
2423 words
[j
++] = output_opcode
[i
] & 0xFFFF;
2426 /* Handle relocation. */
2427 if ((instruction
->flags
& RELAXABLE
) && relocatable
)
2430 /* Write the maximal instruction size supported. */
2431 insn_size
= INSN_MAX_SIZE
;
2433 if (IS_INSN_TYPE (BRANCH_INS
))
2435 switch (insn
->rtype
)
2437 case BFD_RELOC_CR16_DISP24
:
2440 case BFD_RELOC_CR16_DISP16
:
2451 this_frag
= frag_var (rs_machine_dependent
, insn_size
*2,
2453 insn
->exp
.X_add_symbol
,
2459 insn_size
= instruction
->size
;
2460 this_frag
= frag_more (insn_size
* 2);
2462 if ((relocatable
) && (insn
->rtype
!= BFD_RELOC_NONE
))
2464 reloc_howto_type
*reloc_howto
;
2467 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, insn
->rtype
);
2472 size
= bfd_get_reloc_size (reloc_howto
);
2474 if (size
< 1 || size
> 4)
2477 fix_new_exp (frag_now
, this_frag
- frag_now
->fr_literal
,
2478 size
, &insn
->exp
, reloc_howto
->pc_relative
,
2483 /* Verify a 2-byte code alignment. */
2484 addr_mod
= frag_now_fix () & 1;
2485 if (frag_now
->has_code
&& frag_now
->insn_addr
!= addr_mod
)
2486 as_bad (_("instruction address is not a multiple of 2"));
2487 frag_now
->insn_addr
= addr_mod
;
2488 frag_now
->has_code
= 1;
2490 /* Write the instruction encoding to frag. */
2491 for (i
= 0; i
< insn_size
; i
++)
2493 md_number_to_chars (this_frag
, (valueT
) words
[i
], 2);
2498 /* This is the guts of the machine-dependent assembler. OP points to a
2499 machine dependent instruction. This function is supposed to emit
2500 the frags/bytes it assembles to. */
2503 md_assemble (char *op
)
2506 char *param
, param1
[32];
2509 /* Reset global variables for a new instruction. */
2512 /* Strip the mnemonic. */
2513 for (param
= op
; *param
!= 0 && !ISSPACE (*param
); param
++)
2518 /* bCC instuctions and adjust the mnemonic by adding extra white spaces. */
2519 if (is_bcc_insn (op
))
2521 strcpy (param1
, get_b_cc (op
));
2523 strcat (param1
,",");
2524 strcat (param1
, param
);
2525 param
= (char *) ¶m1
;
2528 /* Checking the cinv options and adjust the mnemonic by removing the
2529 extra white spaces. */
2530 if (streq ("cinv", op
))
2532 /* Validate the cinv options. */
2533 check_cinv_options (param
);
2537 /* MAPPING - SHIFT INSN, if imm4/imm16 positive values
2538 lsh[b/w] imm4/imm6, reg ==> ashu[b/w] imm4/imm16, reg
2539 as CR16 core doesn't support lsh[b/w] right shift operaions. */
2540 if ((streq ("lshb", op
) || streq ("lshw", op
) || streq ("lshd", op
))
2541 && (param
[0] == '$'))
2543 strcpy (param1
, param
);
2544 /* Find the instruction. */
2545 instruction
= (const inst
*) hash_find (cr16_inst_hash
, op
);
2546 parse_operands (&cr16_ins
, param1
);
2547 if (((&cr16_ins
)->arg
[0].type
== arg_ic
)
2548 && ((&cr16_ins
)->arg
[0].constant
>= 0))
2550 if (streq ("lshb", op
))
2552 else if (streq ("lshd", op
))
2559 /* Find the instruction. */
2560 instruction
= (const inst
*) hash_find (cr16_inst_hash
, op
);
2561 if (instruction
== NULL
)
2563 as_bad (_("Unknown opcode: `%s'"), op
);
2567 /* Tie dwarf2 debug info to the address at the start of the insn. */
2568 dwarf2_emit_insn (0);
2570 /* Parse the instruction's operands. */
2571 parse_insn (&cr16_ins
, param
);
2573 /* Assemble the instruction - return upon failure. */
2574 if (assemble_insn (op
, &cr16_ins
) == 0)
2577 /* Print the instruction. */
2578 print_insn (&cr16_ins
);