Mercurial > repos > blastem
comparison jagcpu.c @ 1094:1dba006bad47
Get Jaguar disassembler more or less working. Dump gpu program to file when GPU GO bit is set
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 31 Oct 2016 09:23:25 -0700 |
parents | 4987fddd42a0 |
children | 920d796ea6a2 |
comparison
equal
deleted
inserted
replaced
1093:4987fddd42a0 | 1094:1dba006bad47 |
---|---|
93 init_done = 1; | 93 init_done = 1; |
94 } | 94 } |
95 | 95 |
96 uint16_t jag_opcode(uint16_t inst, uint8_t is_gpu) | 96 uint16_t jag_opcode(uint16_t inst, uint8_t is_gpu) |
97 { | 97 { |
98 uint16_t opcode = inst >> 11; | 98 uint16_t opcode = inst >> 10; |
99 if (is_gpu && opcode == GPU_PACK && (inst & 0x20)) { | 99 if (is_gpu && opcode == GPU_PACK && (inst & 0x20)) { |
100 return GPU_UNPACK; | 100 return GPU_UNPACK; |
101 } | 101 } |
102 return opcode; | 102 return opcode; |
103 } | 103 } |
186 { | 186 { |
187 uint32_t rel = jag_reg1(inst); | 187 uint32_t rel = jag_reg1(inst); |
188 if (rel & 0x10) { | 188 if (rel & 0x10) { |
189 rel |= 0xFFFFFFE0; | 189 rel |= 0xFFFFFFE0; |
190 } | 190 } |
191 return address + 2 + rel; | 191 return address + 2 + rel*2; |
192 } | 192 } |
193 | 193 |
194 int jag_cpu_disasm(uint16_t **stream, uint32_t address, char *dst, uint8_t is_gpu, uint8_t labels) | 194 int jag_cpu_disasm(uint16_t **stream, uint32_t address, char *dst, uint8_t is_gpu, uint8_t labels) |
195 { | 195 { |
196 uint16_t inst = **stream; | 196 uint16_t inst = **stream; |
197 *stream++; | 197 (*stream)++; |
198 uint16_t opcode = jag_opcode(inst, is_gpu); | 198 uint16_t opcode = jag_opcode(inst, is_gpu); |
199 char **mnemonics; | 199 char **mnemonics; |
200 if (is_gpu) { | 200 if (is_gpu) { |
201 mnemonics = gpu_mnemonics; | 201 mnemonics = gpu_mnemonics; |
202 } else { | 202 } else { |
205 } | 205 } |
206 switch (opcode) | 206 switch (opcode) |
207 { | 207 { |
208 case JAG_MOVEI: { | 208 case JAG_MOVEI: { |
209 uint32_t immed = **stream; | 209 uint32_t immed = **stream; |
210 *stream++; | 210 (*stream)++; |
211 immed |= **stream << 16; | 211 immed |= **stream << 16; |
212 *stream++; | 212 (*stream)++; |
213 return sprintf("%s $%X, r%d", mnemonics[opcode], immed, jag_reg2(inst)); | 213 return sprintf(dst, "%s $%X, r%d", mnemonics[opcode], immed, jag_reg2(inst)); |
214 } | 214 } |
215 case JAG_JR: | 215 case JAG_JR: |
216 return sprintf( | 216 return sprintf(dst, |
217 labels ? "%s %s, ADR_%X" : "%s %s, $W%X", | 217 labels ? "%s %s, ADR_%X" : "%s %s, $W%X", |
218 mnemonics[opcode], jag_cc(inst), jag_jr_dest(inst, address) | 218 mnemonics[opcode], jag_cc(inst), jag_jr_dest(inst, address) |
219 ); | 219 ); |
220 case JAG_JUMP: | 220 case JAG_JUMP: |
221 return sprintf("%s %s, (r%d)", mnemonics[opcode], jag_cc(inst), jag_reg1(inst)); | 221 return sprintf(dst, "%s %s, (r%d)", mnemonics[opcode], jag_cc(inst), jag_reg1(inst)); |
222 default: | 222 default: |
223 if (is_quick_1_32_opcode(opcode, is_gpu)) { | 223 if (is_quick_1_32_opcode(opcode, is_gpu)) { |
224 return sprintf("%s %d, r%d", mnemonics[opcode], jag_quick(inst), jag_reg2(inst)); | 224 return sprintf(dst, "%s %d, r%d", mnemonics[opcode], jag_quick(inst), jag_reg2(inst)); |
225 } else if (is_quick_0_31_opcode(opcode)) { | 225 } else if (is_quick_0_31_opcode(opcode)) { |
226 return sprintf("%s %d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst)); | 226 return sprintf(dst, "%s %d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst)); |
227 } else { | 227 } else { |
228 return sprintf("%s r%d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst)); | 228 return sprintf(dst, "%s r%d, r%d", mnemonics[opcode], jag_reg1(inst), jag_reg2(inst)); |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |