Home | History | Annotate | Line # | Download | only in opcodes
crx-opc.c revision 1.6
      1  1.1  christos /* crx-opc.c -- Table of opcodes for the CRX processor.
      2  1.6  christos    Copyright (C) 2004-2018 Free Software Foundation, Inc.
      3  1.1  christos    Contributed by Tomer Levi NSC, Israel.
      4  1.1  christos    Originally written for GAS 2.12 by Tomer Levi.
      5  1.1  christos 
      6  1.1  christos    This file is part of the GNU opcodes library.
      7  1.1  christos 
      8  1.1  christos    This library is free software; you can redistribute it and/or modify
      9  1.1  christos    it under the terms of the GNU General Public License as published by
     10  1.1  christos    the Free Software Foundation; either version 3, or (at your option)
     11  1.1  christos    any later version.
     12  1.1  christos 
     13  1.1  christos    It is distributed in the hope that it will be useful, but WITHOUT
     14  1.1  christos    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     15  1.1  christos    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
     16  1.1  christos    License for more details.
     17  1.1  christos 
     18  1.1  christos    You should have received a copy of the GNU General Public License
     19  1.1  christos    along with this program; if not, write to the Free Software
     20  1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     21  1.1  christos    MA 02110-1301, USA.  */
     22  1.1  christos 
     23  1.1  christos #include <stdio.h>
     24  1.1  christos #include "libiberty.h"
     25  1.1  christos #include "symcat.h"
     26  1.1  christos #include "opcode/crx.h"
     27  1.1  christos 
     28  1.1  christos const inst crx_instruction[] =
     29  1.1  christos {
     30  1.1  christos /* Create an arithmetic instruction - INST[bw].  */
     31  1.1  christos #define  ARITH_BYTE_INST(NAME, OPC) \
     32  1.1  christos   /* opc8 cst4 r */								\
     33  1.1  christos   {NAME, 1, OPC,  24, ARITH_BYTE_INS | CST4MAP, {{cst4,20}, {regr,16}}},	\
     34  1.1  christos   /* opc8 i16 r */								\
     35  1.1  christos   {NAME, 2, (OPC<<4)+0xE, 20, ARITH_BYTE_INS | CST4MAP, {{i16,0}, {regr,16}}},  \
     36  1.1  christos   /* opc8 r r */								\
     37  1.1  christos   {NAME, 1, OPC+0x40, 24, ARITH_BYTE_INS, {{regr,20}, {regr,16}}}
     38  1.1  christos 
     39  1.1  christos   ARITH_BYTE_INST ("addub", 0x0),
     40  1.1  christos   ARITH_BYTE_INST ("addb",  0x1),
     41  1.1  christos   ARITH_BYTE_INST ("addcb", 0x2),
     42  1.1  christos   ARITH_BYTE_INST ("andb",  0x3),
     43  1.1  christos   ARITH_BYTE_INST ("cmpb",  0x4),
     44  1.1  christos   ARITH_BYTE_INST ("movb",  0x5),
     45  1.1  christos   ARITH_BYTE_INST ("orb",   0x6),
     46  1.1  christos   ARITH_BYTE_INST ("subb",  0x7),
     47  1.1  christos   ARITH_BYTE_INST ("subcb", 0x8),
     48  1.1  christos   ARITH_BYTE_INST ("xorb",  0x9),
     49  1.1  christos   ARITH_BYTE_INST ("mulb",  0xA),
     50  1.1  christos 
     51  1.1  christos   ARITH_BYTE_INST ("adduw", 0x10),
     52  1.1  christos   ARITH_BYTE_INST ("addw",  0x11),
     53  1.1  christos   ARITH_BYTE_INST ("addcw", 0x12),
     54  1.1  christos   ARITH_BYTE_INST ("andw",  0x13),
     55  1.1  christos   ARITH_BYTE_INST ("cmpw",  0x14),
     56  1.1  christos   ARITH_BYTE_INST ("movw",  0x15),
     57  1.1  christos   ARITH_BYTE_INST ("orw",   0x16),
     58  1.1  christos   ARITH_BYTE_INST ("subw",  0x17),
     59  1.1  christos   ARITH_BYTE_INST ("subcw", 0x18),
     60  1.1  christos   ARITH_BYTE_INST ("xorw",  0x19),
     61  1.1  christos   ARITH_BYTE_INST ("mulw",  0x1A),
     62  1.1  christos 
     63  1.1  christos /* Create an arithmetic instruction - INST[d].  */
     64  1.1  christos #define  ARITH_INST(NAME, OPC) \
     65  1.1  christos   /* opc8 cst4 r */							    \
     66  1.1  christos   {NAME, 1, OPC,  24, ARITH_INS | CST4MAP, {{cst4,20}, {regr,16}}},	    \
     67  1.1  christos   /* opc8 i16 r */							    \
     68  1.1  christos   {NAME, 2, (OPC<<4)+0xE, 20, ARITH_INS | CST4MAP, {{i16,0},  {regr,16}}},  \
     69  1.1  christos   /* opc8 i32 r */							    \
     70  1.1  christos   {NAME, 3, (OPC<<4)+0xF, 20, ARITH_INS, {{i32,0},  {regr,16}}},	    \
     71  1.1  christos   /* opc8 r r */							    \
     72  1.1  christos   {NAME, 1, OPC+0x40, 24, ARITH_INS, {{regr,20}, {regr,16}}}
     73  1.1  christos 
     74  1.1  christos   ARITH_INST ("addud", 0x20),
     75  1.1  christos   ARITH_INST ("addd",  0x21),
     76  1.1  christos   ARITH_INST ("addcd", 0x22),
     77  1.1  christos   ARITH_INST ("andd",  0x23),
     78  1.1  christos   ARITH_INST ("cmpd",  0x24),
     79  1.1  christos   ARITH_INST ("movd",  0x25),
     80  1.1  christos   ARITH_INST ("ord",   0x26),
     81  1.1  christos   ARITH_INST ("subd",  0x27),
     82  1.1  christos   ARITH_INST ("subcd", 0x28),
     83  1.1  christos   ARITH_INST ("xord",  0x29),
     84  1.1  christos   ARITH_INST ("muld",  0x2A),
     85  1.1  christos 
     86  1.1  christos /* Create a shift instruction.  */
     87  1.1  christos #define  SHIFT_INST(NAME, OPRD, OPC1, SHIFT1, OPC2) \
     88  1.1  christos   /* OPRD=ui3 -->> opc9 ui3 r */			      \
     89  1.1  christos   /* OPRD=ui4 -->> opc8 ui4 r */			      \
     90  1.1  christos   /* OPRD=ui5 -->> opc7 ui5 r */			      \
     91  1.1  christos   {NAME, 1, OPC1, SHIFT1, SHIFT_INS, {{OPRD,20}, {regr,16}}}, \
     92  1.1  christos   /* opc8 r r */					      \
     93  1.1  christos   {NAME, 1, OPC2, 24, SHIFT_INS, {{regr,20}, {regr,16}}}
     94  1.1  christos 
     95  1.1  christos   SHIFT_INST ("sllb", ui3, 0x1F8, 23, 0x4D),
     96  1.1  christos   SHIFT_INST ("srlb", ui3, 0x1F9, 23, 0x4E),
     97  1.1  christos   SHIFT_INST ("srab", ui3, 0x1FA, 23, 0x4F),
     98  1.1  christos 
     99  1.1  christos   SHIFT_INST ("sllw", ui4, 0xB6,  24, 0x5D),
    100  1.1  christos   SHIFT_INST ("srlw", ui4, 0xB7,  24, 0x5E),
    101  1.1  christos   SHIFT_INST ("sraw", ui4, 0xB8,  24, 0x5F),
    102  1.1  christos 
    103  1.1  christos   SHIFT_INST ("slld", ui5, 0x78,  25, 0x6D),
    104  1.1  christos   SHIFT_INST ("srld", ui5, 0x79,  25, 0x6E),
    105  1.1  christos   SHIFT_INST ("srad", ui5, 0x7A,  25, 0x6F),
    106  1.1  christos 
    107  1.1  christos /* Create a conditional branch instruction.  */
    108  1.1  christos #define  BRANCH_INST(NAME, OPC) \
    109  1.1  christos   /* opc4 c4 dispe9 */							\
    110  1.1  christos   {NAME,  1, OPC, 24, BRANCH_INS | RELAXABLE, {{dispe9,16}}},		\
    111  1.1  christos   /* opc4 c4 disps17 */							\
    112  1.1  christos   {NAME,  2, (OPC<<8)+0x7E, 16,	BRANCH_INS | RELAXABLE, {{disps17,0}}}, \
    113  1.1  christos   /* opc4 c4 disps32 */							\
    114  1.1  christos   {NAME,  3, (OPC<<8)+0x7F, 16,	BRANCH_INS | RELAXABLE, {{disps32,0}}}
    115  1.1  christos 
    116  1.1  christos   BRANCH_INST ("beq", 0x70),
    117  1.1  christos   BRANCH_INST ("bne", 0x71),
    118  1.1  christos   BRANCH_INST ("bcs", 0x72),
    119  1.1  christos   BRANCH_INST ("bcc", 0x73),
    120  1.1  christos   BRANCH_INST ("bhi", 0x74),
    121  1.1  christos   BRANCH_INST ("bls", 0x75),
    122  1.1  christos   BRANCH_INST ("bgt", 0x76),
    123  1.1  christos   BRANCH_INST ("ble", 0x77),
    124  1.1  christos   BRANCH_INST ("bfs", 0x78),
    125  1.1  christos   BRANCH_INST ("bfc", 0x79),
    126  1.1  christos   BRANCH_INST ("blo", 0x7A),
    127  1.1  christos   BRANCH_INST ("bhs", 0x7B),
    128  1.1  christos   BRANCH_INST ("blt", 0x7C),
    129  1.1  christos   BRANCH_INST ("bge", 0x7D),
    130  1.1  christos   BRANCH_INST ("br",  0x7E),
    131  1.1  christos 
    132  1.1  christos /* Create a 'Branch if Equal to 0' instruction.  */
    133  1.1  christos #define  BRANCH_NEQ_INST(NAME, OPC) \
    134  1.1  christos   /* opc8 dispu5 r */						\
    135  1.1  christos   {NAME,  1, OPC, 24, BRANCH_NEQ_INS, {{regr,16}, {dispu5,20}}}
    136  1.1  christos 
    137  1.1  christos   BRANCH_NEQ_INST ("beq0b",  0xB0),
    138  1.1  christos   BRANCH_NEQ_INST ("bne0b",  0xB1),
    139  1.1  christos   BRANCH_NEQ_INST ("beq0w",  0xB2),
    140  1.1  christos   BRANCH_NEQ_INST ("bne0w",  0xB3),
    141  1.1  christos   BRANCH_NEQ_INST ("beq0d",  0xB4),
    142  1.1  christos   BRANCH_NEQ_INST ("bne0d",  0xB5),
    143  1.1  christos 
    144  1.1  christos /* Create instruction with no operands.  */
    145  1.1  christos #define  NO_OP_INST(NAME, OPC) \
    146  1.1  christos   /* opc16 */			    \
    147  1.1  christos   {NAME,  1, OPC, 16, 0, {{0, 0}}}
    148  1.1  christos 
    149  1.1  christos   NO_OP_INST ("nop",	0x3002),
    150  1.1  christos   NO_OP_INST ("retx",	0x3003),
    151  1.1  christos   NO_OP_INST ("di",	0x3004),
    152  1.1  christos   NO_OP_INST ("ei",	0x3005),
    153  1.1  christos   NO_OP_INST ("wait",	0x3006),
    154  1.1  christos   NO_OP_INST ("eiwait",	0x3007),
    155  1.1  christos 
    156  1.1  christos /* Create a 'Compare & Branch' instruction.  */
    157  1.1  christos #define  CMPBR_INST(NAME, OPC1, OPC2, C4) \
    158  1.1  christos   /* opc12 r r c4 disps9 */					      \
    159  1.1  christos   {NAME, 2, ((0x300+OPC1)<<12)+C4,  8, CMPBR_INS | FMT_3| RELAXABLE,  \
    160  1.1  christos       {{regr,16}, {regr,12}, {disps9,0}}},			      \
    161  1.1  christos   /* opc12 r r c4 disps25 */					      \
    162  1.1  christos   {NAME, 3, ((0x310+OPC1)<<12)+C4,  8, CMPBR_INS | FMT_3 | RELAXABLE, \
    163  1.1  christos       {{regr,16}, {regr,12}, {disps25,0}}},			      \
    164  1.1  christos   /* opc12 i4cst4 r c4 disps9 */				      \
    165  1.1  christos   {NAME, 2, ((0x300+OPC2)<<12)+C4,  8, CMPBR_INS | FMT_3 | RELAXABLE, \
    166  1.1  christos       {{cst4,16}, {regr,12}, {disps9,0}}},			      \
    167  1.1  christos   /* opc12 i4cst4 r c4 disps25 */				      \
    168  1.1  christos   {NAME, 3, ((0x310+OPC2)<<12)+C4,  8, CMPBR_INS | FMT_3 | RELAXABLE, \
    169  1.1  christos       {{cst4,16}, {regr,12}, {disps25,0}}}
    170  1.1  christos 
    171  1.1  christos   CMPBR_INST ("cmpbeqb", 0x8, 0xC, 0x0),
    172  1.1  christos   CMPBR_INST ("cmpbneb", 0x8, 0xC, 0x1),
    173  1.1  christos   CMPBR_INST ("cmpbhib", 0x8, 0xC, 0x4),
    174  1.1  christos   CMPBR_INST ("cmpblsb", 0x8, 0xC, 0x5),
    175  1.1  christos   CMPBR_INST ("cmpbgtb", 0x8, 0xC, 0x6),
    176  1.1  christos   CMPBR_INST ("cmpbleb", 0x8, 0xC, 0x7),
    177  1.1  christos   CMPBR_INST ("cmpblob", 0x8, 0xC, 0xA),
    178  1.1  christos   CMPBR_INST ("cmpbhsb", 0x8, 0xC, 0xB),
    179  1.1  christos   CMPBR_INST ("cmpbltb", 0x8, 0xC, 0xC),
    180  1.1  christos   CMPBR_INST ("cmpbgeb", 0x8, 0xC, 0xD),
    181  1.1  christos 
    182  1.1  christos   CMPBR_INST ("cmpbeqw", 0x9, 0xD, 0x0),
    183  1.1  christos   CMPBR_INST ("cmpbnew", 0x9, 0xD, 0x1),
    184  1.1  christos   CMPBR_INST ("cmpbhiw", 0x9, 0xD, 0x4),
    185  1.1  christos   CMPBR_INST ("cmpblsw", 0x9, 0xD, 0x5),
    186  1.1  christos   CMPBR_INST ("cmpbgtw", 0x9, 0xD, 0x6),
    187  1.1  christos   CMPBR_INST ("cmpblew", 0x9, 0xD, 0x7),
    188  1.1  christos   CMPBR_INST ("cmpblow", 0x9, 0xD, 0xA),
    189  1.1  christos   CMPBR_INST ("cmpbhsw", 0x9, 0xD, 0xB),
    190  1.1  christos   CMPBR_INST ("cmpbltw", 0x9, 0xD, 0xC),
    191  1.1  christos   CMPBR_INST ("cmpbgew", 0x9, 0xD, 0xD),
    192  1.1  christos 
    193  1.1  christos   CMPBR_INST ("cmpbeqd", 0xA, 0xE, 0x0),
    194  1.1  christos   CMPBR_INST ("cmpbned", 0xA, 0xE, 0x1),
    195  1.1  christos   CMPBR_INST ("cmpbhid", 0xA, 0xE, 0x4),
    196  1.1  christos   CMPBR_INST ("cmpblsd", 0xA, 0xE, 0x5),
    197  1.1  christos   CMPBR_INST ("cmpbgtd", 0xA, 0xE, 0x6),
    198  1.1  christos   CMPBR_INST ("cmpbled", 0xA, 0xE, 0x7),
    199  1.1  christos   CMPBR_INST ("cmpblod", 0xA, 0xE, 0xA),
    200  1.1  christos   CMPBR_INST ("cmpbhsd", 0xA, 0xE, 0xB),
    201  1.1  christos   CMPBR_INST ("cmpbltd", 0xA, 0xE, 0xC),
    202  1.1  christos   CMPBR_INST ("cmpbged", 0xA, 0xE, 0xD),
    203  1.1  christos 
    204  1.1  christos /* Create an instruction using a single register operand.  */
    205  1.1  christos #define  REG1_INST(NAME, OPC) \
    206  1.1  christos   /* opc8 c4 r */				\
    207  1.1  christos   {NAME,  1, OPC, 20, NO_TYPE_INS, {{regr,16}}}
    208  1.1  christos 
    209  1.1  christos /* Same as REG1_INST, with additional FLAGS.  */
    210  1.1  christos #define  REG1_FLAG_INST(NAME, OPC, FLAGS) \
    211  1.1  christos   /* opc8 c4 r */					\
    212  1.1  christos   {NAME,  1, OPC, 20, NO_TYPE_INS | FLAGS, {{regr,16}}}
    213  1.1  christos 
    214  1.1  christos   /* JCond instructions	*/
    215  1.1  christos   REG1_INST ("jeq",  0xBA0),
    216  1.1  christos   REG1_INST ("jne",  0xBA1),
    217  1.1  christos   REG1_INST ("jcs",  0xBA2),
    218  1.1  christos   REG1_INST ("jcc",  0xBA3),
    219  1.1  christos   REG1_INST ("jhi",  0xBA4),
    220  1.1  christos   REG1_INST ("jls",  0xBA5),
    221  1.1  christos   REG1_INST ("jgt",  0xBA6),
    222  1.1  christos   REG1_INST ("jle",  0xBA7),
    223  1.1  christos   REG1_INST ("jfs",  0xBA8),
    224  1.1  christos   REG1_INST ("jfc",  0xBA9),
    225  1.1  christos   REG1_INST ("jlo",  0xBAA),
    226  1.1  christos   REG1_INST ("jhs",  0xBAB),
    227  1.1  christos   REG1_INST ("jlt",  0xBAC),
    228  1.1  christos   REG1_INST ("jge",  0xBAD),
    229  1.1  christos   REG1_INST ("jump", 0xBAE),
    230  1.1  christos 
    231  1.1  christos   /* SCond instructions */
    232  1.1  christos   REG1_INST ("seq",  0xBB0),
    233  1.1  christos   REG1_INST ("sne",  0xBB1),
    234  1.1  christos   REG1_INST ("scs",  0xBB2),
    235  1.1  christos   REG1_INST ("scc",  0xBB3),
    236  1.1  christos   REG1_INST ("shi",  0xBB4),
    237  1.1  christos   REG1_INST ("sls",  0xBB5),
    238  1.1  christos   REG1_INST ("sgt",  0xBB6),
    239  1.1  christos   REG1_INST ("sle",  0xBB7),
    240  1.1  christos   REG1_INST ("sfs",  0xBB8),
    241  1.1  christos   REG1_INST ("sfc",  0xBB9),
    242  1.1  christos   REG1_INST ("slo",  0xBBA),
    243  1.1  christos   REG1_INST ("shs",  0xBBB),
    244  1.1  christos   REG1_INST ("slt",  0xBBC),
    245  1.1  christos   REG1_INST ("sge",  0xBBD),
    246  1.1  christos 
    247  1.1  christos /* Create an instruction using two register operands.  */
    248  1.1  christos #define  REG2_INST(NAME, OPC) \
    249  1.1  christos   /* opc24 r r  OR  opc20 c4 r r */			\
    250  1.1  christos   {NAME,  2, 0x300800+OPC,  8, NO_TYPE_INS, {{regr,4}, {regr,0}}}
    251  1.1  christos 
    252  1.1  christos   /* MULTIPLY INSTRUCTIONS */
    253  1.1  christos   REG2_INST ("macsb",  0x40),
    254  1.1  christos   REG2_INST ("macub",  0x41),
    255  1.1  christos   REG2_INST ("macqb",  0x42),
    256  1.1  christos 
    257  1.1  christos   REG2_INST ("macsw",  0x50),
    258  1.1  christos   REG2_INST ("macuw",  0x51),
    259  1.1  christos   REG2_INST ("macqw",  0x52),
    260  1.1  christos 
    261  1.1  christos   REG2_INST ("macsd",  0x60),
    262  1.1  christos   REG2_INST ("macud",  0x61),
    263  1.1  christos   REG2_INST ("macqd",  0x62),
    264  1.1  christos 
    265  1.1  christos   REG2_INST ("mullsd", 0x65),
    266  1.1  christos   REG2_INST ("mullud", 0x66),
    267  1.1  christos 
    268  1.1  christos   REG2_INST ("mulsbw", 0x3B),
    269  1.1  christos   REG2_INST ("mulubw", 0x3C),
    270  1.1  christos   REG2_INST ("mulswd", 0x3D),
    271  1.1  christos   REG2_INST ("muluwd", 0x3E),
    272  1.1  christos 
    273  1.1  christos   /*  SIGNEXTEND STUFF    */
    274  1.1  christos   REG2_INST ("sextbw", 0x30),
    275  1.1  christos   REG2_INST ("sextbd", 0x31),
    276  1.1  christos   REG2_INST ("sextwd", 0x32),
    277  1.1  christos   REG2_INST ("zextbw", 0x34),
    278  1.1  christos   REG2_INST ("zextbd", 0x35),
    279  1.1  christos   REG2_INST ("zextwd", 0x36),
    280  1.1  christos 
    281  1.1  christos   REG2_INST ("bswap",  0x3F),
    282  1.1  christos 
    283  1.1  christos   REG2_INST ("maxsb",  0x80),
    284  1.1  christos   REG2_INST ("minsb",  0x81),
    285  1.1  christos   REG2_INST ("maxub",  0x82),
    286  1.1  christos   REG2_INST ("minub",  0x83),
    287  1.1  christos   REG2_INST ("absb",   0x84),
    288  1.1  christos   REG2_INST ("negb",   0x85),
    289  1.1  christos   REG2_INST ("cntl0b", 0x86),
    290  1.1  christos   REG2_INST ("cntl1b", 0x87),
    291  1.1  christos   REG2_INST ("popcntb",0x88),
    292  1.1  christos   REG2_INST ("rotlb",  0x89),
    293  1.1  christos   REG2_INST ("rotrb",  0x8A),
    294  1.1  christos   REG2_INST ("mulqb",  0x8B),
    295  1.1  christos   REG2_INST ("addqb",  0x8C),
    296  1.1  christos   REG2_INST ("subqb",  0x8D),
    297  1.1  christos   REG2_INST ("cntlsb", 0x8E),
    298  1.1  christos 
    299  1.1  christos   REG2_INST ("maxsw",  0x90),
    300  1.1  christos   REG2_INST ("minsw",  0x91),
    301  1.1  christos   REG2_INST ("maxuw",  0x92),
    302  1.1  christos   REG2_INST ("minuw",  0x93),
    303  1.1  christos   REG2_INST ("absw",   0x94),
    304  1.1  christos   REG2_INST ("negw",   0x95),
    305  1.1  christos   REG2_INST ("cntl0w", 0x96),
    306  1.1  christos   REG2_INST ("cntl1w", 0x97),
    307  1.1  christos   REG2_INST ("popcntw",0x98),
    308  1.1  christos   REG2_INST ("rotlw",  0x99),
    309  1.1  christos   REG2_INST ("rotrw",  0x9A),
    310  1.1  christos   REG2_INST ("mulqw",  0x9B),
    311  1.1  christos   REG2_INST ("addqw",  0x9C),
    312  1.1  christos   REG2_INST ("subqw",  0x9D),
    313  1.1  christos   REG2_INST ("cntlsw", 0x9E),
    314  1.1  christos 
    315  1.1  christos   REG2_INST ("maxsd",  0xA0),
    316  1.1  christos   REG2_INST ("minsd",  0xA1),
    317  1.1  christos   REG2_INST ("maxud",  0xA2),
    318  1.1  christos   REG2_INST ("minud",  0xA3),
    319  1.1  christos   REG2_INST ("absd",   0xA4),
    320  1.1  christos   REG2_INST ("negd",   0xA5),
    321  1.1  christos   REG2_INST ("cntl0d", 0xA6),
    322  1.1  christos   REG2_INST ("cntl1d", 0xA7),
    323  1.1  christos   REG2_INST ("popcntd",0xA8),
    324  1.1  christos   REG2_INST ("rotld",  0xA9),
    325  1.1  christos   REG2_INST ("rotrd",  0xAA),
    326  1.1  christos   REG2_INST ("mulqd",  0xAB),
    327  1.1  christos   REG2_INST ("addqd",  0xAC),
    328  1.1  christos   REG2_INST ("subqd",  0xAD),
    329  1.1  christos   REG2_INST ("cntlsd", 0xAE),
    330  1.1  christos 
    331  1.1  christos /* Conditional move instructions */
    332  1.1  christos   REG2_INST ("cmoveqd", 0x70),
    333  1.1  christos   REG2_INST ("cmovned", 0x71),
    334  1.1  christos   REG2_INST ("cmovcsd", 0x72),
    335  1.1  christos   REG2_INST ("cmovccd", 0x73),
    336  1.1  christos   REG2_INST ("cmovhid", 0x74),
    337  1.1  christos   REG2_INST ("cmovlsd", 0x75),
    338  1.1  christos   REG2_INST ("cmovgtd", 0x76),
    339  1.1  christos   REG2_INST ("cmovled", 0x77),
    340  1.1  christos   REG2_INST ("cmovfsd", 0x78),
    341  1.1  christos   REG2_INST ("cmovfcd", 0x79),
    342  1.1  christos   REG2_INST ("cmovlod", 0x7A),
    343  1.1  christos   REG2_INST ("cmovhsd", 0x7B),
    344  1.1  christos   REG2_INST ("cmovltd", 0x7C),
    345  1.1  christos   REG2_INST ("cmovged", 0x7D),
    346  1.1  christos 
    347  1.1  christos /* Load instructions (from memory to register).  */
    348  1.1  christos #define  LD_REG_INST(NAME, OPC1, OPC2, DISP) \
    349  1.1  christos   /* opc12 r abs16 */							    \
    350  1.1  christos   {NAME,  2, 0x320+OPC1,  20, LD_STOR_INS | REVERSE_MATCH,		    \
    351  1.1  christos       {{abs16,0}, {regr,16}}},						    \
    352  1.1  christos   /* opc12 r abs32 */							    \
    353  1.1  christos   {NAME,  3, 0x330+OPC1,  20, LD_STOR_INS | REVERSE_MATCH,		    \
    354  1.1  christos       {{abs32,0}, {regr,16}}},						    \
    355  1.1  christos   /* opc4 r rbase dispu[bwd]4 */					    \
    356  1.1  christos   {NAME,  1, 0x8+OPC2,  28, LD_STOR_INS | DISP | REVERSE_MATCH,		    \
    357  1.1  christos       {{rbase_dispu4,16}, {regr,24}}},					    \
    358  1.1  christos   /* opc4 r rbase disps16 */						    \
    359  1.1  christos   {NAME,  2, ((0x8+OPC2)<<8)+0xE, 20, LD_STOR_INS | FMT_1 | REVERSE_MATCH,  \
    360  1.1  christos       {{rbase_disps16,16}, {regr,24}}},					    \
    361  1.1  christos   /* opc4 r rbase disps32 */						    \
    362  1.1  christos   {NAME,  3, ((0x8+OPC2)<<8)+0xF,  20, LD_STOR_INS | FMT_1 | REVERSE_MATCH, \
    363  1.1  christos       {{rbase_disps32,16}, {regr,24}}},					    \
    364  1.1  christos   /* opc12 r rbase ridx scl2 disps6 */					    \
    365  1.1  christos   {NAME,  2, 0x32C+OPC1,  20, LD_STOR_INS | REVERSE_MATCH,		    \
    366  1.1  christos       {{rindex_disps6,0}, {regr,16}}},					    \
    367  1.1  christos   /* opc12 r rbase ridx scl2 disps22 */					    \
    368  1.1  christos   {NAME,  3, 0x33C+OPC1,  20, LD_STOR_INS | REVERSE_MATCH,		    \
    369  1.1  christos       {{rindex_disps22,0}, {regr,16}}},					    \
    370  1.1  christos   /* opc12 r rbase disps12 */						    \
    371  1.1  christos   {NAME,  2, 0x328+OPC1,  20, LD_STOR_INS_INC | REVERSE_MATCH,		    \
    372  1.1  christos       {{rbase_disps12,12}, {regr,16}}}
    373  1.1  christos 
    374  1.1  christos   LD_REG_INST ("loadb", 0x0, 0x0, DISPUB4),
    375  1.1  christos   LD_REG_INST ("loadw", 0x1, 0x1, DISPUW4),
    376  1.1  christos   LD_REG_INST ("loadd", 0x2, 0x2, DISPUD4),
    377  1.1  christos 
    378  1.1  christos /* Store instructions (from Register to Memory).  */
    379  1.1  christos #define  ST_REG_INST(NAME, OPC1, OPC2, DISP) \
    380  1.1  christos   /* opc12 r abs16 */							      \
    381  1.1  christos   {NAME,  2, 0x320+OPC1,  20, LD_STOR_INS, {{regr,16}, {abs16,0}}},	      \
    382  1.1  christos   /* opc12 r abs32 */							      \
    383  1.1  christos   {NAME,  3, 0x330+OPC1,  20, LD_STOR_INS, {{regr,16}, {abs32,0}}},	      \
    384  1.1  christos   /* opc4 r rbase dispu[bwd]4 */					      \
    385  1.1  christos   {NAME,  1, 0x8+OPC2,  28, LD_STOR_INS | DISP,				      \
    386  1.1  christos       {{regr,24}, {rbase_dispu4,16}}},					      \
    387  1.1  christos   /* opc4 r rbase disps16 */						      \
    388  1.1  christos   {NAME,  2, ((0x8+OPC2)<<8)+0xE,  20, LD_STOR_INS | FMT_1,	  	      \
    389  1.1  christos       {{regr,24}, {rbase_disps16,16}}},					      \
    390  1.1  christos   /* opc4 r rbase disps32 */						      \
    391  1.1  christos   {NAME,  3, ((0x8+OPC2)<<8)+0xF,  20, LD_STOR_INS | FMT_1,		      \
    392  1.1  christos       {{regr,24}, {rbase_disps32,16}}},					      \
    393  1.1  christos   /* opc12 r rbase ridx scl2 disps6 */					      \
    394  1.1  christos   {NAME,  2, 0x32C+OPC1,  20, LD_STOR_INS,				      \
    395  1.1  christos       {{regr,16}, {rindex_disps6,0}}},					      \
    396  1.1  christos   /* opc12 r rbase ridx scl2 disps22 */					      \
    397  1.1  christos   {NAME,  3, 0x33C+OPC1,  20, LD_STOR_INS, {{regr,16}, {rindex_disps22,0}}},  \
    398  1.1  christos   /* opc12 r rbase disps12 */						      \
    399  1.1  christos   {NAME,  2, 0x328+OPC1,  20, LD_STOR_INS_INC, {{regr,16}, {rbase_disps12,12}}}
    400  1.1  christos 
    401  1.1  christos /* Store instructions (Immediate to Memory).  */
    402  1.1  christos #define  ST_I_INST(NAME, OPC) \
    403  1.1  christos   /* opc12 ui4 rbase disps12 */						      \
    404  1.1  christos   {NAME,  2, 0x368+OPC,	20, LD_STOR_INS_INC, {{ui4,16}, {rbase_disps12,12}}}, \
    405  1.1  christos   /* opc12 ui4 abs16 */							      \
    406  1.1  christos   {NAME,  2, 0x360+OPC,	20, STOR_IMM_INS, {{ui4,16}, {abs16,0}}},	      \
    407  1.1  christos   /* opc12 ui4 abs32 */							      \
    408  1.1  christos   {NAME,  3, 0x370+OPC,	20, STOR_IMM_INS, {{ui4,16}, {abs32,0}}},	      \
    409  1.1  christos   /* opc12 ui4 rbase disps12 */						      \
    410  1.1  christos   {NAME,  2, 0x364+OPC,	20, STOR_IMM_INS, {{ui4,16}, {rbase_disps12,12}}},    \
    411  1.1  christos   /* opc12 ui4 rbase disps28 */						      \
    412  1.1  christos   {NAME,  3, 0x374+OPC,	20, STOR_IMM_INS, {{ui4,16}, {rbase_disps28,12}}},    \
    413  1.1  christos   /* opc12 ui4 rbase ridx scl2 disps6 */				      \
    414  1.1  christos   {NAME,  2, 0x36C+OPC,	20, STOR_IMM_INS, {{ui4,16}, {rindex_disps6,0}}},     \
    415  1.1  christos   /* opc12 ui4 rbase ridx scl2 disps22 */				      \
    416  1.1  christos   {NAME,  3, 0x37C+OPC,	20, STOR_IMM_INS, {{ui4,16}, {rindex_disps22,0}}}
    417  1.1  christos 
    418  1.1  christos   ST_REG_INST ("storb", 0x20, 0x4, DISPUB4),
    419  1.1  christos   ST_I_INST ("storb",  0x0),
    420  1.1  christos 
    421  1.1  christos   ST_REG_INST ("storw", 0x21, 0x5, DISPUW4),
    422  1.1  christos   ST_I_INST ("storw",  0x1),
    423  1.1  christos 
    424  1.1  christos   ST_REG_INST ("stord", 0x22, 0x6, DISPUD4),
    425  1.1  christos   ST_I_INST ("stord",  0x2),
    426  1.1  christos 
    427  1.1  christos /* Create a bit instruction.  */
    428  1.1  christos #define  CSTBIT_INST(NAME, OP, OPC1, DIFF, SHIFT, OPC2) \
    429  1.1  christos   /* OP=ui3 -->> opc13 ui3 */						      \
    430  1.1  christos   /* OP=ui4 -->> opc12 ui4 */						      \
    431  1.1  christos   /* OP=ui5 -->> opc11 ui5 */						      \
    432  1.1  christos 									      \
    433  1.1  christos   /* opcNN iN abs16 */							      \
    434  1.1  christos   {NAME,  2, OPC1+0*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {abs16,0}}},	      \
    435  1.1  christos   /* opcNN iN abs32 */							      \
    436  1.1  christos   {NAME,  3, OPC1+1*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {abs32,0}}},	      \
    437  1.1  christos   /* opcNN iN rbase */							      \
    438  1.1  christos   {NAME,  1, OPC2,  SHIFT+4,  CSTBIT_INS, {{OP,20}, {rbase,16}}},	      \
    439  1.1  christos   /* opcNN iN rbase disps12 */						      \
    440  1.1  christos   {NAME,  2, OPC1+2*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {rbase_disps12,12}}},  \
    441  1.1  christos   /* opcNN iN rbase disps28 */						      \
    442  1.1  christos   {NAME,  3, OPC1+3*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {rbase_disps28,12}}},  \
    443  1.1  christos   /* opcNN iN rbase ridx scl2 disps6 */					      \
    444  1.1  christos   {NAME,  2, OPC1+4*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {rindex_disps6,0}}},   \
    445  1.1  christos   /* opcNN iN rbase ridx scl2 disps22 */				      \
    446  1.1  christos   {NAME,  3, OPC1+5*DIFF, SHIFT, CSTBIT_INS, {{OP,16}, {rindex_disps22,0}}}
    447  1.1  christos 
    448  1.1  christos   CSTBIT_INST ("cbitb", ui3, 0x700, 0x20, 19, 0x1FC),
    449  1.1  christos   CSTBIT_INST ("cbitw", ui4, 0x382, 0x10, 20, 0xBD),
    450  1.1  christos   CSTBIT_INST ("cbitd", ui5, 0x1C3, 0x8,  21, 0x7B),
    451  1.1  christos   {"cbitd",   2, 0x300838,  8, CSTBIT_INS, {{regr,4}, {regr,0}}},
    452  1.1  christos   {"cbitd",   2, 0x18047B,  9, CSTBIT_INS, {{ui5,4}, {regr,0}}},
    453  1.1  christos 
    454  1.1  christos   CSTBIT_INST ("sbitb", ui3, 0x701, 0x20, 19, 0x1FD),
    455  1.1  christos   CSTBIT_INST ("sbitw", ui4, 0x383, 0x10, 20, 0xBE),
    456  1.1  christos   CSTBIT_INST ("sbitd", ui5, 0x1C4, 0x8,  21, 0x7C),
    457  1.1  christos   {"sbitd",   2, 0x300839,  8, CSTBIT_INS, {{regr,4}, {regr,0}}},
    458  1.1  christos   {"sbitd",   2, 0x18047C,  9, CSTBIT_INS, {{ui5,4}, {regr,0}}},
    459  1.1  christos 
    460  1.1  christos   CSTBIT_INST ("tbitb", ui3, 0x702, 0x20, 19, 0x1FE),
    461  1.1  christos   CSTBIT_INST ("tbitw", ui4, 0x384, 0x10, 20, 0xBF),
    462  1.1  christos   CSTBIT_INST ("tbitd", ui5, 0x1C5, 0x8,  21, 0x7D),
    463  1.1  christos   {"tbitd",   2, 0x30083A,  8, CSTBIT_INS, {{regr,4}, {regr,0}}},
    464  1.1  christos   {"tbitd",   2, 0x18047D,  9, CSTBIT_INS, {{ui5,4}, {regr,0}}},
    465  1.1  christos 
    466  1.1  christos /* Instructions including a register list (opcode is represented as a mask).  */
    467  1.1  christos #define  REGLIST_INST(NAME, OPC, FLAG) \
    468  1.1  christos   /* opc12 r mask16 */							    \
    469  1.1  christos   {NAME,  2, OPC, 20, NO_TYPE_INS | REG_LIST | FLAG, {{regr,16}, {ui16,0}}}
    470  1.1  christos 
    471  1.1  christos   REG1_INST ("getrfid",	0xFF9),
    472  1.1  christos   REG1_INST ("setrfid",	0xFFA),
    473  1.1  christos 
    474  1.1  christos   REGLIST_INST ("push",	 0x346,	 NO_RPTR),
    475  1.1  christos   REG1_FLAG_INST ("push", 0xFFB, NO_SP),
    476  1.1  christos   REGLIST_INST ("pushx", 0x347,	 NO_RPTR),
    477  1.1  christos 
    478  1.1  christos   REGLIST_INST ("pop",	 0x324,	 NO_RPTR),
    479  1.1  christos   REG1_FLAG_INST ("pop", 0xFFC,	 NO_SP),
    480  1.1  christos   REGLIST_INST ("popx",	 0x327,	 NO_RPTR),
    481  1.1  christos 
    482  1.1  christos   REGLIST_INST ("popret", 0x326, NO_RPTR),
    483  1.1  christos   REG1_FLAG_INST ("popret",0xFFD,NO_SP),
    484  1.1  christos 
    485  1.1  christos   REGLIST_INST ("loadm",  0x324, NO_RPTR),
    486  1.1  christos   REGLIST_INST ("loadma", 0x325, USER_REG),
    487  1.1  christos 
    488  1.1  christos   REGLIST_INST ("storm",  0x344, NO_RPTR),
    489  1.1  christos   REGLIST_INST ("storma", 0x345, USER_REG),
    490  1.1  christos 
    491  1.1  christos /* Create a branch instruction.  */
    492  1.1  christos #define  BR_INST(NAME, OPC1, OPC2, INS_TYPE) \
    493  1.1  christos   /* opc12 r disps17 */							  \
    494  1.1  christos   {NAME,  2, OPC1,  20, INS_TYPE | RELAXABLE, {{regr,16}, {disps17,0}}},  \
    495  1.1  christos   /* opc12 r disps32 */							  \
    496  1.1  christos   {NAME,  3, OPC2,  20, INS_TYPE | RELAXABLE, {{regr,16}, {disps32,0}}}
    497  1.1  christos 
    498  1.1  christos   BR_INST ("bal",   0x307, 0x317, NO_TYPE_INS),
    499  1.1  christos 
    500  1.1  christos   /* Decrement and Branch instructions.  */
    501  1.1  christos   BR_INST ("dbnzb", 0x304, 0x314, DCR_BRANCH_INS),
    502  1.1  christos   BR_INST ("dbnzw", 0x305, 0x315, DCR_BRANCH_INS),
    503  1.1  christos   BR_INST ("dbnzd", 0x306, 0x316, DCR_BRANCH_INS),
    504  1.1  christos 
    505  1.1  christos   /* Jump and link instructions.  */
    506  1.1  christos   REG1_INST ("jal",    0xFF8),
    507  1.1  christos   REG2_INST ("jal",    0x37),
    508  1.1  christos   REG2_INST ("jalid",  0x33),
    509  1.1  christos 
    510  1.1  christos /* Create a CO-processor instruction.  */
    511  1.1  christos   /* esc12 c4 ui16 */
    512  1.1  christos   {"cpi",  2, 0x301,  20, COP_REG_INS, {{ui4,16}, {ui16,0}}},
    513  1.1  christos   /* esc12 c4 ui16 ui16 */
    514  1.1  christos   {"cpi",  3, 0x311,  20, COP_REG_INS, {{ui4,16}, {ui16,0}, {ui16,16}}},
    515  1.1  christos 
    516  1.1  christos #define  COP_INST(NAME, OPC, TYPE, REG1, REG2) \
    517  1.1  christos   /* opc12 c4 opc8 REG1 REG2 */						      \
    518  1.1  christos   {NAME,  2, 0x301030+OPC,  8, TYPE | FMT_2, {{ui4,16}, {REG1,4}, {REG2,0}}}
    519  1.1  christos /* A reverse form of the above macro.  */
    520  1.1  christos #define  REV_COP_INST(NAME, OPC, TYPE, REG1, REG2) \
    521  1.1  christos   /* opc12 c4 opc8 REG2 REG1 */						      \
    522  1.1  christos   {NAME,  2, 0x301030+OPC,  8, TYPE | FMT_2, {{ui4,16}, {REG1,0}, {REG2,4}}}
    523  1.1  christos 
    524  1.1  christos   COP_INST	("mtcr",   0, COP_REG_INS,	regr,	  copregr),
    525  1.1  christos   COP_INST	("mfcr",   1, COP_REG_INS,	copregr,  regr),
    526  1.1  christos   COP_INST	("mtcsr",  2, COPS_REG_INS,	regr,	  copsregr),
    527  1.1  christos   COP_INST	("mfcsr",  3, COPS_REG_INS,	copsregr, regr),
    528  1.1  christos   COP_INST	("ldcr",   4, COP_REG_INS,	regr,	  copregr),
    529  1.1  christos   REV_COP_INST	("stcr",   5, COP_REG_INS,	copregr,  regr),
    530  1.1  christos   COP_INST	("ldcsr",  6, COPS_REG_INS,	regr,     copsregr),
    531  1.1  christos   REV_COP_INST	("stcsr",  7, COPS_REG_INS,	copsregr, regr),
    532  1.1  christos 
    533  1.1  christos /* Create a memory-related CO-processor instruction.  */
    534  1.1  christos #define  COPMEM_INST(NAME, OPC, TYPE) \
    535  1.1  christos   /* opc12 c4 opc12 r mask16 */				  \
    536  1.1  christos   {NAME,  3, 0x3110300+OPC,  4, TYPE | REG_LIST | FMT_5,  \
    537  1.1  christos       {{ui4,16}, {regr,0}, {ui16,16}}}
    538  1.1  christos 
    539  1.1  christos   COPMEM_INST("loadmcr",  0,  COP_REG_INS),
    540  1.1  christos   COPMEM_INST("stormcr",  1,  COP_REG_INS),
    541  1.1  christos   COPMEM_INST("loadmcsr", 2,  COPS_REG_INS),
    542  1.1  christos   COPMEM_INST("stormcsr", 3,  COPS_REG_INS),
    543  1.1  christos 
    544  1.1  christos   /* CO-processor extensions.  */
    545  1.1  christos   /* opc12 c4 opc4 ui4 disps9 */
    546  1.3  christos   {"bcop",    2, 0x30107, 12, COP_BRANCH_INS | FMT_4 | RELAXABLE,
    547  1.1  christos       {{ui4,8}, {ui4,16}, {disps9,0}}},
    548  1.1  christos   /* opc12 c4 opc4 ui4 disps25 */
    549  1.3  christos   {"bcop",    3, 0x31107, 12, COP_BRANCH_INS | FMT_4 | RELAXABLE,
    550  1.1  christos       {{ui4,8}, {ui4,16}, {disps25,0}}},
    551  1.1  christos   /* opc12 c4 opc4 cpdo r r */
    552  1.3  christos   {"cpdop",   2, 0x3010B, 12, COP_REG_INS | FMT_4,
    553  1.1  christos       {{ui4,16}, {ui4,8}, {regr,4}, {regr,0}}},
    554  1.1  christos   /* opc12 c4 opc4 cpdo r r cpdo16 */
    555  1.3  christos   {"cpdop",   3, 0x3110B, 12, COP_REG_INS | FMT_4,
    556  1.1  christos       {{ui4,16}, {ui4,8}, {regr,4}, {regr,0}, {ui16,16}}},
    557  1.1  christos   /* esc16 r procreg */
    558  1.1  christos   {"mtpr",    2, 0x3009,  16, NO_TYPE_INS, {{regr8,8}, {regr8,0}}},
    559  1.1  christos   /* esc16 procreg r */
    560  1.1  christos   {"mfpr",    2, 0x300A,  16, NO_TYPE_INS, {{regr8,8}, {regr8,0}}},
    561  1.1  christos 
    562  1.1  christos   /* Miscellaneous.  */
    563  1.1  christos   /* opc12 ui4 */
    564  1.1  christos   {"excp",    1, 0xFFF,	20, NO_TYPE_INS, {{ui4,16}}},
    565  1.1  christos   /* opc28 ui4 */
    566  1.1  christos   {"cinv",    2, 0x3010000, 4,	NO_TYPE_INS, {{ui4,0}}},
    567  1.1  christos 
    568  1.1  christos   /* opc9 ui5 ui5 ui5 r r */
    569  1.3  christos   {"ram", 2, 0x7C,  23, NO_TYPE_INS,
    570  1.1  christos       {{ui5,18}, {ui5,13}, {ui5,8}, {regr,4}, {regr,0}}},
    571  1.3  christos   {"rim", 2, 0x7D,  23, NO_TYPE_INS,
    572  1.1  christos       {{ui5,18}, {ui5,13}, {ui5,8}, {regr,4}, {regr,0}}},
    573  1.1  christos 
    574  1.1  christos   /* opc9 ui3 r */
    575  1.1  christos   {"rotb",    1, 0x1FB,	23, NO_TYPE_INS, {{ui3,20}, {regr,16}}},
    576  1.1  christos   /* opc8 ui4 r */
    577  1.1  christos   {"rotw",    1, 0xB9,	24, NO_TYPE_INS, {{ui4,20}, {regr,16}}},
    578  1.1  christos   /* opc23 ui5 r */
    579  1.1  christos   {"rotd",    2, 0x180478,  9, NO_TYPE_INS, {{ui5,4}, {regr,0}}},
    580  1.1  christos 
    581  1.1  christos   {NULL,      0, 0, 0,	0, {{0, 0}}}
    582  1.1  christos };
    583  1.1  christos 
    584  1.1  christos const int crx_num_opcodes = ARRAY_SIZE (crx_instruction);
    585  1.1  christos 
    586  1.1  christos /* Macro to build a reg_entry, which have an opcode image :
    587  1.1  christos    For example :
    588  1.1  christos       REG(u4, 0x84, CRX_U_REGTYPE)
    589  1.1  christos    is interpreted as :
    590  1.3  christos       {"u4",  u4, 0x84, CRX_U_REGTYPE}
    591  1.3  christos    The union initializer (second member) always refers to the first
    592  1.3  christos    member of the union, so cast NAME to that type to avoid possible
    593  1.3  christos    compiler warnings when used for non-CRX_R_REGTYPE cases.  */
    594  1.3  christos #define REG(NAME, N, TYPE)    {STRINGX(NAME), {(reg) NAME}, N, TYPE}
    595  1.1  christos 
    596  1.1  christos const reg_entry crx_regtab[] =
    597  1.1  christos {
    598  1.1  christos /* Build a general purpose register r<N>.  */
    599  1.1  christos #define REG_R(N)    REG(CONCAT2(r,N), N, CRX_R_REGTYPE)
    600  1.1  christos 
    601  1.1  christos   REG_R(0),  REG_R(1),	REG_R(2),  REG_R(3),
    602  1.1  christos   REG_R(4),  REG_R(5),	REG_R(6),  REG_R(7),
    603  1.1  christos   REG_R(8),  REG_R(9),	REG_R(10), REG_R(11),
    604  1.1  christos   REG_R(12), REG_R(13), REG_R(14), REG_R(15),
    605  1.1  christos   REG(ra, 0xe, CRX_R_REGTYPE),
    606  1.1  christos   REG(sp, 0xf, CRX_R_REGTYPE),
    607  1.1  christos 
    608  1.1  christos /* Build a user register u<N>.  */
    609  1.1  christos #define REG_U(N)    REG(CONCAT2(u,N), 0x80 + N, CRX_U_REGTYPE)
    610  1.1  christos 
    611  1.1  christos   REG_U(0),  REG_U(1),  REG_U(2),  REG_U(3),
    612  1.1  christos   REG_U(4),  REG_U(5),  REG_U(6),  REG_U(7),
    613  1.1  christos   REG_U(8),  REG_U(9),  REG_U(10), REG_U(11),
    614  1.1  christos   REG_U(12), REG_U(13), REG_U(14), REG_U(15),
    615  1.1  christos   REG(ura, 0x8e, CRX_U_REGTYPE),
    616  1.1  christos   REG(usp, 0x8f, CRX_U_REGTYPE),
    617  1.1  christos 
    618  1.1  christos /* Build a configuration register.  */
    619  1.1  christos #define REG_CFG(NAME, N)    REG(NAME, N, CRX_CFG_REGTYPE)
    620  1.1  christos 
    621  1.1  christos   REG_CFG(hi,	    0x10),
    622  1.1  christos   REG_CFG(lo,	    0x11),
    623  1.1  christos   REG_CFG(uhi,	    0x90),
    624  1.1  christos   REG_CFG(ulo,	    0x91),
    625  1.1  christos   REG_CFG(psr,	    0x12),
    626  1.1  christos   REG_CFG(intbase,  0x13),
    627  1.1  christos   REG_CFG(isp,	    0x14),
    628  1.1  christos   REG_CFG(cfg,	    0x15),
    629  1.1  christos   REG_CFG(cpcfg,    0x16),
    630  1.1  christos   REG_CFG(cen,	    0x17)
    631  1.1  christos };
    632  1.1  christos 
    633  1.1  christos const int crx_num_regs = ARRAY_SIZE (crx_regtab);
    634  1.1  christos 
    635  1.1  christos const reg_entry crx_copregtab[] =
    636  1.1  christos {
    637  1.1  christos /* Build a Coprocessor register c<N>.  */
    638  1.1  christos #define REG_C(N)    REG(CONCAT2(c,N), N, CRX_C_REGTYPE)
    639  1.1  christos 
    640  1.1  christos   REG_C(0),  REG_C(1),	REG_C(2),  REG_C(3),
    641  1.1  christos   REG_C(4),  REG_C(5),	REG_C(6),  REG_C(7),
    642  1.1  christos   REG_C(8),  REG_C(9),	REG_C(10), REG_C(11),
    643  1.1  christos   REG_C(12), REG_C(13), REG_C(14), REG_C(15),
    644  1.1  christos 
    645  1.1  christos /* Build a Coprocessor Special register cs<N>.  */
    646  1.1  christos #define REG_CS(N)    REG(CONCAT2(cs,N), N, CRX_CS_REGTYPE)
    647  1.1  christos 
    648  1.1  christos   REG_CS(0),  REG_CS(1),  REG_CS(2),  REG_CS(3),
    649  1.1  christos   REG_CS(4),  REG_CS(5),  REG_CS(6),  REG_CS(7),
    650  1.1  christos   REG_CS(8),  REG_CS(9),  REG_CS(10), REG_CS(11),
    651  1.1  christos   REG_CS(12), REG_CS(13), REG_CS(14), REG_CS(15)
    652  1.1  christos };
    653  1.1  christos 
    654  1.1  christos const int crx_num_copregs = ARRAY_SIZE (crx_copregtab);
    655  1.1  christos 
    656  1.1  christos /* CRX operands table.  */
    657  1.1  christos const operand_entry crx_optab[] =
    658  1.1  christos {
    659  1.1  christos   /* Index 0 is dummy, so we can count the instruction's operands.  */
    660  1.1  christos   {0,	nullargs,   0},					/* dummy */
    661  1.1  christos   {4,	arg_ic,	    OP_CST4},				/* cst4 */
    662  1.1  christos   {16,	arg_ic,	    OP_SIGNED},				/* i16 */
    663  1.1  christos   {32,	arg_ic,	    OP_SIGNED},				/* i32 */
    664  1.1  christos   {3,	arg_ic,	    OP_UNSIGNED},			/* ui3 */
    665  1.1  christos   {4,	arg_ic,	    OP_UNSIGNED},		        /* ui4 */
    666  1.1  christos   {5,	arg_ic,	    OP_UNSIGNED},		        /* ui5 */
    667  1.1  christos   {16,	arg_ic,	    OP_UNSIGNED},		        /* ui16 */
    668  1.1  christos   {8,	arg_c,	    OP_EVEN|OP_SHIFT|OP_SIGNED},	/* disps9 */
    669  1.1  christos   {16,	arg_c,	    OP_EVEN|OP_SHIFT|OP_SIGNED},	/* disps17 */
    670  1.1  christos   {24,	arg_c,	    OP_EVEN|OP_SHIFT|OP_SIGNED},	/* disps25 */
    671  1.1  christos   {32,	arg_c,	    OP_EVEN|OP_SHIFT|OP_SIGNED},	/* disps32 */
    672  1.1  christos   {4,	arg_c,	    OP_EVEN|OP_SHIFT_DEC|OP_UNSIGNED},  /* dispu5 */
    673  1.1  christos   {8,	arg_c,	    OP_EVEN|OP_SHIFT|OP_SIGNED|OP_ESC}, /* dispe9 */
    674  1.1  christos   {16,	arg_c,	    OP_UNSIGNED|OP_UPPER_64KB},		/* abs16 */
    675  1.1  christos   {32,	arg_c,	    OP_UNSIGNED},			/* abs32 */
    676  1.1  christos   {4,	arg_rbase,  0},					/* rbase */
    677  1.1  christos   {4,	arg_cr,	    OP_DISPU4},				/* rbase_dispu4 */
    678  1.1  christos   {12,	arg_cr,	    OP_SIGNED},				/* rbase_disps12 */
    679  1.1  christos   {16,	arg_cr,	    OP_SIGNED},				/* rbase_disps16 */
    680  1.1  christos   {28,	arg_cr,	    OP_SIGNED},				/* rbase_disps28 */
    681  1.1  christos   {32,	arg_cr,	    OP_SIGNED},				/* rbase_disps32 */
    682  1.1  christos   {6,	arg_idxr,   OP_SIGNED},				/* rindex_disps6 */
    683  1.1  christos   {22,  arg_idxr,   OP_SIGNED},				/* rindex_disps22 */
    684  1.1  christos   {4,	arg_r,	    0},					/* regr */
    685  1.1  christos   {8,	arg_r,	    0},					/* regr8 */
    686  1.1  christos   {4,	arg_copr,   0},					/* copregr */
    687  1.1  christos   {4,	arg_copsr,  0}					/* copsregr */
    688  1.1  christos };
    689  1.1  christos 
    690  1.1  christos /* CRX traps/interrupts.  */
    691  1.1  christos const trap_entry crx_traps[] =
    692  1.1  christos {
    693  1.1  christos   {"nmi", 1}, {"svc", 5}, {"dvz", 6}, {"flg", 7},
    694  1.1  christos   {"bpt", 8}, {"und", 10}, {"prv", 11}, {"iberr", 12}
    695  1.1  christos };
    696  1.1  christos 
    697  1.1  christos const int crx_num_traps = ARRAY_SIZE (crx_traps);
    698  1.1  christos 
    699  1.1  christos /* cst4 operand mapping:
    700  1.1  christos The value in entry <N> is mapped to the value <N>
    701  1.1  christos       Value		  Binary mapping
    702  1.1  christos     cst4_map[N]	  -->>		N
    703  1.1  christos 
    704  1.1  christos Example (for N=5):
    705  1.1  christos 
    706  1.1  christos     cst4_map[5]=-4  -->>	5		*/
    707  1.6  christos const int crx_cst4_map[] =
    708  1.1  christos {
    709  1.1  christos   0, 1, 2, 3, 4, -4, -1, 7, 8, 16, 32, 20, 12, 48
    710  1.1  christos };
    711  1.1  christos 
    712  1.6  christos const int crx_cst4_maps = ARRAY_SIZE (crx_cst4_map);
    713  1.1  christos 
    714  1.1  christos /* CRX instructions that don't have arguments.  */
    715  1.6  christos const char* crx_no_op_insn[] =
    716  1.1  christos {
    717  1.1  christos   "di", "ei", "eiwait", "nop", "retx", "wait", NULL
    718  1.1  christos };
    719