almost working !

hang when downcount is under 0
This commit is contained in:
Ced2911 2013-08-10 20:32:57 +02:00
parent b32da03ce0
commit 3a82881bf2
3 changed files with 29 additions and 13 deletions

View File

@ -52,10 +52,10 @@ const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
//Break();
// Cmp ??
//CMPLI(DCNTREG, 0);
//BLT((const void *)outerLoopPCInR0);
CMPLI(DCNTREG, 0);
BLT((const void *)outerLoopPCInR0);
// if (currentMIPS->downcount<0)
BGT((const void *)outerLoopPCInR0);
//BGT((const void *)outerLoopPCInR0);
b->normalEntry = GetCodePtr();
// TODO: this needs work
@ -163,11 +163,14 @@ void Jit::GenerateFixedCode() {
// allocate stack
STWU(R1, R1, -stackFrameSize);
#endif
#if 1
// Map fixed register
MOVI2R(BASEREG, (u32)Memory::base);
MOVI2R(CTXREG, (u32)mips_);
MOVI2R(CODEREG, (u32)GetBasePtr());
Break();
// Update downcount reg value from memory
RestoreDowncount(DCNTREG);
@ -300,15 +303,28 @@ void Jit::GenerateFixedCode() {
// label bailCoreState:
SetJumpTarget(bailCoreState);
#if 0
// Compare coreState and CORE_RUNNING
MOVI2R(SREG, (u32)&coreState);
LWZ(SREG, SREG); // SREG = *SREG => SREG = coreState
CMPLI(SREG, 0); // compare 0(CORE_RUNNING) and corestate
// if (coreState == CORE_RUNNING) check for downcount
FixupBranch badcpustates = BNE();
//BEQ(outerLoop);
CMPLI(DCNTREG, 0);
BLT(outerLoop);
SetJumpTarget(badcpustates);
#else
// Compare coreState and CORE_RUNNING
MOVI2R(SREG, (u32)&coreState);
LWZ(SREG, SREG); // SREG = *SREG => SREG = coreState
CMPLI(SREG, 0); // compare 0(CORE_RUNNING) and corestate
// branch to outerLoop if (coreState == CORE_RUNNING)
// arm: B_CC(CC_EQ, outerLoop);
//Break();
BEQ(outerLoop);
#endif
// }
// badCoreState label:
@ -320,6 +336,8 @@ void Jit::GenerateFixedCode() {
// mips->downcount = DCNTREG
SaveDowncount(DCNTREG);
#endif
#if 1
// Write Epilogue (restore stack frame, return)
// free stack
@ -335,8 +353,10 @@ void Jit::GenerateFixedCode() {
// Restore Lr
MTLR(R12);
Break();
//BLR();
// Go back to caller
BLR();
#endif
// Don't forget to zap the instruction cache!

View File

@ -97,13 +97,13 @@ void Jit::WriteDownCount(int offset)
if (jo.downcountInRegister) {
// DCNTREG = DCNTREG - theDowncount;
MOVI2R(SREG, theDowncount);
SUBF(DCNTREG, SREG, DCNTREG);
SUBF(DCNTREG, SREG, DCNTREG, 1);
STW(DCNTREG, CTXREG, offsetof(MIPSState, downcount));
} else {
// DCNTREG = MIPSState->downcount - theDowncount;
MOVI2R(SREG, theDowncount);
LWZ(DCNTREG, CTXREG, offsetof(MIPSState, downcount));
SUBF(DCNTREG, SREG, DCNTREG);
SUBF(DCNTREG, SREG, DCNTREG, 1);
STW(DCNTREG, CTXREG, offsetof(MIPSState, downcount));
}
}

View File

@ -124,7 +124,6 @@ void Clear()
u32 Read_Instruction(u32 address)
{
#ifndef NO_JIT
u32 inst = Read_U32(address);
if (MIPS_IS_EMUHACK(inst) && MIPSComp::jit)
{
@ -138,9 +137,6 @@ u32 Read_Instruction(u32 address)
} else {
return inst;
}
#else
return Read_U32(address);
#endif
}
u32 Read_Opcode_JIT(u32 address)