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