Removed a stray MOV in increase_addr_reg, fixed decrease_addr_reg. NR should work now.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5329 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
j4ck.fr0st 2010-04-11 14:06:46 +00:00
parent 800595980e
commit 945f8089b8
4 changed files with 41 additions and 33 deletions

View File

@ -63,7 +63,7 @@ void DSPEmitter::increment_addr_reg(int reg)
// if ((tmp & tmb) == tmb) // if ((tmp & tmb) == tmb)
AND(16, R(ECX), R(EAX)); AND(16, R(ECX), R(EAX));
CMP(16, R(EAX), R(ECX)); CMP(16, R(EAX), R(ECX));
FixupBranch not_equal = J_CC(CC_NZ); FixupBranch not_equal = J_CC(CC_NE);
// tmp ^= g_dsp.r[DSP_REG_WR0 + reg]; // tmp ^= g_dsp.r[DSP_REG_WR0 + reg];
MOVZX(32, 16, ECX, M(&g_dsp.r[reg])); MOVZX(32, 16, ECX, M(&g_dsp.r[reg]));
@ -155,8 +155,6 @@ void DSPEmitter::increase_addr_reg(int reg)
SetJumpTarget(posValue); SetJumpTarget(posValue);
SetJumpTarget(end); SetJumpTarget(end);
MOV(16, M(&g_dsp.r[reg]), R(EDX));
} }
// Decrease addr register according to the correspond ix register // Decrease addr register according to the correspond ix register
@ -164,38 +162,35 @@ void DSPEmitter::decrease_addr_reg(int reg)
{ {
// s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg]; // s16 value = (s16)g_dsp.r[DSP_REG_IX0 + reg];
MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg])); MOVSX(32, 16, EDX, M(&g_dsp.r[DSP_REG_IX0 + reg]));
XOR(32, R(ESI), R(ESI)); // i = 0
// if (value > 0) // if (value > 0)
CMP(16, R(EDX), Imm16(0)); CMP(32, R(EDX), Imm32(0));
FixupBranch end = J_CC(CC_Z); FixupBranch end = J_CC(CC_Z, true);
FixupBranch negValue = J_CC(CC_L); FixupBranch negValue = J_CC(CC_L);
// for (int i = 0; i < value; i++) // for (int i = 0; i < value; i++)
XOR(32, R(ESI), R(ESI)); // i = 0 JumpTarget loop_pos = GetCodePtr();
FixupBranch posloop;
SetJumpTarget(posloop);
decrement_addr_reg(reg); decrement_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ ADD(32, R(ESI), Imm32(1)); // i++
CMP(32, R(ESI), R(EDX)); // i < value CMP(32, R(ESI), R(EDX)); // i < value
J_CC(CC_NE, loop_pos);
FixupBranch posValue = J(); FixupBranch posValue = J();
// FIXME: get normal abs with cdq
IMUL(32, EDX, Imm16(-1)); SetJumpTarget(negValue);
//abs == cdq; xor eax, edx; sub eax, edx
//we know its negative, and in that case edx is -1
XOR(32, R(EDX), Imm32(-1));
SUB(32, R(EDX), Imm32(-1));
// for (int i = 0; i < (int)(-value); i++) // for (int i = 0; i < (int)(-value); i++)
XOR(32, R(ESI), R(ESI)); // i = 0 JumpTarget loop_neg = GetCodePtr();
FixupBranch negloop;
SetJumpTarget(negloop);
increment_addr_reg(reg); increment_addr_reg(reg);
ADD(32, R(ESI), Imm32(1)); // i++ ADD(32, R(ESI), Imm32(1)); // i++
CMP(32, R(ESI), R(EDX)); // i < -value CMP(32, R(ESI), R(EDX)); // i < -value
J_CC(CC_NE, loop_neg);
negloop = J_CC(CC_L);
SetJumpTarget(posValue); SetJumpTarget(posValue);
SetJumpTarget(end); SetJumpTarget(end);
@ -203,7 +198,6 @@ void DSPEmitter::decrease_addr_reg(int reg)
void DSPEmitter::ext_dmem_write(u32 dest, u32 src) void DSPEmitter::ext_dmem_write(u32 dest, u32 src)
{ {
// u16 addr = g_dsp.r[dest]; // u16 addr = g_dsp.r[dest];
MOVZX(32, 16, EAX, M(&g_dsp.r[dest])); MOVZX(32, 16, EAX, M(&g_dsp.r[dest]));

View File

@ -47,7 +47,7 @@ void nx_ir()
void nx_nr() void nx_nr()
{ {
SDSP test_dsp; SDSP test_dsp;
DSPJitTester tester(0x40, 0x0c, true); DSPJitTester tester(0x40, 0x0c);
for (u16 input_reg = 0; input_reg < 10; input_reg++) for (u16 input_reg = 0; input_reg < 10; input_reg++)
for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++) for (u16 input_wr0 = 0; input_wr0 < 10; input_wr0++)
@ -74,7 +74,7 @@ void AudioJitTests()
nx_ir(); nx_ir();
nx_dr(); nx_dr();
//nx_nr(); nx_nr();
} }
//required to be able to link against DSPCore //required to be able to link against DSPCore

View File

@ -1,5 +1,15 @@
#include "DSPJitTester.h" #include "DSPJitTester.h"
DSPJitTester::DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose)
: be_verbose(verbose), run_count(0), fail_count(0)
{
instruction = opcode << 9 | opcode_ext;
opcode_template = GetOpTemplate(instruction);
sprintf(instruction_name, "%s", opcode_template->name);
if (opcode_template->extended)
sprintf(&instruction_name[strlen(instruction_name)], "'%s",
extOpTable[instruction & (((instruction >> 12) == 0x3) ? 0x7F : 0xFF)]->name);
}
bool DSPJitTester::Test(SDSP dsp_settings) bool DSPJitTester::Test(SDSP dsp_settings)
{ {
if (be_verbose) if (be_verbose)
@ -64,6 +74,18 @@ void DSPJitTester::Report()
{ {
printf("%s (0x%04x): Ran %d times, Failed %d times.\n", instruction_name, instruction, run_count, fail_count); printf("%s (0x%04x): Ran %d times, Failed %d times.\n", instruction_name, instruction, run_count, fail_count);
} }
void DSPJitTester::DumpJittedCode()
{
ResetJit();
const u8* code = jit.GetCodePtr();
jit.WriteCallInterpreter(instruction);
int code_size = jit.GetCodePtr() - code;
printf("%s emitted: ", instruction_name);
for (int i = 0; i < code_size; i++)
printf("%02x ", code[i]);
printf("\n");
}
void DSPJitTester::Initialize() void DSPJitTester::Initialize()
{ {
//init int //init int

View File

@ -21,16 +21,7 @@ class DSPJitTester
bool AreEqual(SDSP&, SDSP&); bool AreEqual(SDSP&, SDSP&);
public: public:
DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose = false) DSPJitTester(u16 opcode, u16 opcode_ext, bool verbose = false);
: be_verbose(verbose), run_count(0), fail_count(0)
{
instruction = opcode << 9 | opcode_ext;
opcode_template = GetOpTemplate(instruction);
sprintf(instruction_name, "%s", opcode_template->name);
if (opcode_template->extended)
sprintf(&instruction_name[strlen(instruction_name)], "'%s",
extOpTable[instruction & (((instruction >> 12) == 0x3) ? 0x7F : 0xFF)]->name);
}
bool Test(SDSP); bool Test(SDSP);
SDSP RunInterpreter(SDSP); SDSP RunInterpreter(SDSP);
SDSP RunJit(SDSP); SDSP RunJit(SDSP);
@ -42,6 +33,7 @@ public:
inline int GetFailCount() { return fail_count; } inline int GetFailCount() { return fail_count; }
inline const char* GetInstructionName() { return instruction_name; } inline const char* GetInstructionName() { return instruction_name; }
void Report(); void Report();
void DumpJittedCode();
static void Initialize(); static void Initialize();
}; };