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