/[pcsx2_0.9.7]/trunk/pcsx2/R5900OpcodeTables.cpp
ViewVC logotype

Contents of /trunk/pcsx2/R5900OpcodeTables.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 4 months ago) by william
File size: 27690 byte(s)
committing r3113 initial commit again...
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16
17 //all tables for R5900 are define here..
18
19 #include "PrecompiledHeader.h"
20
21 #include "R5900OpcodeTables.h"
22 #include "R5900.h"
23
24 #include "x86/iR5900AritImm.h"
25 #include "x86/iR5900Arit.h"
26 #include "x86/iR5900MultDiv.h"
27 #include "x86/iR5900Shift.h"
28 #include "x86/iR5900Branch.h"
29 #include "x86/iR5900Jump.h"
30 #include "x86/iR5900LoadStore.h"
31 #include "x86/iR5900Move.h"
32 #include "x86/iMMI.h"
33 #include "x86/iCOP0.h"
34 #include "x86/iFPU.h"
35
36 namespace R5900
37 {
38 namespace Opcodes
39 {
40 // Generates an entry for the given opcode name.
41 // Assumes the default function naming schemes for interpreter and recompiler functions.
42 # define MakeOpcode( name, cycles ) \
43 static const OPCODE name = { \
44 #name, \
45 cycles, \
46 NULL, \
47 ::R5900::Interpreter::OpcodeImpl::name, \
48 ::R5900::Dynarec::OpcodeImpl::rec##name, \
49 ::R5900::OpcodeDisasm::name \
50 }
51
52 # define MakeOpcodeM( name, cycles ) \
53 static const OPCODE name = { \
54 #name, \
55 cycles, \
56 NULL, \
57 ::R5900::Interpreter::OpcodeImpl::MMI::name, \
58 ::R5900::Dynarec::OpcodeImpl::MMI::rec##name, \
59 ::R5900::OpcodeDisasm::name \
60 }
61
62 # define MakeOpcode0( name, cycles ) \
63 static const OPCODE name = { \
64 #name, \
65 cycles, \
66 NULL, \
67 ::R5900::Interpreter::OpcodeImpl::COP0::name, \
68 ::R5900::Dynarec::OpcodeImpl::COP0::rec##name, \
69 ::R5900::OpcodeDisasm::name \
70 }
71
72 # define MakeOpcode1( name, cycles ) \
73 static const OPCODE name = { \
74 #name, \
75 cycles, \
76 NULL, \
77 ::R5900::Interpreter::OpcodeImpl::COP1::name, \
78 ::R5900::Dynarec::OpcodeImpl::COP1::rec##name, \
79 ::R5900::OpcodeDisasm::name \
80 }
81
82 # define MakeOpcodeClass( name ) \
83 static const OPCODE name = { \
84 #name, \
85 0, \
86 R5900::Opcodes::Class_##name, \
87 NULL, \
88 NULL, \
89 NULL \
90 }
91
92 // We're working on new hopefully better cycle ratios, but they're still a WIP.
93 // And yes this whole thing is an ugly hack. I'll clean it up once we have
94 // a better idea how exactly the cycle ratios will work best.
95
96 namespace Cycles
97 {
98 static const int Default = 9;
99 static const int Branch = 11;
100 static const int CopDefault = 7;
101
102 static const int Mult = 2*8;
103 static const int Div = 14*8;
104 static const int MMI_Mult = 3*8;
105 static const int MMI_Div = 22*8;
106 static const int MMI_Default = 14;
107
108 static const int FPU_Mult = 4*8;
109
110 static const int Store = 14;
111 static const int Load = 14;
112 }
113
114 using namespace Cycles;
115
116 MakeOpcode( Unknown, Default );
117 MakeOpcode( MMI_Unknown, Default );
118 MakeOpcode( COP0_Unknown, Default );
119 MakeOpcode( COP1_Unknown, Default );
120
121 // Class Subset Opcodes
122 // (not really opcodes, but rather entire subsets of other opcode classes)
123
124 MakeOpcodeClass( SPECIAL );
125 MakeOpcodeClass( REGIMM );
126 //MakeOpcodeClass( COP2 );
127 MakeOpcodeClass( MMI );
128 MakeOpcodeClass( MMI0 );
129 MakeOpcodeClass( MMI2 );
130 MakeOpcodeClass( MMI1 );
131 MakeOpcodeClass( MMI3 );
132
133 MakeOpcodeClass( COP0 );
134 MakeOpcodeClass( COP1 );
135
136 // Misc Junk
137
138 MakeOpcode( COP2, Default );
139
140 MakeOpcode( CACHE, Default );
141 MakeOpcode( PREF, Default );
142 MakeOpcode( SYSCALL, Default );
143 MakeOpcode( BREAK, Default );
144 MakeOpcode( SYNC, Default );
145
146 // Branch/Jump Opcodes
147
148 MakeOpcode( J , Default );
149 MakeOpcode( JAL, Default );
150 MakeOpcode( JR, Default );
151 MakeOpcode( JALR, Default );
152
153 MakeOpcode( BEQ, Branch );
154 MakeOpcode( BNE, Branch );
155 MakeOpcode( BLEZ, Branch );
156 MakeOpcode( BGTZ, Branch );
157 MakeOpcode( BEQL, Branch );
158 MakeOpcode( BNEL, Branch );
159 MakeOpcode( BLEZL, Branch );
160 MakeOpcode( BGTZL, Branch );
161 MakeOpcode( BLTZ, Branch );
162 MakeOpcode( BGEZ, Branch );
163 MakeOpcode( BLTZL, Branch );
164 MakeOpcode( BGEZL, Branch );
165 MakeOpcode( BLTZAL, Branch );
166 MakeOpcode( BGEZAL, Branch );
167 MakeOpcode( BLTZALL, Branch );
168 MakeOpcode( BGEZALL, Branch );
169
170 MakeOpcode( TGEI, Branch );
171 MakeOpcode( TGEIU, Branch );
172 MakeOpcode( TLTI, Branch );
173 MakeOpcode( TLTIU, Branch );
174 MakeOpcode( TEQI, Branch );
175 MakeOpcode( TNEI, Branch );
176 MakeOpcode( TGE, Branch );
177 MakeOpcode( TGEU, Branch );
178 MakeOpcode( TLT, Branch );
179 MakeOpcode( TLTU, Branch );
180 MakeOpcode( TEQ, Branch );
181 MakeOpcode( TNE, Branch );
182
183 // Arithmetic
184
185 MakeOpcode( MULT, Mult );
186 MakeOpcode( MULTU, Mult );
187 MakeOpcode( MULT1, Mult );
188 MakeOpcode( MULTU1, Mult );
189 MakeOpcode( MADD, Mult );
190 MakeOpcode( MADDU, Mult );
191 MakeOpcode( MADD1, Mult );
192 MakeOpcode( MADDU1, Mult );
193 MakeOpcode( DIV, Div );
194 MakeOpcode( DIVU, Div );
195 MakeOpcode( DIV1, Div );
196 MakeOpcode( DIVU1, Div );
197
198 MakeOpcode( ADDI, Default );
199 MakeOpcode( ADDIU, Default );
200 MakeOpcode( DADDI, Default );
201 MakeOpcode( DADDIU, Default );
202 MakeOpcode( DADD, Default );
203 MakeOpcode( DADDU, Default );
204 MakeOpcode( DSUB, Default );
205 MakeOpcode( DSUBU, Default );
206 MakeOpcode( ADD, Default );
207 MakeOpcode( ADDU, Default );
208 MakeOpcode( SUB, Default );
209 MakeOpcode( SUBU, Default );
210
211 MakeOpcode( ANDI, Default );
212 MakeOpcode( ORI, Default );
213 MakeOpcode( XORI, Default );
214 MakeOpcode( AND, Default );
215 MakeOpcode( OR, Default );
216 MakeOpcode( XOR, Default );
217 MakeOpcode( NOR, Default );
218 MakeOpcode( SLTI, Default );
219 MakeOpcode( SLTIU, Default );
220 MakeOpcode( SLT, Default );
221 MakeOpcode( SLTU, Default );
222 MakeOpcode( LUI, Default );
223 MakeOpcode( SLL, Default );
224 MakeOpcode( SRL, Default );
225 MakeOpcode( SRA, Default );
226 MakeOpcode( SLLV, Default );
227 MakeOpcode( SRLV, Default );
228 MakeOpcode( SRAV, Default );
229 MakeOpcode( MOVZ, Default );
230 MakeOpcode( MOVN, Default );
231 MakeOpcode( DSLLV, Default );
232 MakeOpcode( DSRLV, Default );
233 MakeOpcode( DSRAV, Default );
234 MakeOpcode( DSLL, Default );
235 MakeOpcode( DSRL, Default );
236 MakeOpcode( DSRA, Default );
237 MakeOpcode( DSLL32, Default );
238 MakeOpcode( DSRL32, Default );
239 MakeOpcode( DSRA32, Default );
240
241 MakeOpcode( MFHI, Default );
242 MakeOpcode( MTHI, Default );
243 MakeOpcode( MFLO, Default );
244 MakeOpcode( MTLO, Default );
245 MakeOpcode( MFSA, Default );
246 MakeOpcode( MTSA, Default );
247 MakeOpcode( MTSAB, Default );
248 MakeOpcode( MTSAH, Default );
249 MakeOpcode( MFHI1, Default );
250 MakeOpcode( MTHI1, Default );
251 MakeOpcode( MFLO1, Default );
252 MakeOpcode( MTLO1, Default );
253
254 // Loads!
255
256 MakeOpcode( LDL, Load );
257 MakeOpcode( LDR, Load );
258 MakeOpcode( LQ, Load );
259 MakeOpcode( LB, Load );
260 MakeOpcode( LH, Load );
261 MakeOpcode( LWL, Load );
262 MakeOpcode( LW, Load );
263 MakeOpcode( LBU, Load );
264 MakeOpcode( LHU, Load );
265 MakeOpcode( LWR, Load );
266 MakeOpcode( LWU, Load );
267 MakeOpcode( LWC1, Load );
268 MakeOpcode( LQC2, Load );
269 MakeOpcode( LD, Load );
270
271 // Stores!
272
273 MakeOpcode( SQ, Store );
274 MakeOpcode( SB, Store );
275 MakeOpcode( SH, Store );
276 MakeOpcode( SWL, Store );
277 MakeOpcode( SW, Store );
278 MakeOpcode( SDL, Store );
279 MakeOpcode( SDR, Store );
280 MakeOpcode( SWR, Store );
281 MakeOpcode( SWC1, Store );
282 MakeOpcode( SQC2, Store );
283 MakeOpcode( SD, Store );
284
285
286 // Multimedia Instructions!
287
288 MakeOpcodeM( PLZCW, MMI_Default );
289 MakeOpcodeM( PMFHL, MMI_Default );
290 MakeOpcodeM( PMTHL, MMI_Default );
291 MakeOpcodeM( PSLLH, MMI_Default );
292 MakeOpcodeM( PSRLH, MMI_Default );
293 MakeOpcodeM( PSRAH, MMI_Default );
294 MakeOpcodeM( PSLLW, MMI_Default );
295 MakeOpcodeM( PSRLW, MMI_Default );
296 MakeOpcodeM( PSRAW, MMI_Default );
297
298 MakeOpcodeM( PADDW, MMI_Default );
299 MakeOpcodeM( PADDH, MMI_Default );
300 MakeOpcodeM( PADDB, MMI_Default );
301 MakeOpcodeM( PADDSW, MMI_Default );
302 MakeOpcodeM( PADDSH, MMI_Default );
303 MakeOpcodeM( PADDSB, MMI_Default );
304 MakeOpcodeM( PADDUW, MMI_Default );
305 MakeOpcodeM( PADDUH, MMI_Default );
306 MakeOpcodeM( PADDUB, MMI_Default );
307 MakeOpcodeM( PSUBW, MMI_Default );
308 MakeOpcodeM( PSUBH, MMI_Default );
309 MakeOpcodeM( PSUBB, MMI_Default );
310 MakeOpcodeM( PSUBSW, MMI_Default );
311 MakeOpcodeM( PSUBSH, MMI_Default );
312 MakeOpcodeM( PSUBSB, MMI_Default );
313 MakeOpcodeM( PSUBUW, MMI_Default );
314 MakeOpcodeM( PSUBUH, MMI_Default );
315 MakeOpcodeM( PSUBUB, MMI_Default );
316
317 MakeOpcodeM( PCGTW, MMI_Default );
318 MakeOpcodeM( PMAXW, MMI_Default );
319 MakeOpcodeM( PMAXH, MMI_Default );
320 MakeOpcodeM( PCGTH, MMI_Default );
321 MakeOpcodeM( PCGTB, MMI_Default );
322 MakeOpcodeM( PEXTLW, MMI_Default );
323 MakeOpcodeM( PEXTLH, MMI_Default );
324 MakeOpcodeM( PEXTLB, MMI_Default );
325 MakeOpcodeM( PEXT5, MMI_Default );
326 MakeOpcodeM( PPACW, MMI_Default );
327 MakeOpcodeM( PPACH, MMI_Default );
328 MakeOpcodeM( PPACB, MMI_Default );
329 MakeOpcodeM( PPAC5, MMI_Default );
330
331 MakeOpcodeM( PABSW, MMI_Default );
332 MakeOpcodeM( PABSH, MMI_Default );
333 MakeOpcodeM( PCEQW, MMI_Default );
334 MakeOpcodeM( PMINW, MMI_Default );
335 MakeOpcodeM( PMINH, MMI_Default );
336 MakeOpcodeM( PADSBH, MMI_Default );
337 MakeOpcodeM( PCEQH, MMI_Default );
338 MakeOpcodeM( PCEQB, MMI_Default );
339 MakeOpcodeM( PEXTUW, MMI_Default );
340 MakeOpcodeM( PEXTUH, MMI_Default );
341 MakeOpcodeM( PEXTUB, MMI_Default );
342 MakeOpcodeM( PSLLVW, MMI_Default );
343 MakeOpcodeM( PSRLVW, MMI_Default );
344
345 MakeOpcodeM( QFSRV, MMI_Default );
346
347 MakeOpcodeM( PMADDH, MMI_Mult );
348 MakeOpcodeM( PHMADH, MMI_Mult );
349 MakeOpcodeM( PMSUBH, MMI_Mult );
350 MakeOpcodeM( PHMSBH, MMI_Mult );
351 MakeOpcodeM( PMULTH, MMI_Mult );
352 MakeOpcodeM( PMADDW, MMI_Mult );
353 MakeOpcodeM( PMSUBW, MMI_Mult );
354 MakeOpcodeM( PMFHI, MMI_Mult );
355 MakeOpcodeM( PMFLO, MMI_Mult );
356 MakeOpcodeM( PMULTW, MMI_Mult );
357 MakeOpcodeM( PMADDUW, MMI_Mult );
358 MakeOpcodeM( PMULTUW, MMI_Mult );
359 MakeOpcodeM( PDIVUW, MMI_Div );
360 MakeOpcodeM( PDIVW, MMI_Div );
361 MakeOpcodeM( PDIVBW, MMI_Div );
362
363 MakeOpcodeM( PINTH, MMI_Default );
364 MakeOpcodeM( PCPYLD, MMI_Default );
365 MakeOpcodeM( PAND, MMI_Default );
366 MakeOpcodeM( PXOR, MMI_Default );
367 MakeOpcodeM( PEXEH, MMI_Default );
368 MakeOpcodeM( PREVH, MMI_Default );
369 MakeOpcodeM( PEXEW, MMI_Default );
370 MakeOpcodeM( PROT3W, MMI_Default );
371
372 MakeOpcodeM( PSRAVW, MMI_Default );
373 MakeOpcodeM( PMTHI, MMI_Default );
374 MakeOpcodeM( PMTLO, MMI_Default );
375 MakeOpcodeM( PINTEH, MMI_Default );
376 MakeOpcodeM( PCPYUD, MMI_Default );
377 MakeOpcodeM( POR, MMI_Default );
378 MakeOpcodeM( PNOR, MMI_Default );
379 MakeOpcodeM( PEXCH, MMI_Default );
380 MakeOpcodeM( PCPYH, MMI_Default );
381 MakeOpcodeM( PEXCW, MMI_Default );
382
383 //////////////////////////////////////////////////////////
384 // COP0 Instructions
385
386 MakeOpcodeClass( COP0_C0 );
387 MakeOpcodeClass( COP0_BC0 );
388
389 MakeOpcode0( MFC0, CopDefault );
390 MakeOpcode0( MTC0, CopDefault );
391
392 MakeOpcode0( BC0F, Branch );
393 MakeOpcode0( BC0T, Branch );
394 MakeOpcode0( BC0FL, Branch );
395 MakeOpcode0( BC0TL, Branch );
396
397 MakeOpcode0( TLBR, CopDefault );
398 MakeOpcode0( TLBWI, CopDefault );
399 MakeOpcode0( TLBWR, CopDefault );
400 MakeOpcode0( TLBP, CopDefault );
401 MakeOpcode0( ERET, CopDefault );
402 MakeOpcode0( EI, CopDefault );
403 MakeOpcode0( DI, CopDefault );
404
405 //////////////////////////////////////////////////////////
406 // COP1 Instructions!
407
408 MakeOpcodeClass( COP1_BC1 );
409 MakeOpcodeClass( COP1_S );
410 MakeOpcodeClass( COP1_W ); // contains CVT_S instruction *only*
411
412 MakeOpcode1( MFC1, CopDefault );
413 MakeOpcode1( CFC1, CopDefault );
414 MakeOpcode1( MTC1, CopDefault );
415 MakeOpcode1( CTC1, CopDefault );
416
417 MakeOpcode1( BC1F, Branch );
418 MakeOpcode1( BC1T, Branch );
419 MakeOpcode1( BC1FL, Branch );
420 MakeOpcode1( BC1TL, Branch );
421
422 MakeOpcode1( ADD_S, CopDefault );
423 MakeOpcode1( ADDA_S, CopDefault );
424 MakeOpcode1( SUB_S, CopDefault );
425 MakeOpcode1( SUBA_S, CopDefault );
426
427 MakeOpcode1( ABS_S, CopDefault );
428 MakeOpcode1( MOV_S, CopDefault );
429 MakeOpcode1( NEG_S, CopDefault );
430 MakeOpcode1( MAX_S, CopDefault );
431 MakeOpcode1( MIN_S, CopDefault );
432
433 MakeOpcode1( MUL_S, FPU_Mult );
434 MakeOpcode1( DIV_S, 6*8 );
435 MakeOpcode1( SQRT_S, 6*8 );
436 MakeOpcode1( RSQRT_S, 8*8 );
437 MakeOpcode1( MULA_S, FPU_Mult );
438 MakeOpcode1( MADD_S, FPU_Mult );
439 MakeOpcode1( MSUB_S, FPU_Mult );
440 MakeOpcode1( MADDA_S, FPU_Mult );
441 MakeOpcode1( MSUBA_S, FPU_Mult );
442
443 MakeOpcode1( C_F, CopDefault );
444 MakeOpcode1( C_EQ, CopDefault );
445 MakeOpcode1( C_LT, CopDefault );
446 MakeOpcode1( C_LE, CopDefault );
447
448 MakeOpcode1( CVT_S, CopDefault );
449 MakeOpcode1( CVT_W, CopDefault );
450 }
451
452 namespace OpcodeTables
453 {
454 using namespace Opcodes;
455
456 const OPCODE tbl_Standard[64] =
457 {
458 SPECIAL, REGIMM, J, JAL, BEQ, BNE, BLEZ, BGTZ,
459 ADDI, ADDIU, SLTI, SLTIU, ANDI, ORI, XORI, LUI,
460 COP0, COP1, COP2, Unknown, BEQL, BNEL, BLEZL, BGTZL,
461 DADDI, DADDIU, LDL, LDR, MMI, Unknown, LQ, SQ,
462 LB, LH, LWL, LW, LBU, LHU, LWR, LWU,
463 SB, SH, SWL, SW, SDL, SDR, SWR, CACHE,
464 Unknown, LWC1, Unknown, PREF, Unknown, Unknown, LQC2, LD,
465 Unknown, SWC1, Unknown, Unknown, Unknown, Unknown, SQC2, SD
466 };
467
468 static const OPCODE tbl_Special[64] =
469 {
470 SLL, Unknown, SRL, SRA, SLLV, Unknown, SRLV, SRAV,
471 JR, JALR, MOVZ, MOVN, SYSCALL, BREAK, Unknown, SYNC,
472 MFHI, MTHI, MFLO, MTLO, DSLLV, Unknown, DSRLV, DSRAV,
473 MULT, MULTU, DIV, DIVU, Unknown, Unknown, Unknown, Unknown,
474 ADD, ADDU, SUB, SUBU, AND, OR, XOR, NOR,
475 MFSA, MTSA, SLT, SLTU, DADD, DADDU, DSUB, DSUBU,
476 TGE, TGEU, TLT, TLTU, TEQ, Unknown, TNE, Unknown,
477 DSLL, Unknown, DSRL, DSRA, DSLL32, Unknown, DSRL32, DSRA32
478 };
479
480 static const OPCODE tbl_RegImm[32] = {
481 BLTZ, BGEZ, BLTZL, BGEZL, Unknown, Unknown, Unknown, Unknown,
482 TGEI, TGEIU, TLTI, TLTIU, TEQI, Unknown, TNEI, Unknown,
483 BLTZAL, BGEZAL, BLTZALL, BGEZALL, Unknown, Unknown, Unknown, Unknown,
484 MTSAB, MTSAH , Unknown, Unknown, Unknown, Unknown, Unknown, Unknown,
485 };
486
487 static const OPCODE tbl_MMI[64] =
488 {
489 MADD, MADDU, MMI_Unknown, MMI_Unknown, PLZCW, MMI_Unknown, MMI_Unknown, MMI_Unknown,
490 MMI0, MMI2, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
491 MFHI1, MTHI1, MFLO1, MTLO1, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
492 MULT1, MULTU1, DIV1, DIVU1, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
493 MADD1, MADDU1, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
494 MMI1, MMI3, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
495 PMFHL, PMTHL, MMI_Unknown, MMI_Unknown, PSLLH, MMI_Unknown, PSRLH, PSRAH,
496 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown, PSLLW, MMI_Unknown, PSRLW, PSRAW,
497 };
498
499 static const OPCODE tbl_MMI0[32] =
500 {
501 PADDW, PSUBW, PCGTW, PMAXW,
502 PADDH, PSUBH, PCGTH, PMAXH,
503 PADDB, PSUBB, PCGTB, MMI_Unknown,
504 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
505 PADDSW, PSUBSW, PEXTLW, PPACW,
506 PADDSH, PSUBSH, PEXTLH, PPACH,
507 PADDSB, PSUBSB, PEXTLB, PPACB,
508 MMI_Unknown, MMI_Unknown, PEXT5, PPAC5,
509 };
510
511 static const OPCODE tbl_MMI1[32] =
512 {
513 MMI_Unknown, PABSW, PCEQW, PMINW,
514 PADSBH, PABSH, PCEQH, PMINH,
515 MMI_Unknown, MMI_Unknown, PCEQB, MMI_Unknown,
516 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
517 PADDUW, PSUBUW, PEXTUW, MMI_Unknown,
518 PADDUH, PSUBUH, PEXTUH, MMI_Unknown,
519 PADDUB, PSUBUB, PEXTUB, QFSRV,
520 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
521 };
522
523
524 static const OPCODE tbl_MMI2[32] =
525 {
526 PMADDW, MMI_Unknown, PSLLVW, PSRLVW,
527 PMSUBW, MMI_Unknown, MMI_Unknown, MMI_Unknown,
528 PMFHI, PMFLO, PINTH, MMI_Unknown,
529 PMULTW, PDIVW, PCPYLD, MMI_Unknown,
530 PMADDH, PHMADH, PAND, PXOR,
531 PMSUBH, PHMSBH, MMI_Unknown, MMI_Unknown,
532 MMI_Unknown, MMI_Unknown, PEXEH, PREVH,
533 PMULTH, PDIVBW, PEXEW, PROT3W,
534 };
535
536 static const OPCODE tbl_MMI3[32] =
537 {
538 PMADDUW, MMI_Unknown, MMI_Unknown, PSRAVW,
539 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
540 PMTHI, PMTLO, PINTEH, MMI_Unknown,
541 PMULTUW, PDIVUW, PCPYUD, MMI_Unknown,
542 MMI_Unknown, MMI_Unknown, POR, PNOR,
543 MMI_Unknown, MMI_Unknown, MMI_Unknown, MMI_Unknown,
544 MMI_Unknown, MMI_Unknown, PEXCH, PCPYH,
545 MMI_Unknown, MMI_Unknown, PEXCW, MMI_Unknown,
546 };
547
548 static const OPCODE tbl_COP0[32] =
549 {
550 MFC0, COP0_Unknown, COP0_Unknown, COP0_Unknown, MTC0, COP0_Unknown, COP0_Unknown, COP0_Unknown,
551 COP0_BC0, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
552 COP0_C0, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
553 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
554 };
555
556 static const OPCODE tbl_COP0_BC0[32] =
557 {
558 BC0F, BC0T, BC0FL, BC0TL, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
559 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
560 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
561 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
562 };
563
564 static const OPCODE tbl_COP0_C0[64] =
565 {
566 COP0_Unknown, TLBR, TLBWI, COP0_Unknown, COP0_Unknown, COP0_Unknown, TLBWR, COP0_Unknown,
567 TLBP, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
568 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
569 ERET, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
570 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
571 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
572 COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown,
573 EI, DI, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown, COP0_Unknown
574 };
575
576 static const OPCODE tbl_COP1[32] =
577 {
578 MFC1, COP1_Unknown, CFC1, COP1_Unknown, MTC1, COP1_Unknown, CTC1, COP1_Unknown,
579 COP1_BC1, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
580 COP1_S, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_W, COP1_Unknown, COP1_Unknown, COP1_Unknown,
581 COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
582 };
583
584 static const OPCODE tbl_COP1_BC1[32] =
585 {
586 BC1F, BC1T, BC1FL, BC1TL, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
587 COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
588 COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
589 COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown, COP1_Unknown,
590 };
591
592 static const OPCODE tbl_COP1_S[64] =
593 {
594 ADD_S, SUB_S, MUL_S, DIV_S, SQRT_S, ABS_S, MOV_S, NEG_S,
595 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
596 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,RSQRT_S, COP1_Unknown,
597 ADDA_S, SUBA_S, MULA_S, COP1_Unknown,MADD_S, MSUB_S, MADDA_S, MSUBA_S,
598 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,CVT_W, COP1_Unknown,COP1_Unknown,COP1_Unknown,
599 MAX_S, MIN_S, COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
600 C_F, COP1_Unknown,C_EQ, COP1_Unknown,C_LT, COP1_Unknown,C_LE, COP1_Unknown,
601 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
602 };
603
604 static const OPCODE tbl_COP1_W[64] =
605 {
606 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
607 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
608 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
609 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
610 CVT_S, COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
611 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
612 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
613 COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,COP1_Unknown,
614 };
615
616 } // end namespace R5900::OpcodeTables
617
618 namespace Opcodes
619 {
620 using namespace OpcodeTables;
621
622 const OPCODE& Class_SPECIAL() { return tbl_Special[_Funct_]; }
623 const OPCODE& Class_REGIMM() { return tbl_RegImm[_Rt_]; }
624
625 const OPCODE& Class_MMI() { return tbl_MMI[_Funct_]; }
626 const OPCODE& Class_MMI0() { return tbl_MMI0[_Sa_]; }
627 const OPCODE& Class_MMI1() { return tbl_MMI1[_Sa_]; }
628 const OPCODE& Class_MMI2() { return tbl_MMI2[_Sa_]; }
629 const OPCODE& Class_MMI3() { return tbl_MMI3[_Sa_]; }
630
631 const OPCODE& Class_COP0() { return tbl_COP0[_Rs_]; }
632 const OPCODE& Class_COP0_BC0() { return tbl_COP0_BC0[(cpuRegs.code >> 16) & 0x03]; }
633 const OPCODE& Class_COP0_C0() { return tbl_COP0_C0[_Funct_]; }
634
635 const OPCODE& Class_COP1() { return tbl_COP1[_Rs_]; }
636 const OPCODE& Class_COP1_BC1() { return tbl_COP1_BC1[_Rt_]; }
637 const OPCODE& Class_COP1_S() { return tbl_COP1_S[_Funct_]; }
638 const OPCODE& Class_COP1_W() { return tbl_COP1_W[_Funct_]; }
639
640 // These are for future use when the COP2 tables are completed.
641 //const OPCODE& Class_COP2() { return tbl_COP2[_Rs_]; }
642 //const OPCODE& Class_COP2_BC2() { return tbl_COP2_BC2[_Rt_]; }
643 //const OPCODE& Class_COP2_SPECIAL() { return tbl_COP2_SPECIAL[_Funct_]; }
644 //const OPCODE& Class_COP2_SPECIAL2() { return tbl_COP2_SPECIAL2[(cpuRegs.code & 0x3) | ((cpuRegs.code >> 4) & 0x7c)]; }
645 }
646 } // end namespace R5900
647
648 void (*Int_COP2PrintTable[32])() = {
649 COP2_Unknown, QMFC2, CFC2, COP2_Unknown, COP2_Unknown, QMTC2, CTC2, COP2_Unknown,
650 COP2_BC2, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown,
651 COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL,
652 COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL, COP2_SPECIAL,
653 };
654
655 void (*Int_COP2BC2PrintTable[32])() = {
656 BC2F, BC2T, BC2FL, BC2TL, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown,
657 COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown,
658 COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown,
659 COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown, COP2_Unknown,
660 };
661
662 void (*Int_COP2SPECIAL1PrintTable[64])() =
663 {
664 VADDx, VADDy, VADDz, VADDw, VSUBx, VSUBy, VSUBz, VSUBw,
665 VMADDx, VMADDy, VMADDz, VMADDw, VMSUBx, VMSUBy, VMSUBz, VMSUBw,
666 VMAXx, VMAXy, VMAXz, VMAXw, VMINIx, VMINIy, VMINIz, VMINIw,
667 VMULx, VMULy, VMULz, VMULw, VMULq, VMAXi, VMULi, VMINIi,
668 VADDq, VMADDq, VADDi, VMADDi, VSUBq, VMSUBq, VSUBi, VMSUBi,
669 VADD, VMADD, VMUL, VMAX, VSUB, VMSUB, VOPMSUB, VMINI,
670 VIADD, VISUB, VIADDI, COP2_Unknown,VIAND, VIOR, COP2_Unknown, COP2_Unknown,
671 VCALLMS, VCALLMSR, COP2_Unknown,COP2_Unknown,COP2_SPECIAL2,COP2_SPECIAL2,COP2_SPECIAL2,COP2_SPECIAL2,
672 };
673
674 void (*Int_COP2SPECIAL2PrintTable[128])() =
675 {
676 VADDAx ,VADDAy ,VADDAz ,VADDAw ,VSUBAx ,VSUBAy ,VSUBAz ,VSUBAw,
677 VMADDAx ,VMADDAy ,VMADDAz ,VMADDAw ,VMSUBAx ,VMSUBAy ,VMSUBAz ,VMSUBAw,
678 VITOF0 ,VITOF4 ,VITOF12 ,VITOF15 ,VFTOI0 ,VFTOI4 ,VFTOI12 ,VFTOI15,
679 VMULAx ,VMULAy ,VMULAz ,VMULAw ,VMULAq ,VABS ,VMULAi ,VCLIPw,
680 VADDAq ,VMADDAq ,VADDAi ,VMADDAi ,VSUBAq ,VMSUBAq ,VSUBAi ,VMSUBAi,
681 VADDA ,VMADDA ,VMULA ,COP2_Unknown,VSUBA ,VMSUBA ,VOPMULA ,VNOP,
682 VMOVE ,VMR32 ,COP2_Unknown,COP2_Unknown,VLQI ,VSQI ,VLQD ,VSQD,
683 VDIV ,VSQRT ,VRSQRT ,VWAITQ ,VMTIR ,VMFIR ,VILWR ,VISWR,
684 VRNEXT ,VRGET ,VRINIT ,VRXOR ,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
685 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
686 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
687 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
688 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
689 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
690 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
691 COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,COP2_Unknown,
692 };

  ViewVC Help
Powered by ViewVC 1.1.22