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