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