1 |
#ifndef OPCODES_H |
2 |
#define OPCODES_H |
3 |
|
4 |
/* |
5 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
6 |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions are met: |
9 |
* |
10 |
* 1. Redistributions of source code must retain the above copyright |
11 |
* notice, this list of conditions and the following disclaimer. |
12 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
* notice, this list of conditions and the following disclaimer in the |
14 |
* documentation and/or other materials provided with the distribution. |
15 |
* 3. The name of the author may not be used to endorse or promote products |
16 |
* derived from this software without specific prior written permission. |
17 |
* |
18 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
19 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
22 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 |
* SUCH DAMAGE. |
29 |
* |
30 |
* |
31 |
* $Id: opcodes_mips.h,v 1.2 2005/03/15 06:52:15 debug Exp $ |
32 |
* |
33 |
* MIPS opcodes, gathered from various sources. |
34 |
*/ |
35 |
|
36 |
|
37 |
/* Opcodes: (see page 191 in MIPS_IV_Instruction_Set_v3.2.pdf) */ |
38 |
|
39 |
#define HI6_NAMES { \ |
40 |
"special", "regimm", "j", "jal", "beq", "bne", "blez", "bgtz", /* 0x00 - 0x07 */ \ |
41 |
"addi", "addiu", "slti", "sltiu", "andi", "ori", "xori", "lui", /* 0x08 - 0x0f */ \ |
42 |
"cop0", "cop1", "cop2", "cop3", "beql", "bnel", "blezl", "bgtzl", /* 0x10 - 0x17 */ \ |
43 |
"daddi", "daddiu", "ldl", "ldr", "special2", "opcode_1d", "lq_mdmx", "sq", /* 0x18 - 0x1f */ \ |
44 |
"lb", "lh", "lwl", "lw", "lbu", "lhu", "lwr", "lwu", /* 0x20 - 0x27 */ \ |
45 |
"sb", "sh", "swl", "sw", "sdl", "sdr", "swr", "cache", /* 0x28 - 0x2f */ \ |
46 |
"ll", "lwc1", "lwc2", "lwc3", "lld", "ldc1", "ldc2", "ld", /* 0x30 - 0x37 */ \ |
47 |
"sc", "swc1", "swc2", "swc3", "scd", "sdc1", "sdc2", "sd" /* 0x38 - 0x3f */ } |
48 |
|
49 |
#define REGIMM_NAMES { \ |
50 |
"bltz", "bgez", "bltzl", "bgezl", "regimm_04", "regimm_05", "regimm_06", "regimm_07", /* 0x00 - 0x07 */ \ |
51 |
"regimm_08", "regimm_09", "regimm_0a", "regimm_0b", "regimm_0c", "regimm_0d", "regimm_0e", "regimm_0f", /* 0x08 - 0x0f */ \ |
52 |
"bltzal", "bgezal", "bltzall", "bgezall", "regimm_14", "regimm_15", "regimm_16", "regimm_17", /* 0x10 - 0x17 */ \ |
53 |
"regimm_18", "regimm_19", "regimm_1a", "regimm_1b", "regimm_1c", "regimm_1d", "regimm_1e", "regimm_1f" /* 0x18 - 0x1f */ } |
54 |
|
55 |
#define SPECIAL_NAMES { \ |
56 |
"sll", "special_01", "srl", "sra", "sllv", "special_05", "srlv", "srav", /* 0x00 - 0x07 */ \ |
57 |
"jr", "jalr", "movz", "movn", "syscall", "break", "special_0e", "sync", /* 0x08 - 0x0f */ \ |
58 |
"mfhi", "mthi", "mflo", "mtlo", "dsllv", "special_15", "dsrlv", "dsrav", /* 0x10 - 0x17 */ \ |
59 |
"mult", "multu", "div", "divu", "dmult", "dmultu", "ddiv", "ddivu", /* 0x18 - 0x1f */ \ |
60 |
"add", "addu", "sub", "subu", "and", "or", "xor", "nor", /* 0x20 - 0x27 */ \ |
61 |
"mfsa", "mtsa", "slt", "sltu", "special_2c", "daddu", "special_2e", "dsubu", /* 0x28 - 0x2f */ \ |
62 |
"special_30", "special_31", "special_32", "special_33", "teq", "special_35", "special_36", "special_37", /* 0x30 - 0x37 */ \ |
63 |
"dsll", "special_39", "dsrl", "dsra", "dsll32", "special_3d", "dsrl32", "dsra32"/* 0x38 - 0x3f */ } |
64 |
|
65 |
#define SPECIAL2_NAMES { \ |
66 |
"madd", "maddu", "mul", "special2_03", "msub", "msubu", "special2_06", "special2_07", /* 0x00 - 0x07 */ \ |
67 |
"mov_xxx", "pmfhi_lo", "special2_0a", "special2_0b", "special2_0c", "special2_0d", "special2_0e", "special2_0f", /* 0x08 - 0x0f */ \ |
68 |
"special2_10", "special2_11", "special2_12", "special2_13", "special2_14", "special2_15", "special2_16", "special2_17", /* 0x10 - 0x17 */ \ |
69 |
"special2_18", "special2_19", "special2_1a", "special2_1b", "special2_1c", "special2_1d", "special2_1e", "special2_1f", /* 0x18 - 0x1f */ \ |
70 |
"clz", "clo", "special2_22", "special2_23", "dclz", "dclo", "special2_26", "special2_27", /* 0x20 - 0x27 */ \ |
71 |
"special2_28", "por", "special2_2a", "special2_2b", "special2_2c", "special2_2d", "special2_2e", "special2_2f", /* 0x28 - 0x2f */ \ |
72 |
"special2_30", "special2_31", "special2_32", "special2_33", "special2_34", "special2_35", "special2_36", "special2_37", /* 0x30 - 0x37 */ \ |
73 |
"special2_38", "special2_39", "special2_3a", "special2_3b", "special2_3c", "special2_3d", "special2_3e", "sdbbp" /* 0x38 - 0x3f */ } |
74 |
|
75 |
#define HI6_SPECIAL 0x00 /* 000000 */ |
76 |
#define SPECIAL_SLL 0x00 /* 000000 */ /* MIPS I */ |
77 |
/* 0x01 000001 */ |
78 |
#define SPECIAL_SRL 0x02 /* 000010 */ /* MIPS I */ |
79 |
#define SPECIAL_SRA 0x03 /* 000011 */ /* MIPS I */ |
80 |
#define SPECIAL_SLLV 0x04 /* 000100 */ /* MIPS I */ |
81 |
/* 0x05 000101 */ |
82 |
#define SPECIAL_SRLV 0x06 /* 000110 */ |
83 |
#define SPECIAL_SRAV 0x07 /* 000111 */ /* MIPS I */ |
84 |
#define SPECIAL_JR 0x08 /* 001000 */ /* MIPS I */ |
85 |
#define SPECIAL_JALR 0x09 /* 001001 */ /* MIPS I */ |
86 |
#define SPECIAL_MOVZ 0x0a /* 001010 */ /* MIPS IV */ |
87 |
#define SPECIAL_MOVN 0x0b /* 001011 */ /* MIPS IV */ |
88 |
#define SPECIAL_SYSCALL 0x0c /* 001100 */ /* MIPS I */ |
89 |
#define SPECIAL_BREAK 0x0d /* 001101 */ /* MIPS I */ |
90 |
/* 0x0e 001110 */ |
91 |
#define SPECIAL_SYNC 0x0f /* 001111 */ /* MIPS II */ |
92 |
#define SPECIAL_MFHI 0x10 /* 010000 */ /* MIPS I */ |
93 |
#define SPECIAL_MTHI 0x11 /* 010001 */ /* MIPS I */ |
94 |
#define SPECIAL_MFLO 0x12 /* 010010 */ /* MIPS I */ |
95 |
#define SPECIAL_MTLO 0x13 /* 010011 */ /* MIPS I */ |
96 |
#define SPECIAL_DSLLV 0x14 /* 010100 */ |
97 |
/* 0x15 010101 */ |
98 |
#define SPECIAL_DSRLV 0x16 /* 010110 */ /* MIPS III */ |
99 |
#define SPECIAL_DSRAV 0x17 /* 010111 */ /* MIPS III */ |
100 |
#define SPECIAL_MULT 0x18 /* 011000 */ /* MIPS I */ |
101 |
#define SPECIAL_MULTU 0x19 /* 011001 */ /* MIPS I */ |
102 |
#define SPECIAL_DIV 0x1a /* 011010 */ /* MIPS I */ |
103 |
#define SPECIAL_DIVU 0x1b /* 011011 */ /* MIPS I */ |
104 |
#define SPECIAL_DMULT 0x1c /* 011100 */ /* MIPS III */ |
105 |
#define SPECIAL_DMULTU 0x1d /* 011101 */ /* MIPS III */ |
106 |
#define SPECIAL_DDIV 0x1e /* 011110 */ /* MIPS III */ |
107 |
#define SPECIAL_DDIVU 0x1f /* 011111 */ /* MIPS III */ |
108 |
#define SPECIAL_ADD 0x20 /* 100000 */ /* MIPS I */ |
109 |
#define SPECIAL_ADDU 0x21 /* 100001 */ /* MIPS I */ |
110 |
#define SPECIAL_SUB 0x22 /* 100010 */ /* MIPS I */ |
111 |
#define SPECIAL_SUBU 0x23 /* 100011 */ /* MIPS I */ |
112 |
#define SPECIAL_AND 0x24 /* 100100 */ /* MIPS I */ |
113 |
#define SPECIAL_OR 0x25 /* 100101 */ /* MIPS I */ |
114 |
#define SPECIAL_XOR 0x26 /* 100110 */ /* MIPS I */ |
115 |
#define SPECIAL_NOR 0x27 /* 100111 */ /* MIPS I */ |
116 |
#define SPECIAL_MFSA 0x28 /* 101000 */ /* Undocumented R5900 ? */ |
117 |
#define SPECIAL_MTSA 0x29 /* 101001 */ /* Undocumented R5900 ? */ |
118 |
#define SPECIAL_SLT 0x2a /* 101010 */ /* MIPS I */ |
119 |
#define SPECIAL_SLTU 0x2b /* 101011 */ /* MIPS I */ |
120 |
#define SPECIAL_DADD 0x2c /* 101100 */ /* MIPS III */ |
121 |
#define SPECIAL_DADDU 0x2d /* 101101 */ /* MIPS III */ |
122 |
#define SPECIAL_DSUB 0x2e /* 101110 */ |
123 |
#define SPECIAL_DSUBU 0x2f /* 101111 */ /* MIPS III */ |
124 |
#define SPECIAL_TGE 0x30 /* 110000 */ |
125 |
#define SPECIAL_TGEU 0x31 /* 110001 */ |
126 |
#define SPECIAL_TLT 0x32 /* 110010 */ |
127 |
#define SPECIAL_TLTU 0x33 /* 110011 */ |
128 |
#define SPECIAL_TEQ 0x34 /* 110100 */ |
129 |
/* 0x35 110101 */ |
130 |
#define SPECIAL_TNE 0x36 /* 110110 */ |
131 |
/* 0x37 110111 */ |
132 |
#define SPECIAL_DSLL 0x38 /* 111000 */ /* MIPS III */ |
133 |
/* 0x39 111001 */ |
134 |
#define SPECIAL_DSRL 0x3a /* 111010 */ /* MIPS III */ |
135 |
#define SPECIAL_DSRA 0x3b /* 111011 */ /* MIPS III */ |
136 |
#define SPECIAL_DSLL32 0x3c /* 111100 */ /* MIPS III */ |
137 |
/* 0x3d 111101 */ |
138 |
#define SPECIAL_DSRL32 0x3e /* 111110 */ /* MIPS III */ |
139 |
#define SPECIAL_DSRA32 0x3f /* 111111 */ /* MIPS III */ |
140 |
|
141 |
#define HI6_REGIMM 0x01 /* 000001 */ |
142 |
#define REGIMM_BLTZ 0x00 /* 00000 */ /* MIPS I */ |
143 |
#define REGIMM_BGEZ 0x01 /* 00001 */ /* MIPS I */ |
144 |
#define REGIMM_BLTZL 0x02 /* 00010 */ /* MIPS II */ |
145 |
#define REGIMM_BGEZL 0x03 /* 00011 */ /* MIPS II */ |
146 |
#define REGIMM_BLTZAL 0x10 /* 10000 */ |
147 |
#define REGIMM_BGEZAL 0x11 /* 10001 */ |
148 |
#define REGIMM_BLTZALL 0x12 /* 10010 */ |
149 |
#define REGIMM_BGEZALL 0x13 /* 10011 */ |
150 |
/* regimm ............... */ |
151 |
|
152 |
#define HI6_J 0x02 /* 000010 */ /* MIPS I */ |
153 |
#define HI6_JAL 0x03 /* 000011 */ /* MIPS I */ |
154 |
#define HI6_BEQ 0x04 /* 000100 */ /* MIPS I */ |
155 |
#define HI6_BNE 0x05 /* 000101 */ |
156 |
#define HI6_BLEZ 0x06 /* 000110 */ /* MIPS I */ |
157 |
#define HI6_BGTZ 0x07 /* 000111 */ /* MIPS I */ |
158 |
#define HI6_ADDI 0x08 /* 001000 */ /* MIPS I */ |
159 |
#define HI6_ADDIU 0x09 /* 001001 */ /* MIPS I */ |
160 |
#define HI6_SLTI 0x0a /* 001010 */ /* MIPS I */ |
161 |
#define HI6_SLTIU 0x0b /* 001011 */ /* MIPS I */ |
162 |
#define HI6_ANDI 0x0c /* 001100 */ /* MIPS I */ |
163 |
#define HI6_ORI 0x0d /* 001101 */ /* MIPS I */ |
164 |
#define HI6_XORI 0x0e /* 001110 */ /* MIPS I */ |
165 |
#define HI6_LUI 0x0f /* 001111 */ /* MIPS I */ |
166 |
#define HI6_COP0 0x10 /* 010000 */ |
167 |
#define COPz_MFCz 0x00 /* 00000 */ |
168 |
#define COPz_DMFCz 0x01 /* 00001 */ |
169 |
#define COPz_MTCz 0x04 /* 00100 */ |
170 |
#define COPz_DMTCz 0x05 /* 00101 */ |
171 |
/* COP1 fmt codes = bits 25..21 (only if COP1): */ |
172 |
#define COPz_CFCz 0x02 /* 00010 */ /* MIPS I */ |
173 |
#define COPz_CTCz 0x06 /* 00110 */ /* MIPS I */ |
174 |
/* COP0 opcodes = bits 4..0 (only if COP0 and CO=1): */ |
175 |
#define COP0_TLBR 0x01 /* 00001 */ |
176 |
#define COP0_TLBWI 0x02 /* 00010 */ |
177 |
#define COP0_TLBWR 0x06 /* 00110 */ |
178 |
#define COP0_TLBP 0x08 /* 01000 */ |
179 |
#define COP0_RFE 0x10 /* 10000 */ |
180 |
#define COP0_ERET 0x18 /* 11000 */ |
181 |
#define COP0_STANDBY 0x21 |
182 |
#define COP0_SUSPEND 0x22 |
183 |
#define COP0_HIBERNATE 0x23 |
184 |
#define HI6_COP1 0x11 /* 010001 */ |
185 |
#define HI6_COP2 0x12 /* 010010 */ |
186 |
#define HI6_COP3 0x13 /* 010011 */ |
187 |
#define HI6_BEQL 0x14 /* 010100 */ /* MIPS II */ |
188 |
#define HI6_BNEL 0x15 /* 010101 */ |
189 |
#define HI6_BLEZL 0x16 /* 010110 */ /* MIPS II */ |
190 |
#define HI6_BGTZL 0x17 /* 010111 */ /* MIPS II */ |
191 |
#define HI6_DADDI 0x18 /* 011000 */ /* MIPS III */ |
192 |
#define HI6_DADDIU 0x19 /* 011001 */ /* MIPS III */ |
193 |
#define HI6_LDL 0x1a /* 011010 */ /* MIPS III */ |
194 |
#define HI6_LDR 0x1b /* 011011 */ /* MIPS III */ |
195 |
#define HI6_SPECIAL2 0x1c /* 011100 */ |
196 |
#define SPECIAL2_MADD 0x00 /* 000000 */ /* MIPS32 (?) TODO */ |
197 |
#define SPECIAL2_MADDU 0x01 /* 000001 */ /* MIPS32 (?) TODO */ |
198 |
#define SPECIAL2_MUL 0x02 /* 000010 */ /* MIPS32 (?) TODO */ |
199 |
#define SPECIAL2_MSUB 0x04 /* 000100 */ /* MIPS32 (?) TODO */ |
200 |
#define SPECIAL2_MSUBU 0x05 /* 000001 */ /* MIPS32 (?) TODO */ |
201 |
#define SPECIAL2_MOV_XXX 0x08 /* 001000 */ /* Undocumented R5900 ? */ |
202 |
#define SPECIAL2_PMFHI 0x09 /* 001001 */ /* Undocumented R5900 ? */ |
203 |
#define SPECIAL2_CLZ 0x20 /* 100100 */ /* MIPS32 */ |
204 |
#define SPECIAL2_CLO 0x21 /* 100101 */ /* MIPS32 */ |
205 |
#define SPECIAL2_DCLZ 0x24 /* 100100 */ /* MIPS64 */ |
206 |
#define SPECIAL2_DCLO 0x25 /* 100101 */ /* MIPS64 */ |
207 |
#define SPECIAL2_POR 0x29 /* 101001 */ /* Undocumented R5900 ? */ |
208 |
#define SPECIAL2_SDBBP 0x3f /* 111111 */ /* EJTAG (?) TODO */ |
209 |
/* JALX (TODO) 0x1d 011101 */ |
210 |
#define HI6_LQ_MDMX 0x1e /* 011110 */ /* lq on R5900, MDMX on others? */ |
211 |
#define HI6_SQ 0x1f /* 011111 */ /* R5900 ? */ |
212 |
#define HI6_LB 0x20 /* 100000 */ /* MIPS I */ |
213 |
#define HI6_LH 0x21 /* 100001 */ /* MIPS I */ |
214 |
#define HI6_LWL 0x22 /* 100010 */ /* MIPS I */ |
215 |
#define HI6_LW 0x23 /* 100011 */ /* MIPS I */ |
216 |
#define HI6_LBU 0x24 /* 100100 */ /* MIPS I */ |
217 |
#define HI6_LHU 0x25 /* 100101 */ /* MIPS I */ |
218 |
#define HI6_LWR 0x26 /* 100110 */ /* MIPS I */ |
219 |
#define HI6_LWU 0x27 /* 100111 */ /* MIPS III */ |
220 |
#define HI6_SB 0x28 /* 101000 */ /* MIPS I */ |
221 |
#define HI6_SH 0x29 /* 101001 */ /* MIPS I */ |
222 |
#define HI6_SWL 0x2a /* 101010 */ /* MIPS I */ |
223 |
#define HI6_SW 0x2b /* 101011 */ /* MIPS I */ |
224 |
#define HI6_SDL 0x2c /* 101100 */ /* MIPS III */ |
225 |
#define HI6_SDR 0x2d /* 101101 */ /* MIPS III */ |
226 |
#define HI6_SWR 0x2e /* 101110 */ /* MIPS I */ |
227 |
#define HI6_CACHE 0x2f /* 101111 */ /* ??? R4000 */ |
228 |
#define HI6_LL 0x30 /* 110000 */ /* MIPS II */ |
229 |
#define HI6_LWC1 0x31 /* 110001 */ /* MIPS I */ |
230 |
#define HI6_LWC2 0x32 /* 110010 */ /* MIPS I */ |
231 |
#define HI6_LWC3 0x33 /* 110011 */ /* MIPS I */ |
232 |
#define HI6_LLD 0x34 /* 110100 */ /* MIPS III */ |
233 |
#define HI6_LDC1 0x35 /* 110101 */ /* MIPS II */ |
234 |
#define HI6_LDC2 0x36 /* 110110 */ /* MIPS II */ |
235 |
#define HI6_LD 0x37 /* 110111 */ /* MIPS III */ |
236 |
#define HI6_SC 0x38 /* 111000 */ /* MIPS II */ |
237 |
#define HI6_SWC1 0x39 /* 111001 */ /* MIPS I */ |
238 |
#define HI6_SWC2 0x3a /* 111010 */ /* MIPS I */ |
239 |
#define HI6_SWC3 0x3b /* 111011 */ /* MIPS I */ |
240 |
#define HI6_SCD 0x3c /* 111100 */ /* MIPS III */ |
241 |
#define HI6_SDC1 0x3d /* 111101 */ /* MIPS II */ |
242 |
#define HI6_SDC2 0x3e /* 111110 */ /* MIPS II */ |
243 |
#define HI6_SD 0x3f /* 111111 */ /* MIPS III */ |
244 |
|
245 |
|
246 |
#endif /* OPCODES_H */ |
247 |
|