Fixed a bug with DIVU.

git-svn-id: http://svn.purei.org/purei/trunk@251 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
jpd002 2008-02-23 17:57:21 +00:00
parent 330b540b6b
commit 122f9da917
3 changed files with 25 additions and 8 deletions

View File

@ -1442,7 +1442,7 @@ void CCodeGen::Cmp64(CONDITION nCondition)
}
}
void CCodeGen::Div_Base(const MultFunction& function)
void CCodeGen::Div_Base(const MultFunction& function, bool isSigned)
{
if(FitsPattern<RelativeConstant>())
{
@ -1458,7 +1458,15 @@ void CCodeGen::Div_Base(const MultFunction& function)
LoadRelativeInRegister(lowRegister, ops.first);
LoadConstantInRegister(tempRegister, ops.second);
m_Assembler.Cdq();
if(isSigned)
{
m_Assembler.Cdq();
}
else
{
m_Assembler.XorEd(m_nRegisterLookupEx[highRegister],
CX86Assembler::MakeRegisterAddress(m_nRegisterLookupEx[highRegister]));
}
function(CX86Assembler::MakeRegisterAddress(m_nRegisterLookupEx[tempRegister]));
FreeRegister(tempRegister);
@ -1478,7 +1486,15 @@ void CCodeGen::Div_Base(const MultFunction& function)
unsigned int highRegister = REGISTER_EDX;
LoadRelativeInRegister(lowRegister, ops.first);
m_Assembler.Cdq();
if(isSigned)
{
m_Assembler.Cdq();
}
else
{
m_Assembler.XorEd(m_nRegisterLookupEx[highRegister],
CX86Assembler::MakeRegisterAddress(m_nRegisterLookupEx[highRegister]));
}
function(CX86Assembler::MakeIndRegOffAddress(g_nBaseRegister, ops.second));
@ -1493,12 +1509,12 @@ void CCodeGen::Div_Base(const MultFunction& function)
void CCodeGen::Div()
{
Div_Base(bind(&CX86Assembler::DivEd, &m_Assembler, _1));
Div_Base(bind(&CX86Assembler::DivEd, &m_Assembler, _1), false);
}
void CCodeGen::DivS()
{
Div_Base(bind(&CX86Assembler::IdivEd, &m_Assembler, _1));
Div_Base(bind(&CX86Assembler::IdivEd, &m_Assembler, _1), true);
}
void CCodeGen::Lookup(uint32* table)

View File

@ -300,7 +300,7 @@ private:
typedef std::tr1::function<void (const CX86Assembler::CAddress&)> MultFunction;
typedef std::tr1::function<void (XMMREGISTER, uint8)> PackedShiftFunction;
void Div_Base(const MultFunction&);
void Div_Base(const MultFunction&, bool);
void Mult_Base(const MultFunction&, bool);
void MD_GenericPackedShift(const PackedShiftFunction&, uint8);

View File

@ -349,8 +349,9 @@ void CPS2OS::LoadELF(CStream& stream, const char* sExecName)
// *(uint32*)&m_ram[0x0029B774] = 0;
//REMOVE
//*reinterpret_cast<uint32*>(&m_ram[m_ee.m_State.nPC + 0x00]) = 0x30C600FF;
//*reinterpret_cast<uint32*>(&m_ram[m_ee.m_State.nPC + 0x04]) = 0x00C03027;
// *reinterpret_cast<uint32*>(&m_ram[m_ee.m_State.nPC + 0x00]) = 0x24030064;
// *reinterpret_cast<uint32*>(&m_ram[m_ee.m_State.nPC + 0x04]) = 0x0043001B;
// *reinterpret_cast<uint32*>(&m_ram[m_ee.m_State.nPC + 0x08]) = 0x0000000C;
//------
ApplyPatches();