mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
DSPTool: make existing tests pass
Disassemble code without the additional text for humans, like the current PC and opcode hex values, so that it can be reassembled. I'm not updating any commented-out tests here.
This commit is contained in:
parent
b9b3b1dc19
commit
1580b6e627
@ -6,6 +6,7 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
#include "Core/DSP/DSPDisassembler.h"
|
||||
#include "Core/DSP/DSPHost.h"
|
||||
#include "Core/DSP/DSPTables.h"
|
||||
|
||||
@ -38,13 +39,27 @@ void DSP::Host::UpdateDebugger()
|
||||
{
|
||||
}
|
||||
|
||||
static bool RoundTrippableDissassemble(const std::vector<u16>& code, std::string& text)
|
||||
{
|
||||
DSP::AssemblerSettings settings;
|
||||
settings.ext_separator = '\'';
|
||||
settings.decode_names = true;
|
||||
settings.decode_registers = true;
|
||||
// These two prevent roundtripping.
|
||||
settings.show_hex = false;
|
||||
settings.show_pc = false;
|
||||
DSP::DSPDisassembler disasm(settings);
|
||||
|
||||
return disasm.Disassemble(0x0000, code, 0x0000, text);
|
||||
}
|
||||
|
||||
// This test goes from text ASM to binary to text ASM and once again back to binary.
|
||||
// Then the two binaries are compared.
|
||||
static bool RoundTrip(const std::vector<u16>& code1)
|
||||
{
|
||||
std::vector<u16> code2;
|
||||
std::string text;
|
||||
if (!DSP::Disassemble(code1, false, text))
|
||||
if (!RoundTrippableDissassemble(code1, text))
|
||||
{
|
||||
printf("RoundTrip: Disassembly failed.\n");
|
||||
return false;
|
||||
@ -74,7 +89,8 @@ static bool SuperTrip(const char* asm_code)
|
||||
return false;
|
||||
}
|
||||
printf("First assembly: %i words\n", (int)code1.size());
|
||||
if (!DSP::Disassemble(code1, false, text))
|
||||
|
||||
if (!RoundTrippableDissassemble(code1, text))
|
||||
{
|
||||
printf("SuperTrip: Disassembly failed\n");
|
||||
return false;
|
||||
@ -84,6 +100,7 @@ static bool SuperTrip(const char* asm_code)
|
||||
printf("Disass:\n");
|
||||
printf("%s", text.c_str());
|
||||
}
|
||||
|
||||
if (!DSP::Assemble(text, code2))
|
||||
{
|
||||
printf("SuperTrip: Second assembly failed\n");
|
||||
|
@ -240,7 +240,7 @@ main:
|
||||
cw 0x8600
|
||||
call send_back
|
||||
|
||||
JNS g_0c4d
|
||||
JGE g_0c4d
|
||||
; cw 0x0290
|
||||
; cw 0x0c4d
|
||||
; call send_back JX0
|
||||
@ -630,7 +630,7 @@ dump_memory:
|
||||
mrr $r02, $r00
|
||||
mrr $r00, $r1f
|
||||
|
||||
addis $acc0, #0x1
|
||||
addis $AC0.M, #0x1
|
||||
|
||||
_fill_loop2:
|
||||
nop
|
||||
|
Loading…
Reference in New Issue
Block a user