|
0
|
1 /*- |
|
|
2 * Copyright (c) 1992 The Regents of the University of California. |
|
|
3 * 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: |
|
2
|
18 * This product includes software developed by the University of |
|
|
19 * California, Berkeley and its contributors. |
|
0
|
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 * |
|
2
|
36 * from: @(#)mips_opcode.h 7.1 (Berkeley) 3/19/92 |
|
0
|
37 * via: mips_opcode.h,v 1.1 1994/03/10 16:15:10 (algorithmics) |
|
|
38 */ |
|
|
39 |
|
|
40 /* |
|
|
41 * Define the instruction formats and opcode values for the |
|
|
42 * MIPS instruction set. |
|
|
43 */ |
|
|
44 |
|
|
45 #ifndef _MIPS_OPCODE_H |
|
|
46 #define _MIPS_OPCODE_H |
|
|
47 |
|
|
48 /* |
|
|
49 * Define the instruction formats. |
|
|
50 */ |
|
|
51 typedef union { |
|
|
52 unsigned word; |
|
|
53 |
|
|
54 #ifdef MIPSEL |
|
|
55 struct { |
|
2
|
56 unsigned imm: 16; |
|
|
57 unsigned rt: 5; |
|
|
58 unsigned rs: 5; |
|
|
59 unsigned op: 6; |
|
0
|
60 } IType; |
|
|
61 |
|
|
62 struct { |
|
2
|
63 unsigned target: 26; |
|
|
64 unsigned op: 6; |
|
0
|
65 } JType; |
|
|
66 |
|
|
67 struct { |
|
2
|
68 unsigned func: 6; |
|
|
69 unsigned shamt: 5; |
|
|
70 unsigned rd: 5; |
|
|
71 unsigned rt: 5; |
|
|
72 unsigned rs: 5; |
|
|
73 unsigned op: 6; |
|
0
|
74 } RType; |
|
|
75 |
|
|
76 struct { |
|
2
|
77 unsigned func: 6; |
|
|
78 unsigned fd: 5; |
|
|
79 unsigned fs: 5; |
|
|
80 unsigned ft: 5; |
|
|
81 unsigned fmt: 4; |
|
|
82 unsigned : 1; /* always '1' */ |
|
|
83 unsigned op: 6; /* always '0x11' */ |
|
0
|
84 } FRType; |
|
|
85 #else |
|
|
86 struct { |
|
2
|
87 unsigned op: 6; |
|
|
88 unsigned rs: 5; |
|
|
89 unsigned rt: 5; |
|
|
90 unsigned imm: 16; |
|
0
|
91 } IType; |
|
|
92 |
|
|
93 struct { |
|
2
|
94 unsigned op: 6; |
|
|
95 unsigned target: 26; |
|
0
|
96 } JType; |
|
|
97 |
|
|
98 struct { |
|
2
|
99 unsigned op: 6; |
|
|
100 unsigned rs: 5; |
|
|
101 unsigned rt: 5; |
|
|
102 unsigned rd: 5; |
|
|
103 unsigned shamt: 5; |
|
|
104 unsigned func: 6; |
|
0
|
105 } RType; |
|
|
106 |
|
|
107 struct { |
|
2
|
108 unsigned op: 6; /* always '0x11' */ |
|
|
109 unsigned : 1; /* always '1' */ |
|
|
110 unsigned fmt: 4; |
|
|
111 unsigned func: 6; |
|
|
112 unsigned ft: 5; |
|
|
113 unsigned fs: 5; |
|
|
114 unsigned fd: 5; |
|
0
|
115 } FRType; |
|
|
116 #endif |
|
|
117 } InstFmt; |
|
|
118 |
|
|
119 /* |
|
|
120 * Values for the 'op' field. |
|
|
121 */ |
|
2
|
122 #define OP_SPECIAL 000 |
|
|
123 #define OP_REGIMM 001 |
|
|
124 #define OP_J 002 |
|
|
125 #define OP_JAL 003 |
|
|
126 #define OP_BEQ 004 |
|
|
127 #define OP_BNE 005 |
|
|
128 #define OP_BLEZ 006 |
|
|
129 #define OP_BGTZ 007 |
|
0
|
130 |
|
2
|
131 #define OP_ADDI 010 |
|
|
132 #define OP_ADDIU 011 |
|
|
133 #define OP_SLTI 012 |
|
|
134 #define OP_SLTIU 013 |
|
|
135 #define OP_ANDI 014 |
|
|
136 #define OP_ORI 015 |
|
|
137 #define OP_XORI 016 |
|
|
138 #define OP_LUI 017 |
|
0
|
139 |
|
2
|
140 #define OP_COP0 020 |
|
|
141 #define OP_COP1 021 |
|
|
142 #define OP_COP2 022 |
|
|
143 #define OP_BEQL 024 |
|
|
144 #define OP_BNEL 025 |
|
|
145 #define OP_BLEZL 026 |
|
|
146 #define OP_BGTZL 027 |
|
0
|
147 |
|
2
|
148 #define OP_DADDI 030 |
|
|
149 #define OP_DADDIU 031 |
|
|
150 #define OP_LDL 032 |
|
|
151 #define OP_LDR 033 |
|
0
|
152 |
|
2
|
153 #define OP_LB 040 |
|
|
154 #define OP_LH 041 |
|
|
155 #define OP_LWL 042 |
|
|
156 #define OP_LW 043 |
|
|
157 #define OP_LBU 044 |
|
|
158 #define OP_LHU 045 |
|
|
159 #define OP_LWR 046 |
|
|
160 #define OP_LWU 047 |
|
0
|
161 |
|
2
|
162 #define OP_SB 050 |
|
|
163 #define OP_SH 051 |
|
|
164 #define OP_SWL 052 |
|
|
165 #define OP_SW 053 |
|
|
166 #define OP_SDL 054 |
|
|
167 #define OP_SDR 055 |
|
|
168 #define OP_SWR 056 |
|
|
169 #define OP_CACHE 057 |
|
0
|
170 |
|
2
|
171 #define OP_LL 060 |
|
|
172 #define OP_LWC1 061 |
|
|
173 #define OP_LWC2 062 |
|
|
174 #define OP_LLD 064 |
|
|
175 #define OP_LDC1 065 |
|
|
176 #define OP_LDC2 066 |
|
|
177 #define OP_LD 067 |
|
0
|
178 |
|
2
|
179 #define OP_SC 070 |
|
|
180 #define OP_SWC1 071 |
|
|
181 #define OP_SWC2 072 |
|
|
182 #define OP_SCD 074 |
|
|
183 #define OP_SDC1 075 |
|
|
184 #define OP_SDC2 076 |
|
|
185 #define OP_SD 077 |
|
0
|
186 |
|
|
187 /* |
|
|
188 * Values for the 'func' field when 'op' == OP_SPECIAL. |
|
|
189 */ |
|
2
|
190 #define OP_SLL 000 |
|
|
191 #define OP_SRL 002 |
|
|
192 #define OP_SRA 003 |
|
|
193 #define OP_SLLV 004 |
|
|
194 #define OP_SRLV 006 |
|
|
195 #define OP_SRAV 007 |
|
0
|
196 |
|
2
|
197 #define OP_JR 010 |
|
|
198 #define OP_JALR 011 |
|
|
199 #define OP_SYSCALL 014 |
|
|
200 #define OP_BREAK 015 |
|
|
201 #define OP_SYNC 017 |
|
0
|
202 |
|
2
|
203 #define OP_MFHI 020 |
|
|
204 #define OP_MTHI 021 |
|
|
205 #define OP_MFLO 022 |
|
|
206 #define OP_MTLO 023 |
|
|
207 #define OP_DSLLV 024 |
|
|
208 #define OP_DSRLV 026 |
|
|
209 #define OP_DSRAV 027 |
|
0
|
210 |
|
2
|
211 #define OP_MULT 030 |
|
|
212 #define OP_MULTU 031 |
|
|
213 #define OP_DIV 032 |
|
|
214 #define OP_DIVU 033 |
|
|
215 #define OP_DMULT 034 |
|
|
216 #define OP_DMULTU 035 |
|
|
217 #define OP_DDIV 036 |
|
|
218 #define OP_DDIVU 037 |
|
0
|
219 |
|
2
|
220 #define OP_ADD 040 |
|
|
221 #define OP_ADDU 041 |
|
|
222 #define OP_SUB 042 |
|
|
223 #define OP_SUBU 043 |
|
|
224 #define OP_AND 044 |
|
|
225 #define OP_OR 045 |
|
|
226 #define OP_XOR 046 |
|
|
227 #define OP_NOR 047 |
|
0
|
228 |
|
2
|
229 #define OP_SLT 052 |
|
|
230 #define OP_SLTU 053 |
|
|
231 #define OP_DADD 054 |
|
|
232 #define OP_DADDU 055 |
|
|
233 #define OP_DSUB 056 |
|
|
234 #define OP_DSUBU 057 |
|
0
|
235 |
|
2
|
236 #define OP_TGE 060 |
|
|
237 #define OP_TGEU 061 |
|
|
238 #define OP_TLT 062 |
|
|
239 #define OP_TLTU 063 |
|
|
240 #define OP_TEQ 064 |
|
|
241 #define OP_TNE 066 |
|
0
|
242 |
|
2
|
243 #define OP_DSLL 070 |
|
|
244 #define OP_DSRL 072 |
|
|
245 #define OP_DSRA 073 |
|
|
246 #define OP_DSLL32 074 |
|
|
247 #define OP_DSRL32 076 |
|
|
248 #define OP_DSRA32 077 |
|
0
|
249 |
|
|
250 /* |
|
|
251 * Values for the 'func' field when 'op' == OP_REGIMM. |
|
|
252 */ |
|
2
|
253 #define OP_BLTZ 000 |
|
|
254 #define OP_BGEZ 001 |
|
|
255 #define OP_BLTZL 002 |
|
|
256 #define OP_BGEZL 003 |
|
0
|
257 |
|
2
|
258 #define OP_TGEI 010 |
|
|
259 #define OP_TGEIU 011 |
|
|
260 #define OP_TLTI 012 |
|
|
261 #define OP_TLTIU 013 |
|
|
262 #define OP_TEQI 014 |
|
|
263 #define OP_TNEI 016 |
|
0
|
264 |
|
2
|
265 #define OP_BLTZAL 020 |
|
|
266 #define OP_BGEZAL 021 |
|
|
267 #define OP_BLTZALL 022 |
|
|
268 #define OP_BGEZALL 023 |
|
0
|
269 |
|
|
270 /* |
|
|
271 * Values for the 'rs' field when 'op' == OP_COPz. |
|
|
272 */ |
|
2
|
273 #define OP_MF 000 |
|
|
274 #define OP_DMF 001 |
|
|
275 #define OP_CF 002 |
|
|
276 #define OP_MT 004 |
|
|
277 #define OP_DMT 005 |
|
|
278 #define OP_CT 006 |
|
|
279 #define OP_BC 010 |
|
0
|
280 |
|
|
281 /* |
|
|
282 * Values for the 'rt' field when 'op' == OP_COPz and 'rt' == OP_BC. |
|
|
283 */ |
|
2
|
284 #define COPz_BCF 0x00 |
|
|
285 #define COPz_BCT 0x01 |
|
|
286 #define COPz_BCFL 0x02 |
|
|
287 #define COPz_BCTL 0x03 |
|
0
|
288 |
|
|
289 /* |
|
|
290 * Instructions with specal significance to debuggers. |
|
|
291 */ |
|
2
|
292 #define BREAK_INSTR 0x0005000d /* instruction code for break */ |
|
|
293 #define NOP_INSTR 0x00000000 /* instruction code for no-op */ |
|
0
|
294 |
|
|
295 #endif /* _MIPS_OPCODE_H */ |