xref: /netbsd-src/sys/arch/mips/include/mips_opcode.h (revision d9158b13b5dfe46201430699a3f7a235ecf28df3)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Ralph Campbell.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *	This product includes software developed by the University of
19  *	California, Berkeley and its contributors.
20  * 4. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  *	from: @(#)mips_opcode.h	8.1 (Berkeley) 6/10/93
37  *      $Id: mips_opcode.h,v 1.3 1994/05/27 09:01:30 glass Exp $
38  */
39 
40 /*
41  * Define the instruction formats and opcode values for the
42  * MIPS instruction set.
43  */
44 
45 /*
46  * Define the instruction formats.
47  */
48 typedef union {
49 	unsigned word;
50 
51 #if BYTE_ORDER == LITTLE_ENDIAN
52 	struct {
53 		unsigned imm: 16;
54 		unsigned rt: 5;
55 		unsigned rs: 5;
56 		unsigned op: 6;
57 	} IType;
58 
59 	struct {
60 		unsigned target: 26;
61 		unsigned op: 6;
62 	} JType;
63 
64 	struct {
65 		unsigned func: 6;
66 		unsigned shamt: 5;
67 		unsigned rd: 5;
68 		unsigned rt: 5;
69 		unsigned rs: 5;
70 		unsigned op: 6;
71 	} RType;
72 
73 	struct {
74 		unsigned func: 6;
75 		unsigned fd: 5;
76 		unsigned fs: 5;
77 		unsigned ft: 5;
78 		unsigned fmt: 4;
79 		unsigned : 1;		/* always '1' */
80 		unsigned op: 6;		/* always '0x11' */
81 	} FRType;
82 #endif
83 } InstFmt;
84 
85 /*
86  * Values for the 'op' field.
87  */
88 #define OP_SPECIAL	000
89 #define OP_BCOND	001
90 #define OP_J		002
91 #define	OP_JAL		003
92 #define OP_BEQ		004
93 #define OP_BNE		005
94 #define OP_BLEZ		006
95 #define OP_BGTZ		007
96 
97 #define OP_ADDI		010
98 #define OP_ADDIU	011
99 #define OP_SLTI		012
100 #define OP_SLTIU	013
101 #define OP_ANDI		014
102 #define OP_ORI		015
103 #define OP_XORI		016
104 #define OP_LUI		017
105 
106 #define OP_COP0		020
107 #define OP_COP1		021
108 #define OP_COP2		022
109 #define OP_COP3		023
110 
111 #define OP_LB		040
112 #define OP_LH		041
113 #define OP_LWL		042
114 #define OP_LW		043
115 #define OP_LBU		044
116 #define OP_LHU		045
117 #define OP_LWR		046
118 
119 #define OP_SB		050
120 #define OP_SH		051
121 #define OP_SWL		052
122 #define OP_SW		053
123 #define OP_SWR		056
124 
125 #define OP_LWC0		060
126 #define OP_LWC1		061
127 #define OP_LWC2		062
128 #define OP_LWC3		063
129 
130 #define OP_SWC0		070
131 #define OP_SWC1		071
132 #define OP_SWC2		072
133 #define OP_SWC3		073
134 
135 /*
136  * Values for the 'func' field when 'op' == OP_SPECIAL.
137  */
138 #define OP_SLL		000
139 #define OP_SRL		002
140 #define OP_SRA		003
141 #define OP_SLLV		004
142 #define OP_SRLV		006
143 #define OP_SRAV		007
144 
145 #define OP_JR		010
146 #define OP_JALR		011
147 #define OP_SYSCALL	014
148 #define OP_BREAK	015
149 
150 #define OP_MFHI		020
151 #define OP_MTHI		021
152 #define OP_MFLO		022
153 #define OP_MTLO		023
154 
155 #define OP_MULT		030
156 #define OP_MULTU	031
157 #define OP_DIV		032
158 #define OP_DIVU		033
159 
160 #define OP_ADD		040
161 #define OP_ADDU		041
162 #define OP_SUB		042
163 #define OP_SUBU		043
164 #define OP_AND		044
165 #define OP_OR		045
166 #define OP_XOR		046
167 #define OP_NOR		047
168 
169 #define OP_SLT		052
170 #define OP_SLTU		053
171 
172 /*
173  * Values for the 'func' field when 'op' == OP_BCOND.
174  */
175 #define OP_BLTZ		000
176 #define OP_BGEZ		001
177 #define OP_BLTZAL	020
178 #define OP_BGEZAL	021
179 
180 /*
181  * Values for the 'rs' field when 'op' == OP_COPz.
182  */
183 #define OP_MF		000
184 #define OP_MT		004
185 #define OP_BCx		010
186 #define OP_BCy		014
187 #define OP_CF		002
188 #define OP_CT		006
189 
190 /*
191  * Values for the 'rt' field when 'op' == OP_COPz.
192  */
193 #define COPz_BC_TF_MASK	0x01
194 #define COPz_BC_TRUE	0x01
195 #define COPz_BC_FALSE	0x00
196