Home | History | Annotate | Line # | Download | only in include
mips_opcode.h revision 1.8.6.2
      1  1.8.6.2  nathanw /*	$NetBSD: mips_opcode.h,v 1.8.6.2 2002/08/01 02:42:31 nathanw Exp $	*/
      2  1.8.6.2  nathanw 
      3  1.8.6.2  nathanw /*-
      4  1.8.6.2  nathanw  * Copyright (c) 1992, 1993
      5  1.8.6.2  nathanw  *	The Regents of the University of California.  All rights reserved.
      6  1.8.6.2  nathanw  *
      7  1.8.6.2  nathanw  * This code is derived from software contributed to Berkeley by
      8  1.8.6.2  nathanw  * Ralph Campbell.
      9  1.8.6.2  nathanw  *
     10  1.8.6.2  nathanw  * Redistribution and use in source and binary forms, with or without
     11  1.8.6.2  nathanw  * modification, are permitted provided that the following conditions
     12  1.8.6.2  nathanw  * are met:
     13  1.8.6.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     14  1.8.6.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     15  1.8.6.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.8.6.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     17  1.8.6.2  nathanw  *    documentation and/or other materials provided with the distribution.
     18  1.8.6.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     19  1.8.6.2  nathanw  *    must display the following acknowledgement:
     20  1.8.6.2  nathanw  *	This product includes software developed by the University of
     21  1.8.6.2  nathanw  *	California, Berkeley and its contributors.
     22  1.8.6.2  nathanw  * 4. Neither the name of the University nor the names of its contributors
     23  1.8.6.2  nathanw  *    may be used to endorse or promote products derived from this software
     24  1.8.6.2  nathanw  *    without specific prior written permission.
     25  1.8.6.2  nathanw  *
     26  1.8.6.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  1.8.6.2  nathanw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  1.8.6.2  nathanw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  1.8.6.2  nathanw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  1.8.6.2  nathanw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  1.8.6.2  nathanw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  1.8.6.2  nathanw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  1.8.6.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  1.8.6.2  nathanw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  1.8.6.2  nathanw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  1.8.6.2  nathanw  * SUCH DAMAGE.
     37  1.8.6.2  nathanw  *
     38  1.8.6.2  nathanw  *	@(#)mips_opcode.h	8.1 (Berkeley) 6/10/93
     39  1.8.6.2  nathanw  */
     40  1.8.6.2  nathanw 
     41  1.8.6.2  nathanw /*
     42  1.8.6.2  nathanw  * Define the instruction formats and opcode values for the
     43  1.8.6.2  nathanw  * MIPS instruction set.
     44  1.8.6.2  nathanw  */
     45  1.8.6.2  nathanw 
     46  1.8.6.2  nathanw /*
     47  1.8.6.2  nathanw  * Define the instruction formats.
     48  1.8.6.2  nathanw  */
     49  1.8.6.2  nathanw typedef union {
     50  1.8.6.2  nathanw 	unsigned word;
     51  1.8.6.2  nathanw 
     52  1.8.6.2  nathanw #if BYTE_ORDER == LITTLE_ENDIAN
     53  1.8.6.2  nathanw 	struct {
     54  1.8.6.2  nathanw 		unsigned imm: 16;
     55  1.8.6.2  nathanw 		unsigned rt: 5;
     56  1.8.6.2  nathanw 		unsigned rs: 5;
     57  1.8.6.2  nathanw 		unsigned op: 6;
     58  1.8.6.2  nathanw 	} IType;
     59  1.8.6.2  nathanw 
     60  1.8.6.2  nathanw 	struct {
     61  1.8.6.2  nathanw 		unsigned target: 26;
     62  1.8.6.2  nathanw 		unsigned op: 6;
     63  1.8.6.2  nathanw 	} JType;
     64  1.8.6.2  nathanw 
     65  1.8.6.2  nathanw 	struct {
     66  1.8.6.2  nathanw 		unsigned func: 6;
     67  1.8.6.2  nathanw 		unsigned shamt: 5;
     68  1.8.6.2  nathanw 		unsigned rd: 5;
     69  1.8.6.2  nathanw 		unsigned rt: 5;
     70  1.8.6.2  nathanw 		unsigned rs: 5;
     71  1.8.6.2  nathanw 		unsigned op: 6;
     72  1.8.6.2  nathanw 	} RType;
     73  1.8.6.2  nathanw 
     74  1.8.6.2  nathanw 	struct {
     75  1.8.6.2  nathanw 		unsigned func: 6;
     76  1.8.6.2  nathanw 		unsigned fd: 5;
     77  1.8.6.2  nathanw 		unsigned fs: 5;
     78  1.8.6.2  nathanw 		unsigned ft: 5;
     79  1.8.6.2  nathanw 		unsigned fmt: 4;
     80  1.8.6.2  nathanw 		unsigned : 1;		/* always '1' */
     81  1.8.6.2  nathanw 		unsigned op: 6;		/* always '0x11' */
     82  1.8.6.2  nathanw 	} FRType;
     83  1.8.6.2  nathanw #endif
     84  1.8.6.2  nathanw #if BYTE_ORDER == BIG_ENDIAN
     85  1.8.6.2  nathanw 	struct {
     86  1.8.6.2  nathanw 		unsigned op: 6;
     87  1.8.6.2  nathanw 		unsigned rs: 5;
     88  1.8.6.2  nathanw 		unsigned rt: 5;
     89  1.8.6.2  nathanw 		unsigned imm: 16;
     90  1.8.6.2  nathanw 	} IType;
     91  1.8.6.2  nathanw 
     92  1.8.6.2  nathanw 	struct {
     93  1.8.6.2  nathanw 		unsigned op: 6;
     94  1.8.6.2  nathanw 		unsigned target: 26;
     95  1.8.6.2  nathanw 	} JType;
     96  1.8.6.2  nathanw 
     97  1.8.6.2  nathanw 	struct {
     98  1.8.6.2  nathanw 		unsigned op: 6;
     99  1.8.6.2  nathanw 		unsigned rs: 5;
    100  1.8.6.2  nathanw 		unsigned rt: 5;
    101  1.8.6.2  nathanw 		unsigned rd: 5;
    102  1.8.6.2  nathanw 		unsigned shamt: 5;
    103  1.8.6.2  nathanw 		unsigned func: 6;
    104  1.8.6.2  nathanw 	} RType;
    105  1.8.6.2  nathanw 
    106  1.8.6.2  nathanw 	struct {
    107  1.8.6.2  nathanw 		unsigned op: 6;		/* always '0x11' */
    108  1.8.6.2  nathanw 		unsigned : 1;		/* always '1' */
    109  1.8.6.2  nathanw 		unsigned fmt: 4;
    110  1.8.6.2  nathanw 		unsigned ft: 5;
    111  1.8.6.2  nathanw 		unsigned fs: 5;
    112  1.8.6.2  nathanw 		unsigned fd: 5;
    113  1.8.6.2  nathanw 		unsigned func: 6;
    114  1.8.6.2  nathanw 	} FRType;
    115  1.8.6.2  nathanw #endif
    116  1.8.6.2  nathanw } InstFmt;
    117  1.8.6.2  nathanw 
    118  1.8.6.2  nathanw /*
    119  1.8.6.2  nathanw  * Values for the 'op' field.
    120  1.8.6.2  nathanw  */
    121  1.8.6.2  nathanw #define OP_SPECIAL	000
    122  1.8.6.2  nathanw #define OP_BCOND	001
    123  1.8.6.2  nathanw #define OP_J		002
    124  1.8.6.2  nathanw #define	OP_JAL		003
    125  1.8.6.2  nathanw #define OP_BEQ		004
    126  1.8.6.2  nathanw #define OP_BNE		005
    127  1.8.6.2  nathanw #define OP_BLEZ		006
    128  1.8.6.2  nathanw #define OP_BGTZ		007
    129  1.8.6.2  nathanw #define OP_SYNC		017
    130  1.8.6.2  nathanw 
    131  1.8.6.2  nathanw #define OP_ADDI		010
    132  1.8.6.2  nathanw #define OP_ADDIU	011
    133  1.8.6.2  nathanw #define OP_SLTI		012
    134  1.8.6.2  nathanw #define OP_SLTIU	013
    135  1.8.6.2  nathanw #define OP_ANDI		014
    136  1.8.6.2  nathanw #define OP_ORI		015
    137  1.8.6.2  nathanw #define OP_XORI		016
    138  1.8.6.2  nathanw #define OP_LUI		017
    139  1.8.6.2  nathanw 
    140  1.8.6.2  nathanw #define OP_COP0		020
    141  1.8.6.2  nathanw #define OP_COP1		021
    142  1.8.6.2  nathanw #define OP_COP2		022
    143  1.8.6.2  nathanw #define OP_COP3		023
    144  1.8.6.2  nathanw #define OP_BEQL		024		/* MIPS-II, for r4000 port */
    145  1.8.6.2  nathanw #define OP_BNEL		025		/* MIPS-II, for r4000 port */
    146  1.8.6.2  nathanw #define OP_BLEZL	026		/* MIPS-II, for r4000 port */
    147  1.8.6.2  nathanw #define OP_BGTZL	027		/* MIPS-II, for r4000 port */
    148  1.8.6.2  nathanw 
    149  1.8.6.2  nathanw #define OP_DADDI	030		/* MIPS-II, for r4000 port */
    150  1.8.6.2  nathanw #define OP_DADDIU	031		/* MIPS-II, for r4000 port */
    151  1.8.6.2  nathanw #define OP_LDL		032		/* MIPS-II, for r4000 port */
    152  1.8.6.2  nathanw #define OP_LDR		033		/* MIPS-II, for r4000 port */
    153  1.8.6.2  nathanw 
    154  1.8.6.2  nathanw #define OP_SPECIAL2	034		/* QED opcodes */
    155  1.8.6.2  nathanw 
    156  1.8.6.2  nathanw #define OP_LB		040
    157  1.8.6.2  nathanw #define OP_LH		041
    158  1.8.6.2  nathanw #define OP_LWL		042
    159  1.8.6.2  nathanw #define OP_LW		043
    160  1.8.6.2  nathanw #define OP_LBU		044
    161  1.8.6.2  nathanw #define OP_LHU		045
    162  1.8.6.2  nathanw #define OP_LWR		046
    163  1.8.6.2  nathanw #define OP_LHU		045
    164  1.8.6.2  nathanw #define OP_LWR		046
    165  1.8.6.2  nathanw #define OP_LWU		047		/* MIPS-II, for r4000 port */
    166  1.8.6.2  nathanw 
    167  1.8.6.2  nathanw #define OP_SB		050
    168  1.8.6.2  nathanw #define OP_SH		051
    169  1.8.6.2  nathanw #define OP_SWL		052
    170  1.8.6.2  nathanw #define OP_SW		053
    171  1.8.6.2  nathanw #define OP_SDL		054		/* MIPS-II, for r4000 port */
    172  1.8.6.2  nathanw #define OP_SDR		055		/* MIPS-II, for r4000 port */
    173  1.8.6.2  nathanw #define OP_SWR		056
    174  1.8.6.2  nathanw #define OP_CACHE	057		/* MIPS-II, for r4000 port */
    175  1.8.6.2  nathanw 
    176  1.8.6.2  nathanw #define OP_LL		060
    177  1.8.6.2  nathanw #define OP_LWC0		OP_LL	/* backwards source compatibility */
    178  1.8.6.2  nathanw #define OP_LWC1		061
    179  1.8.6.2  nathanw #define OP_LWC2		062
    180  1.8.6.2  nathanw #define OP_LWC3		063
    181  1.8.6.2  nathanw #define OP_LLD		064		/* MIPS-II, for r4000 port */
    182  1.8.6.2  nathanw #define OP_LDC1		065
    183  1.8.6.2  nathanw #define OP_LD		067		/* MIPS-II, for r4000 port */
    184  1.8.6.2  nathanw 
    185  1.8.6.2  nathanw #define OP_SC		070
    186  1.8.6.2  nathanw #define OP_SWC0		OP_SC	/* backwards source compatibility */
    187  1.8.6.2  nathanw #define OP_SWC1		071
    188  1.8.6.2  nathanw #define OP_SWC2		072
    189  1.8.6.2  nathanw #define OP_SWC3		073
    190  1.8.6.2  nathanw #define OP_SCD		074		/* MIPS-II, for r4000 port */
    191  1.8.6.2  nathanw #define OP_SDC1		075
    192  1.8.6.2  nathanw #define OP_SD		077		/* MIPS-II, for r4000 port */
    193  1.8.6.2  nathanw 
    194  1.8.6.2  nathanw /*
    195  1.8.6.2  nathanw  * Values for the 'func' field when 'op' == OP_SPECIAL.
    196  1.8.6.2  nathanw  */
    197  1.8.6.2  nathanw #define OP_SLL		000
    198  1.8.6.2  nathanw #define OP_SRL		002
    199  1.8.6.2  nathanw #define OP_SRA		003
    200  1.8.6.2  nathanw #define OP_SLLV		004
    201  1.8.6.2  nathanw #define OP_SRLV		006
    202  1.8.6.2  nathanw #define OP_SRAV		007
    203  1.8.6.2  nathanw 
    204  1.8.6.2  nathanw #define OP_JR		010
    205  1.8.6.2  nathanw #define OP_JALR		011
    206  1.8.6.2  nathanw #define OP_SYSCALL	014
    207  1.8.6.2  nathanw #define OP_BREAK	015
    208  1.8.6.2  nathanw #define OP_SYNC		017		/* MIPS-II, for r4000 port */
    209  1.8.6.2  nathanw 
    210  1.8.6.2  nathanw #define OP_MFHI		020
    211  1.8.6.2  nathanw #define OP_MTHI		021
    212  1.8.6.2  nathanw #define OP_MFLO		022
    213  1.8.6.2  nathanw #define OP_MTLO		023
    214  1.8.6.2  nathanw #define OP_DSLLV	024		/* MIPS-II, for r4000 port */
    215  1.8.6.2  nathanw #define OP_DSRLV	026		/* MIPS-II, for r4000 port */
    216  1.8.6.2  nathanw #define OP_DSRAV	027		/* MIPS-II, for r4000 port */
    217  1.8.6.2  nathanw 
    218  1.8.6.2  nathanw #define OP_MULT		030
    219  1.8.6.2  nathanw #define OP_MULTU	031
    220  1.8.6.2  nathanw #define OP_DIV		032
    221  1.8.6.2  nathanw #define OP_DIVU		033
    222  1.8.6.2  nathanw #define OP_DMULT	034		/* MIPS-II, for r4000 port */
    223  1.8.6.2  nathanw #define OP_DMULTU	035		/* MIPS-II, for r4000 port */
    224  1.8.6.2  nathanw #define OP_DDIV		036		/* MIPS-II, for r4000 port */
    225  1.8.6.2  nathanw #define OP_DDIVU	037		/* MIPS-II, for r4000 port */
    226  1.8.6.2  nathanw 
    227  1.8.6.2  nathanw #define OP_ADD		040
    228  1.8.6.2  nathanw #define OP_ADDU		041
    229  1.8.6.2  nathanw #define OP_SUB		042
    230  1.8.6.2  nathanw #define OP_SUBU		043
    231  1.8.6.2  nathanw #define OP_AND		044
    232  1.8.6.2  nathanw #define OP_OR		045
    233  1.8.6.2  nathanw #define OP_XOR		046
    234  1.8.6.2  nathanw #define OP_NOR		047
    235  1.8.6.2  nathanw 
    236  1.8.6.2  nathanw #define OP_SLT		052
    237  1.8.6.2  nathanw #define OP_SLTU		053
    238  1.8.6.2  nathanw #define OP_DADD		054		/* MIPS-II, for r4000 port */
    239  1.8.6.2  nathanw #define OP_DADDU	055		/* MIPS-II, for r4000 port */
    240  1.8.6.2  nathanw #define OP_DSUB		056		/* MIPS-II, for r4000 port */
    241  1.8.6.2  nathanw #define OP_DSUBU	057		/* MIPS-II, for r4000 port */
    242  1.8.6.2  nathanw 
    243  1.8.6.2  nathanw #define OP_TGE		060		/* MIPS-II, for r4000 port */
    244  1.8.6.2  nathanw #define OP_TGEU		061		/* MIPS-II, for r4000 port */
    245  1.8.6.2  nathanw #define OP_TLT		062		/* MIPS-II, for r4000 port */
    246  1.8.6.2  nathanw #define OP_TLTU		063		/* MIPS-II, for r4000 port */
    247  1.8.6.2  nathanw #define OP_TEQ		064		/* MIPS-II, for r4000 port */
    248  1.8.6.2  nathanw #define OP_TNE		066		/* MIPS-II, for r4000 port */
    249  1.8.6.2  nathanw 
    250  1.8.6.2  nathanw #define OP_DSLL		070		/* MIPS-II, for r4000 port */
    251  1.8.6.2  nathanw #define OP_DSRL		072		/* MIPS-II, for r4000 port */
    252  1.8.6.2  nathanw #define OP_DSRA		073		/* MIPS-II, for r4000 port */
    253  1.8.6.2  nathanw #define OP_DSLL32	074		/* MIPS-II, for r4000 port */
    254  1.8.6.2  nathanw #define OP_DSRL32	076		/* MIPS-II, for r4000 port */
    255  1.8.6.2  nathanw #define OP_DSRA32	077		/* MIPS-II, for r4000 port */
    256  1.8.6.2  nathanw 
    257  1.8.6.2  nathanw /*
    258  1.8.6.2  nathanw  * Values for the 'func' field when 'op' == OP_SPECIAL2.
    259  1.8.6.2  nathanw  */
    260  1.8.6.2  nathanw #define OP_MAD		000		/* QED */
    261  1.8.6.2  nathanw #define OP_MADU		001		/* QED */
    262  1.8.6.2  nathanw #define OP_MUL		002		/* QED */
    263  1.8.6.2  nathanw 
    264  1.8.6.2  nathanw /*
    265  1.8.6.2  nathanw  * Values for the 'func' field when 'op' == OP_BCOND.
    266  1.8.6.2  nathanw  */
    267  1.8.6.2  nathanw #define OP_BLTZ		000
    268  1.8.6.2  nathanw #define OP_BGEZ		001
    269  1.8.6.2  nathanw #define OP_BLTZL	002		/* MIPS-II, for r4000 port */
    270  1.8.6.2  nathanw #define OP_BGEZL	003		/* MIPS-II, for r4000 port */
    271  1.8.6.2  nathanw 
    272  1.8.6.2  nathanw #define OP_TGEI		010		/* MIPS-II, for r4000 port */
    273  1.8.6.2  nathanw #define OP_TGEIU	011		/* MIPS-II, for r4000 port */
    274  1.8.6.2  nathanw #define OP_TLTI		012		/* MIPS-II, for r4000 port */
    275  1.8.6.2  nathanw #define OP_TLTIU	013		/* MIPS-II, for r4000 port */
    276  1.8.6.2  nathanw #define OP_TEQI		014		/* MIPS-II, for r4000 port */
    277  1.8.6.2  nathanw #define OP_TNEI		016		/* MIPS-II, for r4000 port */
    278  1.8.6.2  nathanw 
    279  1.8.6.2  nathanw #define OP_BLTZAL	020		/* MIPS-II, for r4000 port */
    280  1.8.6.2  nathanw #define OP_BGEZAL	021
    281  1.8.6.2  nathanw #define OP_BLTZALL	022
    282  1.8.6.2  nathanw #define OP_BGEZALL	023
    283  1.8.6.2  nathanw 
    284  1.8.6.2  nathanw /*
    285  1.8.6.2  nathanw  * Values for the 'rs' field when 'op' == OP_COPz.
    286  1.8.6.2  nathanw  */
    287  1.8.6.2  nathanw #define OP_MF		000
    288  1.8.6.2  nathanw #define OP_DMF		001		/* MIPS-II, for r4000 port */
    289  1.8.6.2  nathanw #define OP_MT		004
    290  1.8.6.2  nathanw #define OP_DMT		005		/* MIPS-II, for r4000 port */
    291  1.8.6.2  nathanw #define OP_BCx		010
    292  1.8.6.2  nathanw #define OP_BCy		014
    293  1.8.6.2  nathanw #define OP_CF		002
    294  1.8.6.2  nathanw #define OP_CT		006
    295  1.8.6.2  nathanw 
    296  1.8.6.2  nathanw /*
    297  1.8.6.2  nathanw  * Values for the 'rt' field when 'op' == OP_COPz.
    298  1.8.6.2  nathanw  */
    299  1.8.6.2  nathanw #define COPz_BC_TF_MASK	0x01
    300  1.8.6.2  nathanw #define COPz_BC_TRUE	0x01
    301  1.8.6.2  nathanw #define COPz_BC_FALSE	0x00
    302  1.8.6.2  nathanw #define COPz_BCL_TF_MASK	0x02		/* MIPS-II, for r4000 port */
    303  1.8.6.2  nathanw #define COPz_BCL_TRUE	0x02		/* MIPS-II, for r4000 port */
    304  1.8.6.2  nathanw #define COPz_BCL_FALSE	0x00		/* MIPS-II, for r4000 port */
    305