diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-04-18 12:27:24 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-04-18 12:27:24 +0000 |
| commit | ee933cb5d4c96bd085ccfe3394f9d9617e647724 (patch) | |
| tree | 0a490cd539aa42808a2050a901b41caaadfdcffc /Source/Core/DSPCore/Src/DSPCodeUtil.cpp | |
| parent | e7e4ef4481d1c5dcce6463414d815843ae15b8e2 (diff) | |
DSPtool: Better code comparer + cmdline interface added. header generator bugfixed. dsp_test.S now matches the binary.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2994 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DSPCore/Src/DSPCodeUtil.cpp')
| -rw-r--r-- | Source/Core/DSPCore/Src/DSPCodeUtil.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp index 370e945a12..d2578493b2 100644 --- a/Source/Core/DSPCore/Src/DSPCodeUtil.cpp +++ b/Source/Core/DSPCore/Src/DSPCodeUtil.cpp @@ -66,12 +66,34 @@ bool Compare(const std::vector<u16> &code1, const std::vector<u16> &code2) printf("Size difference! 1=%i 2=%i\n", (int)code1.size(), (int)code2.size());
int count_equal = 0;
const int min_size = (int)std::min(code1.size(), code2.size());
+
+ AssemblerSettings settings;
+ DSPDisassembler disassembler(settings);
for (int i = 0; i < min_size; i++)
{
if (code1[i] == code2[i])
count_equal++;
else
- printf("!! %04x : %04x vs %04x\n", i, code1[i], code2[i]);
+ {
+ std::string line1, line2;
+ u16 pc = i;
+ disassembler.DisOpcode(&code1[0], 2, &pc, &line1);
+ pc = i;
+ disassembler.DisOpcode(&code2[0], 2, &pc, &line2);
+ printf("!! %04x : %04x vs %04x - %s vs %s\n", i, code1[i], code2[i], line1.c_str(), line2.c_str());
+ }
+ }
+ if (code2.size() != code1.size())
+ {
+ printf("Extra code words:\n");
+ const std::vector<u16> &longest = code1.size() > code2.size() ? code1 : code2;
+ for (int i = min_size; i < longest.size(); i++)
+ {
+ u16 pc = i;
+ std::string line;
+ disassembler.DisOpcode(&longest[0], 2, &pc, &line);
+ printf("!! %s\n", line.c_str());
+ }
}
printf("Equal instruction words: %i / %i\n", count_equal, min_size);
return code1.size() == code2.size() && code1.size() == count_equal;
@@ -88,21 +110,25 @@ void GenRandomCode(int size, std::vector<u16> *code) void CodeToHeader(const std::vector<u16> &code, const char *name, std::string *header)
{
+ std::vector<u16> code_copy = code;
+ // Add some nops at the end to align the size a bit.
+ while (code_copy.size() & 7)
+ code_copy.push_back(0);
char buffer[1024];
header->clear();
header->reserve(code.size() * 4);
header->append("#ifndef _MSCVER\n");
- sprintf(buffer, "const __declspec(align:64) unsigned short %s = {\n");
+ sprintf(buffer, "const unsigned short %s = {\n", name);
header->append(buffer);
header->append("#else\n");
- sprintf(buffer, "const unsigned short %s __attribute__(aligned:64) = {\n");
+ sprintf(buffer, "const unsigned short %s __attribute__ ((aligned (64))) = {\n", name);
header->append(buffer);
header->append("#endif\n\n ");
for (int i = 0; i < code.size(); i++)
{
- if (((i + 1) & 15) == 0)
+ if (i && ((i & 15) == 0))
header->append("\n ");
- sprintf(buffer, "%02x, ", code[i]);
+ sprintf(buffer, "0x%04x, ", code[i]);
header->append(buffer);
}
header->append("\n};\n");
|
