begin merging Hermes patch to gcdsptool to the dsp lle-testing plugin

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2842 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-04-03 06:21:45 +00:00
parent 230f17a639
commit c6ea5b136f
2 changed files with 71 additions and 133 deletions

View File

@ -675,7 +675,7 @@ void nx(const UDSPInstruction& opc)
// FIXME inside // FIXME inside
// TODO: add to opcode table // Hermes switched andf and andcf, so check to make sure they are still correct
void andfc(const UDSPInstruction& opc) void andfc(const UDSPInstruction& opc)
{ {
if (opc.hex & 0xf) if (opc.hex & 0xf)
@ -699,6 +699,7 @@ void andfc(const UDSPInstruction& opc)
} }
// FIXME inside // FIXME inside
// Hermes switched andf and andcf, so check to make sure they are still correct
void andf(const UDSPInstruction& opc) void andf(const UDSPInstruction& opc)
{ {
u8 reg; u8 reg;

View File

@ -120,20 +120,20 @@ pdlabel_t regnames[] =
{0x15, "PROD.M1", "PROD M1",}, {0x15, "PROD.M1", "PROD M1",},
{0x16, "PROD.H", "PROD H",}, {0x16, "PROD.H", "PROD H",},
{0x17, "PROD.M2", "PROD M2",}, {0x17, "PROD.M2", "PROD M2",},
{0x18, "AX0.L", "Additional Accumulators Low 0",}, {0x18, "AX0.L", "Additional Accumulators Low 0",},
{0x19, "AX1.L", "Additional Accumulators Low 1",}, {0x19, "AX1.L", "Additional Accumulators Low 1",},
{0x1a, "AX0.H", "Additional Accumulators High 0",}, {0x1a, "AX0.H", "Additional Accumulators High 0",},
{0x1b, "AX1.H", "Additional Accumulators High 1",}, {0x1b, "AX1.H", "Additional Accumulators High 1",},
{0x1c, "AC0.L", "Register 28",}, {0x1c, "AC0.L", "Register 28",},
{0x1d, "AC1.L", "Register 29",}, {0x1d, "AC1.L", "Register 29",},
{0x1e, "AC0.M", "Register 00",}, {0x1e, "AC0.M", "Register 00",},
{0x1f, "AC1.M", "Register 00",}, {0x1f, "AC1.M", "Register 00",},
// additional to resolve special names // additional to resolve special names
{0x20, "ACC0", "Accumulators 0",}, {0x20, "ACC0", "Accumulators 0",},
{0x21, "ACC1", "Accumulators 1",}, {0x21, "ACC1", "Accumulators 1",},
{0x22, "AX0", "Additional Accumulators 0",}, {0x22, "AX0", "Additional Accumulators 0",},
{0x23, "AX1", "Additional Accumulators 1",}, {0x23, "AX1", "Additional Accumulators 1",},
}; };
const char* pdname(u16 val) const char* pdname(u16 val)
@ -143,16 +143,13 @@ const char* pdname(u16 val)
for (int i = 0; i < (int)(sizeof(pdlabels) / sizeof(pdlabel_t)); i++) for (int i = 0; i < (int)(sizeof(pdlabels) / sizeof(pdlabel_t)); i++)
{ {
if (pdlabels[i].addr == val) if (pdlabels[i].addr == val)
{
return(pdlabels[i].name); return(pdlabels[i].name);
}
} }
sprintf(tmpstr, "0x%04x", val); sprintf(tmpstr, "0x%04x", val);
return(tmpstr); return tmpstr;
} }
char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, char* strbuf) char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, char* strbuf)
{ {
char* buf = strbuf; char* buf = strbuf;
@ -168,103 +165,88 @@ char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, ch
} }
if (opc->params[j].loc >= 1) if (opc->params[j].loc >= 1)
{
val = op2; val = op2;
}
else else
{
val = op1; val = op1;
}
val &= opc->params[j].mask; val &= opc->params[j].mask;
if (opc->params[j].lshift < 0) if (opc->params[j].lshift < 0)
{
val = val << (-opc->params[j].lshift); val = val << (-opc->params[j].lshift);
}
else else
{
val = val >> opc->params[j].lshift; val = val >> opc->params[j].lshift;
}
u32 type; u32 type;
type = opc->params[j].type; type = opc->params[j].type;
if ((type & 0xff) == 0x10)
type &= 0xff00;
if (type & P_REG) if (type & P_REG)
{ {
if (type == P_ACCM_D) if (type == P_ACCD) // Used to be P_ACCM_D TODO verify
{
val = (~val & 0x1) | ((type & P_REGS_MASK) >> 8); val = (~val & 0x1) | ((type & P_REGS_MASK) >> 8);
}
else else
{
val |= (type & P_REGS_MASK) >> 8; val |= (type & P_REGS_MASK) >> 8;
}
type &= ~P_REGS_MASK; type &= ~P_REGS_MASK;
} }
switch (type) switch (type)
{ {
case P_REG: case P_REG:
if (gdg->decode_registers)
sprintf(buf, "$%s", regnames[val].name);
else
sprintf(buf, "$%d", val);
break;
if (gdg->decode_registers){sprintf(buf, "$%s", regnames[val].name);} case P_PRG:
else {sprintf(buf, "$%d", val);} if (gdg->decode_registers)
sprintf(buf, "@$%s", regnames[val].name);
else
sprintf(buf, "@$%d", val);
break;
break; case P_VAL:
if (gdg->decode_names)
sprintf(buf, "%s", pdname(val));
else
sprintf(buf, "0x%04x", val);
break;
case P_PRG: case P_IMM:
if (opc->params[j].size != 2)
{
if (opc->params[j].mask == 0x007f) // LSL, LSR, ASL, ASR
sprintf(buf, "#%d", val < 64 ? val : -(0x80-val)); // I know compiler complains, but this is in gcdsptool...
else
sprintf(buf, "#0x%02x", val);
}
else
sprintf(buf, "#0x%04x", val);
break;
if (gdg->decode_registers){sprintf(buf, "@$%s", regnames[val].name);} case P_MEM:
else {sprintf(buf, "@$%d", val);} if (opc->params[j].size != 2)
val = (u16)(s8)val;
break; if (gdg->decode_names)
sprintf(buf, "@%s", pdname(val));
else
sprintf(buf, "@0x%04x", val);
break;
case P_VAL: default:
sprintf(buf, "0x%04x", val); ERROR_LOG(DSPHLE, "Unknown parameter type: %x", opc->params[j].type);
break; exit(-1);
break;
case P_IMM:
if (opc->params[j].size != 2)
{
sprintf(buf, "#0x%02x", val);
}
else
{
sprintf(buf, "#0x%04x", val);
}
break;
case P_MEM:
if (opc->params[j].size != 2)
{
val = (u16)(s8)val;
}
if (gdg->decode_names)
{
sprintf(buf, "@%s", pdname(val));
}
else
{
sprintf(buf, "@0x%04x", val);
}
break;
default:
ERROR_LOG(DSPHLE, "Unknown parameter type: %x\n", opc->params[j].type);
exit(-1);
break;
} }
buf += strlen(buf); buf += strlen(buf);
} }
return(strbuf); return strbuf;
} }
@ -283,9 +265,7 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
bool extended; bool extended;
if ((gdg->pc & 0x7fff) >= 0x1000) if ((gdg->pc & 0x7fff) >= 0x1000)
{ return 1;
return(1);
}
u32 op1 = Common::swap16(gdg->binbuf[gdg->pc & 0x0fff]); u32 op1 = Common::swap16(gdg->binbuf[gdg->pc & 0x0fff]);
@ -294,13 +274,9 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
u16 mask; u16 mask;
if (opcodes[j].size & P_EXT) if (opcodes[j].size & P_EXT)
{
mask = opcodes[j].opcode_mask & 0xff00; mask = opcodes[j].opcode_mask & 0xff00;
}
else else
{
mask = opcodes[j].opcode_mask; mask = opcodes[j].opcode_mask;
}
if ((op1 & mask) == opcodes[j].opcode) if ((op1 & mask) == opcodes[j].opcode)
{ {
@ -316,13 +292,9 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
} }
if (opc->size & P_EXT && op1 & 0x00ff) if (opc->size & P_EXT && op1 & 0x00ff)
{
extended = true; extended = true;
}
else else
{
extended = false; extended = false;
}
if (extended) if (extended)
{ {
@ -342,7 +314,7 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
ERROR_LOG(DSPHLE, "get_opcode_size ext ARGH"); ERROR_LOG(DSPHLE, "get_opcode_size ext ARGH");
} }
return(opc_ext->size); return opc_ext->size;
} }
return(opc->size & ~P_EXT); return(opc->size & ~P_EXT);
@ -377,13 +349,9 @@ char* gd_dis_opcode(gd_globals_t* gdg)
u16 mask; u16 mask;
if (opcodes[j].size & P_EXT) if (opcodes[j].size & P_EXT)
{
mask = opcodes[j].opcode_mask & 0xff00; mask = opcodes[j].opcode_mask & 0xff00;
}
else else
{
mask = opcodes[j].opcode_mask; mask = opcodes[j].opcode_mask;
}
if ((op1 & mask) == opcodes[j].opcode) if ((op1 & mask) == opcodes[j].opcode)
{ {
@ -393,13 +361,9 @@ char* gd_dis_opcode(gd_globals_t* gdg)
} }
if (opc->size & P_EXT && op1 & 0x00ff) if (opc->size & P_EXT && op1 & 0x00ff)
{
extended = true; extended = true;
}
else else
{
extended = false; extended = false;
}
if (extended) if (extended)
{ {
@ -417,7 +381,8 @@ char* gd_dis_opcode(gd_globals_t* gdg)
// printing // printing
if (gdg->show_pc){sprintf(buf, "%04x ", gdg->pc);} if (gdg->show_pc)
sprintf(buf, "%04x ", gdg->pc);
buf += strlen(buf); buf += strlen(buf);
@ -425,13 +390,15 @@ char* gd_dis_opcode(gd_globals_t* gdg)
{ {
op2 = Common::swap16(gdg->binbuf[pc + 1]); op2 = Common::swap16(gdg->binbuf[pc + 1]);
if (gdg->show_hex){sprintf(buf, "%04x %04x ", op1, op2);} if (gdg->show_hex)
sprintf(buf, "%04x %04x ", op1, op2);
} }
else else
{ {
op2 = 0; op2 = 0;
if (gdg->show_hex){sprintf(buf, "%04x ", op1);} if (gdg->show_hex)
sprintf(buf, "%04x ", op1);
} }
buf += strlen(buf); buf += strlen(buf);
@ -439,38 +406,26 @@ char* gd_dis_opcode(gd_globals_t* gdg)
char tmpbuf[20]; char tmpbuf[20];
if (extended) if (extended)
{
sprintf(tmpbuf, "%s%c%s", opc->name, gdg->ext_separator, opc_ext->name); sprintf(tmpbuf, "%s%c%s", opc->name, gdg->ext_separator, opc_ext->name);
}
else else
{
sprintf(tmpbuf, "%s", opc->name); sprintf(tmpbuf, "%s", opc->name);
}
if (gdg->print_tabs) if (gdg->print_tabs)
{
sprintf(buf, "%s\t", tmpbuf); sprintf(buf, "%s\t", tmpbuf);
}
else else
{
sprintf(buf, "%-12s", tmpbuf); sprintf(buf, "%-12s", tmpbuf);
}
buf += strlen(buf); buf += strlen(buf);
if (opc->param_count > 0) if (opc->param_count > 0)
{
gd_dis_params(gdg, opc, op1, op2, buf); gd_dis_params(gdg, opc, op1, op2, buf);
}
buf += strlen(buf); buf += strlen(buf);
if (extended) if (extended)
{ {
if (opc->param_count > 0) if (opc->param_count > 0)
{
sprintf(buf, " "); sprintf(buf, " ");
}
buf += strlen(buf); buf += strlen(buf);
@ -478,9 +433,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
buf += strlen(buf); buf += strlen(buf);
if (opc_ext->param_count > 0) if (opc_ext->param_count > 0)
{
gd_dis_params(gdg, opc_ext, op1, op2, buf); gd_dis_params(gdg, opc_ext, op1, op2, buf);
}
buf += strlen(buf); buf += strlen(buf);
} }
@ -493,18 +446,13 @@ char* gd_dis_opcode(gd_globals_t* gdg)
} }
if (extended) if (extended)
{
gdg->pc += opc_ext->size; gdg->pc += opc_ext->size;
}
else else
{
gdg->pc += opc->size & ~P_EXT; gdg->pc += opc->size & ~P_EXT;
}
return(gdg->buffer); return(gdg->buffer);
} }
bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output) bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
{ {
FILE* in; FILE* in;
@ -513,9 +461,7 @@ bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
in = fopen(name, "rb"); in = fopen(name, "rb");
if (in == NULL) if (in == NULL)
{ return false;
return(false);
}
fseek(in, 0, SEEK_END); fseek(in, 0, SEEK_END);
size = (int)ftell(in); size = (int)ftell(in);
@ -527,9 +473,7 @@ bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
gdg->buffer_size = 256; gdg->buffer_size = 256;
for (gdg->pc = 0; gdg->pc < (size / 2);) for (gdg->pc = 0; gdg->pc < (size / 2);)
{
fprintf(output, "%s\n", gd_dis_opcode(gdg)); fprintf(output, "%s\n", gd_dis_opcode(gdg));
}
fclose(in); fclose(in);
@ -540,10 +484,9 @@ bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
gdg->buffer = NULL; gdg->buffer = NULL;
gdg->buffer_size = 0; gdg->buffer_size = 0;
return(true); return true;
} }
void gd_dis_close_unkop() void gd_dis_close_unkop()
{ {
FILE* uo; FILE* uo;
@ -572,9 +515,7 @@ void gd_dis_close_unkop()
for (j = 15; j >= 0; j--) for (j = 15; j >= 0; j--)
{ {
if ((j & 0x3) == 3) if ((j & 0x3) == 3)
{
fprintf(uo, "\tb"); fprintf(uo, "\tb");
}
fprintf(uo, "%d", (i >> j) & 0x1); fprintf(uo, "%d", (i >> j) & 0x1);
} }
@ -588,7 +529,6 @@ void gd_dis_close_unkop()
} }
} }
void gd_dis_open_unkop() void gd_dis_open_unkop()
{ {
FILE* uo; FILE* uo;
@ -611,10 +551,7 @@ void gd_dis_open_unkop()
} }
} }
const char* gd_dis_get_reg_name(u16 reg) const char* gd_dis_get_reg_name(u16 reg)
{ {
return(regnames[reg].name); return(regnames[reg].name);
} }