annotate jagcpu.c @ 2229:f699f9d500b4

Fix build
author Michael Pavone <pavone@retrodev.com>
date Mon, 05 Sep 2022 23:48:17 -0700
parents c1e78a101912
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdint.h>
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdio.h>
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include "jagcpu.h"
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 char *gpu_mnemonics[] = {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 "add",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 "addc",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 "addq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 "addqt",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 "sub",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 "subc",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 "subq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 "subqt",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 "neg",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 "and",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 "or",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 "xor",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 "not",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 "btst",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 "bset",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 "bclr",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 "mult",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 "imult",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 "imultn",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 "resmac",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 "imacn",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 "div",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 "abs",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29 "sh",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 "shlq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 "shrq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 "sha",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 "sharq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 "ror",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 "rorq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 "cmp",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 "cmpq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 "sat8",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39 "sat16",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 "move",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 "moveq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 "moveta",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 "movefa",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 "movei",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 "loadb",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 "loadw",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 "load",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 "loadp",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 "load", //r14 relative
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 "load", //r15 relative
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 "storeb",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 "storew",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 "store",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 "storep",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 "store", //r14 relative
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 "store", //r15 relative
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 "move", //PC
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 "jump",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 "jr",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 "mmult",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 "mtoi",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 "normi",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 "nop",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 "load", //r14 indexed
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 "load", //r15 indexed
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 "store", //r14 indexed
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 "store", //r15 indexed
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 "sat24",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 "pack",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 "unpack"
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 };
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 char *dsp_mnemonics[DSP_ADDQMOD+1] = {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 [DSP_SUBQMOD] = "subqmod",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 [DSP_SAT16S] = "sat16s",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 [DSP_SAT32S] = "sat32s",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77 [DSP_MIRROR] = "mirror",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 [DSP_ADDQMOD] = "addqmod"
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 };
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 void init_dsp_mnemonic_table()
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 static uint8_t init_done;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 if (init_done) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 return;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 for (int i = 0; i < DSP_ADDQMOD; i++)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 if (!dsp_mnemonics[i]) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 dsp_mnemonics[i] = gpu_mnemonics[i];
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 init_done = 1;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 uint16_t jag_opcode(uint16_t inst, uint8_t is_gpu)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 {
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
98 uint16_t opcode = inst >> 10;
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 if (is_gpu && opcode == GPU_PACK && (inst & 0x20)) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 return GPU_UNPACK;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
101 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
102 return opcode;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
105 uint16_t jag_reg2(uint16_t inst)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
106 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
107 return inst & 0x1F;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
108 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
109
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
110 uint16_t jag_reg1(uint16_t inst)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
111 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
112 return inst >> 5 & 0x1F;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
113 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
114
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
115 //moveq and bit instructions should just use jag_reg1 instead
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
116 uint32_t jag_quick(uint16_t inst)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
117 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
118 uint32_t val = inst >> 5 & 0x1F;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
119 return val ? val : 32;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
120 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
121
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
122 uint8_t is_quick_1_32_opcode(uint16_t opcode, uint8_t is_gpu)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
123 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
124 return opcode == JAG_ADDQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
125 || opcode == JAG_ADDQT
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
126 || opcode == JAG_SUBQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
127 || opcode == JAG_SUBQT
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
128 || opcode == JAG_SHLQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
129 || opcode == JAG_SHRQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
130 || opcode == JAG_SHARQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
131 || opcode == JAG_RORQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
132 || (!is_gpu && (
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
133 opcode == DSP_SUBQMOD
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
134 || opcode == DSP_ADDQMOD
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
135 ));
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
136 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
137
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
138 uint8_t is_quick_0_31_opcode(uint16_t opcode)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
139 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
140 return opcode == JAG_MOVEQ
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
141 || opcode == JAG_BTST
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
142 || opcode == JAG_BSET
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
143 || opcode == JAG_BCLR;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
144 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
145
1096
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
146 uint8_t is_load(uint16_t opcode, uint8_t is_gpu)
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
147 {
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
148 return opcode == JAG_LOAD
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
149 || opcode == JAG_LOADB
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
150 || opcode == JAG_LOADW
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
151 || (is_gpu && opcode == GPU_LOADP);
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
152 }
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
153
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
154 uint8_t is_store(uint16_t opcode, uint8_t is_gpu)
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
155 {
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
156 return opcode == JAG_STORE
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
157 || opcode == JAG_STOREB
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
158 || opcode == JAG_STOREW
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
159 || (is_gpu && opcode == GPU_STOREP);
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
160 }
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
161
1115
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
162 uint8_t is_single_source(uint16_t opcode, uint8_t is_gpu)
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
163 {
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
164 return opcode == JAG_NEG
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
165 || opcode == JAG_NOT
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
166 || opcode == JAG_ABS
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
167 || opcode == GPU_SAT16 //no is_gpu check needed as DSP_SAT16S is also single source
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
168 || (is_gpu && (
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
169 opcode == GPU_SAT8
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
170 || opcode == GPU_SAT24
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
171 || opcode == GPU_PACK
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
172 || opcode == GPU_UNPACK
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
173 ))
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
174 || (!is_gpu && (
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
175 opcode == DSP_SAT32S
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
176 || opcode == DSP_MIRROR
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
177 ));
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
178 }
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
179
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
180 char * jag_cc_names[] = {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
181 "t",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
182 "ne",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
183 "eq",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
184 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
185 "cc",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
186 "hi",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
187 "eq_cc",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
188 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
189 "cs",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
190 "ne_cs",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
191 "eq_cs",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
192 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
193 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
194 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
195 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
196 "f"
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
197 "t_alt",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
198 "ne_alt",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
199 "eq_alt",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
200 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
201 "pl",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
202 "ne_pl",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
203 "eq_pl",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
204 "f",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
205 "mi",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
206 "ne_mi",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
207 "eq_mi"
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
208 };
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
209
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
210 char * jag_cc(uint16_t inst)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
211 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
212 uint16_t ccnum = jag_reg2(inst);
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
213 if (ccnum >= sizeof(jag_cc_names)/sizeof(*jag_cc_names)) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
214 return jag_cc_names[3];
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
215 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
216 return jag_cc_names[ccnum];
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
217 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
218
1115
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
219 uint8_t jag_is_alwyas_falsse(uint16_t cond)
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
220 {
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
221 return (cond & 3) == 3 || (cond && 0xC) == 0xC;
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
222 }
c1e78a101912 WIP Jaguar GPU/DSP emulation
Michael Pavone <pavone@retrodev.com>
parents: 1096
diff changeset
223
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
224 uint32_t jag_jr_dest(uint16_t inst, uint32_t address)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
225 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
226 uint32_t rel = jag_reg1(inst);
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
227 if (rel & 0x10) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
228 rel |= 0xFFFFFFE0;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
229 }
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
230 return address + 2 + rel*2;
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
231 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
232
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
233 int jag_cpu_disasm(uint16_t **stream, uint32_t address, char *dst, uint8_t is_gpu, uint8_t labels)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
234 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
235 uint16_t inst = **stream;
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
236 (*stream)++;
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
237 uint16_t opcode = jag_opcode(inst, is_gpu);
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
238 char **mnemonics;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
239 if (is_gpu) {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
240 mnemonics = gpu_mnemonics;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
241 } else {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
242 init_dsp_mnemonic_table();
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
243 mnemonics = dsp_mnemonics;
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
244 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
245 switch (opcode)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
246 {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
247 case JAG_MOVEI: {
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
248 uint32_t immed = **stream;
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
249 (*stream)++;
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
250 immed |= **stream << 16;
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
251 (*stream)++;
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
252 return sprintf(dst, "%s $%X, r%d", mnemonics[opcode], immed, jag_reg2(inst));
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
253 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
254 case JAG_JR:
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
255 return sprintf(dst,
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
256 labels ? "%s %s, ADR_%X" : "%s %s, $W%X",
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
257 mnemonics[opcode], jag_cc(inst), jag_jr_dest(inst, address)
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
258 );
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
259 case JAG_JUMP:
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
260 return sprintf(dst, "%s %s, (r%d)", mnemonics[opcode], jag_cc(inst), jag_reg1(inst));
1095
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
261 case JAG_LOAD_R14_REL:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
262 case JAG_LOAD_R15_REL:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
263 return sprintf(dst, "%s (r%d+%d), r%d",
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
264 mnemonics[opcode],
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
265 opcode == JAG_LOAD_R14_REL ? 14 : 15,
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
266 jag_quick(inst),
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
267 jag_reg2(inst)
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
268 );
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
269 break;
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
270 case JAG_STORE_R14_REL:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
271 case JAG_STORE_R15_REL:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
272 return sprintf(dst, "%s r%d, (r%d+%d)",
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
273 mnemonics[opcode],
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
274 jag_reg2(inst),
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
275 opcode == JAG_STORE_R14_REL ? 14 : 15,
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
276 jag_quick(inst)
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
277 );
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
278 break;
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
279 case JAG_LOAD_R14_INDEXED:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
280 case JAG_LOAD_R15_INDEXED:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
281 return sprintf(dst, "%s (r%d+r%d), r%d",
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
282 mnemonics[opcode],
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
283 opcode == JAG_LOAD_R14_INDEXED ? 14 : 15,
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
284 jag_reg1(inst),
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
285 jag_reg2(inst)
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
286 );
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
287 break;
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
288 case JAG_STORE_R14_INDEXED:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
289 case JAG_STORE_R15_INDEXED:
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
290 return sprintf(dst, "%s r%d, (r%d+r%d)",
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
291 mnemonics[opcode],
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
292 jag_reg2(inst),
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
293 opcode == JAG_STORE_R14_INDEXED ? 14 : 15,
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
294 jag_reg1(inst)
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
295 );
920d796ea6a2 Correct disassembly of r14/r15 relative loads and stores
Michael Pavone <pavone@retrodev.com>
parents: 1094
diff changeset
296 break;
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
297 default:
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
298 if (is_quick_1_32_opcode(opcode, is_gpu)) {
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
299 return sprintf(dst, "%s %d, r%d", mnemonics[opcode], jag_quick(inst), jag_reg2(inst));
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
300 } else if (is_quick_0_31_opcode(opcode)) {
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
301 return sprintf(dst, "%s %d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst));
1096
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
302 } else if (is_load(opcode, is_gpu)) {
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
303 return sprintf(dst, "%s (r%d), r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst));
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
304 } else if (is_store(opcode, is_gpu)) {
1ab30d427db8 Better disassembly of GPU/DSP load store instructions
Michael Pavone <pavone@retrodev.com>
parents: 1095
diff changeset
305 return sprintf(dst, "%s r%d, (r%d)", mnemonics[opcode], jag_reg2(inst), jag_reg1(inst));
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
306 } else {
1094
1dba006bad47 Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
Michael Pavone <pavone@retrodev.com>
parents: 1093
diff changeset
307 return sprintf(dst, "%s r%d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst));
1093
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
308 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
309 }
4987fddd42a0 Initial stab at jaguar disassemler
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
310 }