diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index f0444f5dd..73c5e113a 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -1462,14 +1462,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) { CompConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); JeLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; MoveConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); BeforeCallDirect(m_RegWorkingSet); Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); AfterCallDirect(m_RegWorkingSet); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } break; case 0x04400004: MoveConstToVariable((Value & 0xFFFFFF), &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); break; @@ -1478,14 +1478,14 @@ void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) { CompConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); JeLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; MoveConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); BeforeCallDirect(m_RegWorkingSet); Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); AfterCallDirect(m_RegWorkingSet); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } break; case 0x0440000C: MoveConstToVariable(Value, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; @@ -1821,14 +1821,14 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) { CompX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); JeLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; MoveX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); BeforeCallDirect(m_RegWorkingSet); Call_Direct((void *)g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); AfterCallDirect(m_RegWorkingSet); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } break; case 0x04400004: @@ -1840,14 +1840,14 @@ void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) { CompX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); JeLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; MoveX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); BeforeCallDirect(m_RegWorkingSet); Call_Direct((void *)g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); AfterCallDirect(m_RegWorkingSet); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } break; case 0x0440000C: MoveX86regToVariable(Reg, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; @@ -3701,7 +3701,7 @@ void CMipsMemoryVM::Compile_SW(bool bCheckLLbit) { CompConstToVariable(1, _LLBit, "_LLBit"); JneLabel8("LLBit_Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } if (IsConst(Opcode.rt)) { @@ -3719,7 +3719,7 @@ void CMipsMemoryVM::Compile_SW(bool bCheckLLbit) { CPU_Message(" "); CPU_Message(" LLBit_Continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); Map_GPR_32bit(Opcode.rt, false, -1); MoveVariableToX86reg(_LLBit, "_LLBit", GetMipsRegMapLo(Opcode.rt)); } @@ -4056,18 +4056,18 @@ void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); AfterCallDirect(m_RegWorkingSet); /*JmpLabel8("MemCheckDone",0); - uint8_t * MemCheckDone = m_RecompPos - 1; + uint8_t * MemCheckDone = *g_RecompPos - 1; CPU_Message(" "); CPU_Message(" NotDelaySlot:"); - SetJump8(NotDelaySlotJump,m_RecompPos); + SetJump8(NotDelaySlotJump,*g_RecompPos); MoveX86RegToX86Reg(AddressReg, StoreTemp1); ShiftRightUnsignImmed(StoreTemp1,12); LeaRegReg(StoreTemp1,StoreTemp1,(uint32_t)&(g_Recompiler->FunctionTable()[0]),Multip_x4); CompConstToX86regPointer(StoreTemp1,0); JeLabel8("MemCheckDone",0); - uint8_t * MemCheckDone2 = m_RecompPos - 1; + uint8_t * MemCheckDone2 = *g_RecompPos - 1; BeforeCallDirect(m_RegWorkingSet); PushImm32("CRecompiler::Remove_StoreInstruc",CRecompiler::Remove_StoreInstruc); @@ -4079,8 +4079,8 @@ void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length CPU_Message(" "); CPU_Message(" MemCheckDone:"); - SetJump8(MemCheckDone,m_RecompPos); - SetJump8(MemCheckDone2,m_RecompPos); + SetJump8(MemCheckDone,*g_RecompPos); + SetJump8(MemCheckDone2,*g_RecompPos); X86Protected(StoreTemp1) = false;*/ } diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 1806a023b..be432178c 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -683,6 +683,7 @@ bool CN64System::SetActiveSystem(bool bActive) g_Plugins = m_Plugins; g_TLBLoadAddress = &m_TLBLoadAddress; g_TLBStoreAddress = &m_TLBStoreAddress; + g_RecompPos = m_Recomp ? m_Recomp->RecompPos() : NULL; R4300iOp::m_TestTimer = m_TestTimer; R4300iOp::m_NextInstruction = m_NextInstruction; R4300iOp::m_JumpToLocation = m_JumpToLocation; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index 0e660e964..a7691cbfa 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -33,6 +33,7 @@ CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation) : { g_Notify->BreakPoint(__FILE__, __LINE__); } + m_Sections.push_back(baseSection); baseSection->AddParent(NULL); baseSection->m_CompiledLocation = (uint8_t *)-1; @@ -714,17 +715,7 @@ bool CCodeBlock::Compile() CPU_Message("No of Sections: %d",NoOfSections() ); CPU_Message("====== recompiled code ======"); - EnterCodeBlock(); - - if (g_SyncSystem) - { - //if ((uint32_t)BlockInfo.CompiledLocation == 0x60A7B73B) - //{ - // X86BreakPoint(__FILEW__,__LINE__); - //} - //MoveConstToVariable((uint32_t)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); - } - + m_EnterSection->EnterCodeBlock(); if (g_System->bLinkBlocks()) { while (m_EnterSection->GenerateNativeCode(NextTest())); @@ -736,7 +727,7 @@ bool CCodeBlock::Compile() return false; } } - CompileExitCode(); + m_EnterSection->CompileExitCode(); uint32_t PAddr; g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr); @@ -745,18 +736,6 @@ bool CCodeBlock::Compile() return true; } -void CCodeBlock::CompileExitCode() -{ - for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++) - { - CPU_Message(""); - CPU_Message(" $Exit_%d",ExitIter->ID); - SetJump32(ExitIter->JumpLoc,(uint32_t *)m_RecompPos); - m_NextInstruction = ExitIter->NextInstruction; - m_EnterSection->CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL); - } -} - uint32_t CCodeBlock::NextTest() { uint32_t next_test = m_Test; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.h b/Source/Project64-core/N64System/Recompiler/CodeBlock.h index 8e86310a5..e651e6c52 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.h +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.h @@ -11,14 +11,12 @@ #pragma once #include #include -#include #include -class CCodeBlock : - private CRecompilerOps +class CCodeBlock { public: - CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos ); + CCodeBlock(uint32_t VAddrEnter, uint8_t * CompiledLocation ); ~CCodeBlock(); bool Compile(); @@ -27,10 +25,10 @@ public: uint32_t VAddrFirst() const { return m_VAddrFirst; } uint32_t VAddrLast() const { return m_VAddrLast; } uint8_t * CompiledLocation() const { return m_CompiledLocation; } - int32_t NoOfSections() const { return m_Sections.size(); } + int32_t NoOfSections() const { return m_Sections.size() - 1;} const CCodeSection & EnterSection() const { return *m_EnterSection; } const MD5Digest & Hash() const { return m_Hash; } - + CRecompilerOps * RecompilerOps() { return m_EnterSection; } void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; } void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; } @@ -42,15 +40,12 @@ public: uint32_t NextTest(); - EXIT_LIST m_ExitInfo; - private: CCodeBlock(); // Disable default constructor CCodeBlock(const CCodeBlock&); // Disable copy constructor CCodeBlock& operator=(const CCodeBlock&); // Disable assignment bool AnalyseBlock(); - void CompileExitCode(); bool CreateBlockLinkage ( CCodeSection * EnterSection ); void DetermineLoops (); @@ -67,11 +62,11 @@ private: typedef std::map SectionMap; typedef std::list SectionList; - SectionMap m_SectionMap; - SectionList m_Sections; - CCodeSection * m_EnterSection; - int32_t m_Test; - MD5Digest m_Hash; - uint64_t m_MemContents[2]; - uint64_t * m_MemLocation[2]; + SectionMap m_SectionMap; + SectionList m_Sections; + CCodeSection * m_EnterSection; + int32_t m_Test; + MD5Digest m_Hash; + uint64_t m_MemContents[2]; + uint64_t * m_MemLocation[2]; }; diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp index 8c2a8d7d1..6cb73d96b 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp @@ -131,259 +131,6 @@ CCodeSection::~CCodeSection() { } -void CCodeSection::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)) -{ - if (!CompileNow) - { - char String[100]; - sprintf(String, "Exit_%d", m_BlockInfo->m_ExitInfo.size()); - if (x86Jmp == NULL) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - return; - } - x86Jmp(String, 0); - - CExitInfo ExitInfo; - ExitInfo.ID = m_BlockInfo->m_ExitInfo.size(); - ExitInfo.TargetPC = TargetPC; - ExitInfo.ExitRegSet = ExitRegSet; - ExitInfo.reason = reason; - ExitInfo.NextInstruction = m_NextInstruction; - ExitInfo.JumpLoc = (uint32_t *)(m_RecompPos - 4); - m_BlockInfo->m_ExitInfo.push_back(ExitInfo); - return; - } - - //CPU_Message("CompileExit: %d",reason); - ExitRegSet.WriteBackRegisters(); - - if (TargetPC != (uint32_t)-1) - { - MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - UpdateCounters(ExitRegSet, TargetPC <= JumpPC && JumpPC != -1, reason == CExitInfo::Normal); - } - else - { - UpdateCounters(ExitRegSet, false, reason == CExitInfo::Normal); - } - - switch (reason) - { - case CExitInfo::Normal: case CExitInfo::Normal_NoSysCheck: - ExitRegSet.SetBlockCycleCount(0); - if (TargetPC != (uint32_t)-1) - { - if (TargetPC <= JumpPC && reason == CExitInfo::Normal) - { - CPU_Message("CompileSystemCheck 1"); - CompileSystemCheck((uint32_t)-1, ExitRegSet); - } - } - else - { - if (reason == CExitInfo::Normal) - { - CPU_Message("CompileSystemCheck 2"); - CompileSystemCheck((uint32_t)-1, ExitRegSet); - } - } - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } -#ifdef LinkBlocks - if (bSMM_ValidFunc == false) - { - if (LookUpMode() == FuncFind_ChangeMemory) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - // uint8_t * Jump, * Jump2; - // if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) { - // uint32_t pAddr = TargetPC & 0x1FFFFFFF; - // - // MoveVariableToX86reg((uint8_t *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX); - // Jump2 = NULL; - // } else { - // MoveConstToX86reg((TargetPC >> 12),x86_ECX); - // MoveConstToX86reg(TargetPC,x86_EBX); - // MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); - // TestX86RegToX86Reg(x86_ECX,x86_ECX); - // JeLabel8("NoTlbEntry",0); - // Jump2 = m_RecompPos - 1; - // MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_EAX); - // } - // MoveX86RegToX86Reg(x86_EAX,x86_ECX); - // AndConstToX86Reg(x86_ECX,0xFFFF0000); - // CompConstToX86reg(x86_ECX,0x7C7C0000); - // JneLabel8("NoCode",0); - // Jump = m_RecompPos - 1; - // AndConstToX86Reg(x86_EAX,0xFFFF); - // ShiftLeftSignImmed(x86_EAX,4); - // AddConstToX86Reg(x86_EAX,0xC); - // MoveVariableDispToX86Reg(OrigMem,"OrigMem",x86_ECX,x86_EAX,1); - // JmpDirectReg(x86_ECX); - // CPU_Message(" NoCode:"); - // *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); - // if (Jump2 != NULL) { - // CPU_Message(" NoTlbEntry:"); - // *((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1); - // } - } - else if (LookUpMode() == FuncFind_VirtualLookup) - { - MoveConstToX86reg(TargetPC,x86_EDX); - MoveConstToX86reg((uint32_t)&m_Functions,x86_ECX); - Call_Direct(AddressOf(&CFunctionMap::CompilerFindFunction), "CFunctionMap::CompilerFindFunction"); - MoveX86RegToX86Reg(x86_EAX,x86_ECX); - JecxzLabel8("NullPointer",0); - uint8_t * Jump = m_RecompPos - 1; - MoveX86PointerToX86regDisp(x86_EBX,x86_ECX,0xC); - JmpDirectReg(x86_EBX); - CPU_Message(" NullPointer:"); - *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); - } - else if (LookUpMode() == FuncFind_PhysicalLookup) - { - uint8_t * Jump2 = NULL; - if (TargetPC >= 0x80000000 && TargetPC < 0x90000000) - { - uint32_t pAddr = TargetPC & 0x1FFFFFFF; - MoveVariableToX86reg((uint8_t *)JumpTable + pAddr,"JumpTable + pAddr",x86_ECX); - } - else if (TargetPC >= 0x90000000 && TargetPC < 0xC0000000) - { - } - else - { - MoveConstToX86reg((TargetPC >> 12),x86_ECX); - MoveConstToX86reg(TargetPC,x86_EBX); - MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); - TestX86RegToX86Reg(x86_ECX,x86_ECX); - JeLabel8("NoTlbEntry",0); - Jump2 = m_RecompPos - 1; - AddConstToX86Reg(x86_ECX,(uint32_t)JumpTable - (uint32_t)RDRAM); - MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_ECX); - } - if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000) - { - JecxzLabel8("NullPointer",0); - uint8_t * Jump = m_RecompPos - 1; - MoveX86PointerToX86regDisp(x86_EAX,x86_ECX,0xC); - JmpDirectReg(x86_EAX); - CPU_Message(" NullPointer:"); - *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); - if (Jump2 != NULL) - { - CPU_Message(" NoTlbEntry:"); - *((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1); - } - } - } - } - ExitCodeBlock(); -#else - ExitCodeBlock(); -#endif - break; - case CExitInfo::DoCPU_Action: - MoveConstToX86reg((uint32_t)g_SystemEvents, x86_ECX); - Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents"); - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - //g_System->SyncCPU(g_SyncSystem); - ExitCodeBlock(); - break; - case CExitInfo::DoSysCall: - { - bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; - PushImm32(bDelay ? "true" : "false", bDelay); - MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); - } - break; - case CExitInfo::COP1_Unuseable: - { - bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; - PushImm32("1", 1); - PushImm32(bDelay ? "true" : "false", bDelay); - MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); - } - break; - case CExitInfo::ExitResetRecompCode: - g_Notify->BreakPoint(__FILE__, __LINE__); -#ifdef legacycode - if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT) - { - X86BreakPoint(__FILEW__,__LINE__); - } - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - X86BreakPoint(__FILEW__,__LINE__); - MoveVariableToX86reg(this,"this",x86_ECX); - Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode"); -#endif - ExitCodeBlock(); - break; - case CExitInfo::TLBReadMiss: - MoveVariableToX86reg(g_TLBLoadAddress, "g_TLBLoadAddress", x86_EDX); - Push(x86_EDX); - PushImm32(m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT); - MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss"); - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); - break; - case CExitInfo::TLBWriteMiss: - X86BreakPoint(__FILE__, __LINE__); - ExitCodeBlock(); - break; - case CExitInfo::DivByZero: - AddConstToVariable(4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - if (!g_System->b32BitCore()) - { - MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); - MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); - } - MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); - MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); - if (g_SyncSystem) - { - MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); - break; - default: - WriteTrace(TraceRecompiler, TraceError, "how did you want to exit on reason (%d) ???", reason); - g_Notify->BreakPoint(__FILE__, __LINE__); - } -} - void CCodeSection::GenerateSectionLinkage() { CCodeSection * TargetSection[] = { m_ContinueSection, m_JumpSection }; @@ -411,18 +158,18 @@ void CCodeSection::GenerateSectionLinkage() JumpInfo[i]->FallThrough = false; if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC); if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; } JmpLabel8("FinishBlock",0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } for (i = 0; i < 2; i ++) { @@ -430,23 +177,23 @@ void CCodeSection::GenerateSectionLinkage() JumpInfo[i]->FallThrough = false; if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC); if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; } JmpLabel8("FinishBlock",0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } if (Jump != NULL) { CPU_Message(" $FinishBlock:"); - SetJump8(Jump,m_RecompPos); + SetJump8(Jump,*g_RecompPos); } //MoveConstToVariable(CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_RegWorkingSet.WriteBackRegisters(); @@ -500,11 +247,11 @@ void CCodeSection::GenerateSectionLinkage() { if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -517,11 +264,11 @@ void CCodeSection::GenerateSectionLinkage() if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; } if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -554,11 +301,11 @@ void CCodeSection::GenerateSectionLinkage() JumpInfo[i]->FallThrough = false; if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -598,7 +345,7 @@ void CCodeSection::GenerateSectionLinkage() m_RegWorkingSet = JumpInfo[i]->RegSet; SyncRegState(TargetSection[i]->m_RegEnter); JmpLabel32(Label, 0); - SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); + SetJump32((uint32_t *)*g_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } @@ -626,7 +373,7 @@ void CCodeSection::GenerateSectionLinkage() { JumpInfo[i]->FallThrough = false; JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); - JumpInfo[i]->LinkLocation = (uint32_t*)(m_RecompPos - 4); + JumpInfo[i]->LinkLocation = (uint32_t*)(*g_RecompPos - 4); } } } @@ -652,7 +399,7 @@ void CCodeSection::GenerateSectionLinkage() { JumpInfo[i]->FallThrough = false; JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); - JumpInfo[i]->LinkLocation = (uint32_t *)(m_RecompPos - 4); + JumpInfo[i]->LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -663,11 +410,11 @@ void CCodeSection::GenerateSectionLinkage() if (TargetSection[i] == NULL) { CPU_Message("ExitBlock (from %d):", m_SectionID); - SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL); @@ -686,11 +433,11 @@ void CCodeSection::GenerateSectionLinkage() stdstr_f Label("Section_%d (from %d):", TargetSection[i]->m_SectionID, m_SectionID); CPU_Message(Label.c_str()); - SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } m_RegWorkingSet = JumpInfo[i]->RegSet; @@ -718,7 +465,7 @@ void CCodeSection::GenerateSectionLinkage() m_RegWorkingSet = JumpInfo[i]->RegSet; SyncRegState(TargetSection[i]->m_RegEnter); JmpLabel32(Label.c_str(), 0); - SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); + SetJump32((uint32_t *)*g_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } } @@ -1021,7 +768,7 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) { return false; } - m_CompiledLocation = m_RecompPos; + m_CompiledLocation = *g_RecompPos; m_RegWorkingSet = m_RegEnter; m_CompilePC = m_EnterPC; m_NextInstruction = m_DelaySlot ? JUMP : NORMAL; @@ -1778,7 +1525,7 @@ bool CCodeSection::InheritParentInfo() { if (m_CompiledLocation == NULL) { - m_CompiledLocation = m_RecompPos; + m_CompiledLocation = *g_RecompPos; DisplaySectionInformation(); m_CompiledLocation = NULL; } @@ -1806,10 +1553,10 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d:", m_SectionID); - SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos); } } m_RegWorkingSet = m_RegEnter; @@ -1899,11 +1646,11 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); - SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -2157,7 +1904,7 @@ bool CCodeSection::InheritParentInfo() Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; JmpLabel32(Label.c_str(), 0); - JumpInfo->LinkLocation = (uint32_t *)(m_RecompPos - 4); + JumpInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); JumpInfo->LinkLocation2 = NULL; CurrentParent = i; @@ -2166,11 +1913,11 @@ bool CCodeSection::InheritParentInfo() CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); if (JumpInfo->LinkLocation != NULL) { - SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -2200,11 +1947,11 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { - SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation2 = NULL; } } diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.h b/Source/Project64-core/N64System/Recompiler/CodeSection.h index 089784305..07a92d831 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.h +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.h @@ -15,7 +15,7 @@ class CCodeBlock; class CCodeSection : - private CRecompilerOps + public CRecompilerOps { public: typedef std::list SECTION_LIST; @@ -29,7 +29,6 @@ public: void CompileCop1Test(); bool GenerateNativeCode(uint32_t Test); void GenerateSectionLinkage(); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)); void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID); bool FixConstants(uint32_t Test); CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test); diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp index 9e3d276de..37f54c463 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp @@ -937,7 +937,7 @@ CCompiledFunc * CRecompiler::CompilerCode() //uint32_t StartTime = timeGetTime(); WriteTrace(TraceRecompiler, TraceDebug, ": Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr); - CCodeBlock CodeBlock(PROGRAM_COUNTER, RecompPos()); + CCodeBlock CodeBlock(PROGRAM_COUNTER, *g_RecompPos); if (!CodeBlock.Compile()) { return NULL; diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerClass.h b/Source/Project64-core/N64System/Recompiler/RecompilerClass.h index 09fcd2f13..2a52c6c70 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerClass.h +++ b/Source/Project64-core/N64System/Recompiler/RecompilerClass.h @@ -18,7 +18,7 @@ class CRecompiler : protected CDebugSettings, public CRecompilerSettings, public CFunctionMap, - private CRecompMemory, + public CRecompMemory, private CSystemRegisters { public: diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp index d3eba4479..5d0fa1915 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp @@ -33,7 +33,9 @@ CRecompMemory::~CRecompMemory() bool CRecompMemory::AllocateMemory() { + WriteTrace(TraceRecompiler, TraceDebug, "Start"); uint8_t * RecompCodeBase = (uint8_t *)AllocateAddressSpace(MaxCompileBufferSize + 4); + WriteTrace(TraceRecompiler, TraceDebug, "RecompCodeBase = %X", RecompCodeBase); if (RecompCodeBase == NULL) { WriteTrace(TraceRecompiler, TraceError, "failed to allocate RecompCodeBase"); @@ -52,6 +54,7 @@ bool CRecompMemory::AllocateMemory() m_RecompSize = InitialCompileBufferSize; m_RecompPos = m_RecompCode; memset(m_RecompCode, 0, InitialCompileBufferSize); + WriteTrace(TraceRecompiler, TraceDebug, "Done"); return true; } diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h index 9ee4947aa..44d8d4f2d 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h +++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h @@ -11,8 +11,7 @@ #pragma once #include -class CRecompMemory : - protected CX86Ops +class CRecompMemory { protected: CRecompMemory(); @@ -23,7 +22,8 @@ protected: void Reset(); void ShowMemUsed(); - uint8_t* RecompPos() const { return m_RecompPos; } +public: + uint8_t** RecompPos() { return &m_RecompPos; } private: CRecompMemory(const CRecompMemory&); // Disable copy constructor @@ -31,6 +31,7 @@ private: uint8_t * m_RecompCode; uint32_t m_RecompSize; + uint8_t * m_RecompPos; enum { MaxCompileBufferSize = 0x03C00000 }; enum { InitialCompileBufferSize = 0x00500000 }; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 589df0802..96387e222 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -32,21 +32,21 @@ void CRecompilerOps::CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpRe { MoveConstToVariable(VirtualAddress, g_TLBLoadAddress, "TLBLoadAddress"); TestX86RegToX86Reg(LookUpReg, LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); } void CRecompilerOps::CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg) { MoveX86regToVariable(AddressReg, g_TLBLoadAddress, "TLBLoadAddress"); TestX86RegToX86Reg(LookUpReg, LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); } void CRecompilerOps::CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg) { MoveX86regToVariable(AddressReg, &g_TLBStoreAddress, "g_TLBStoreAddress"); TestX86RegToX86Reg(LookUpReg, LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); } bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); @@ -165,11 +165,11 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { CPU_Message(""); CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } m_Section->m_Jump.FallThrough = true; @@ -178,11 +178,11 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { CPU_Message(""); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } m_Section->m_Cont.FallThrough = true; @@ -212,15 +212,15 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { JmpLabel8("DoDelaySlot", 0); if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILE__, __LINE__); } - DelayLinkLocation = (uint8_t *)(m_RecompPos - 1); + DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1); CPU_Message(" "); CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); - SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); @@ -229,15 +229,15 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { JmpLabel8("DoDelaySlot", 0); if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILE__, __LINE__); } - DelayLinkLocation = (uint8_t *)(m_RecompPos - 1); + DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1); CPU_Message(" "); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); - SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); @@ -246,7 +246,7 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { CPU_Message(""); CPU_Message(" DoDelaySlot:"); - SetJump8(DelayLinkLocation, m_RecompPos); + SetJump8(DelayLinkLocation, *g_RecompPos); } OverflowDelaySlot(false); return; @@ -303,16 +303,16 @@ void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, { FallInfo->FallThrough = false; JmpLabel32(FallInfo->BranchLabel.c_str(), 0); - FallInfo->LinkLocation = (uint32_t *)(m_RecompPos - 4); + FallInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (JumpInfo->LinkLocation != NULL) { CPU_Message(" %s:", JumpInfo->BranchLabel.c_str()); - SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)*g_RecompPos); JumpInfo->LinkLocation2 = NULL; } JumpInfo->FallThrough = true; @@ -443,11 +443,11 @@ void CRecompilerOps::Compile_BranchLikely(BranchFunction CompareFunc, bool Link) { if (m_Section->m_Jump.LinkLocation != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } } @@ -464,15 +464,15 @@ void CRecompilerOps::Compile_BranchLikely(BranchFunction CompareFunc, bool Link) if (m_Section->m_Cont.LinkLocation != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)*g_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } } - m_Section->CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, CExitInfo::Normal, true, NULL); + CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, CExitInfo::Normal, true, NULL); return; } else @@ -549,33 +549,33 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else @@ -584,19 +584,19 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -626,33 +626,33 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else @@ -661,19 +661,19 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -719,12 +719,12 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } if (IsConst(KnownReg)) @@ -740,38 +740,38 @@ void CRecompilerOps::BNE_Compare() JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } } @@ -786,12 +786,12 @@ void CRecompilerOps::BNE_Compare() if (m_Section->m_Jump.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -802,36 +802,36 @@ void CRecompilerOps::BNE_Compare() JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } } @@ -874,33 +874,33 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -909,19 +909,19 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -950,33 +950,33 @@ void CRecompilerOps::BEQ_Compare() } if (m_Section->m_Cont.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -985,19 +985,19 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1043,12 +1043,12 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } if (IsConst(KnownReg)) @@ -1062,12 +1062,12 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Jump.FallThrough) @@ -1075,19 +1075,19 @@ void CRecompilerOps::BEQ_Compare() JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1100,24 +1100,24 @@ void CRecompilerOps::BEQ_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); if (Jump) { CPU_Message(" "); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Jump.FallThrough) @@ -1125,11 +1125,11 @@ void CRecompilerOps::BEQ_Compare() JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1137,14 +1137,14 @@ void CRecompilerOps::BEQ_Compare() JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1186,19 +1186,19 @@ void CRecompilerOps::BGTZ_Compare() if (m_Section->m_Jump.FallThrough) { JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else if (IsUnknown(m_Opcode.rs) && g_System->b32BitCore()) @@ -1207,19 +1207,19 @@ void CRecompilerOps::BGTZ_Compare() if (m_Section->m_Jump.FallThrough) { JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1237,23 +1237,23 @@ void CRecompilerOps::BGTZ_Compare() if (m_Section->m_Jump.FallThrough) { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JgLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else if (m_Section->m_Cont.FallThrough) { JlLabel8("continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } if (IsMapped(m_Opcode.rs)) @@ -1267,23 +1267,23 @@ void CRecompilerOps::BGTZ_Compare() if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1340,19 +1340,19 @@ void CRecompilerOps::BLEZ_Compare() if (m_Section->m_Jump.FallThrough) { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JleLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1370,23 +1370,23 @@ void CRecompilerOps::BLEZ_Compare() if (m_Section->m_Jump.FallThrough) { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JlLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else if (m_Section->m_Cont.FallThrough) { JgLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } if (IsMapped(m_Opcode.rs)) @@ -1400,23 +1400,23 @@ void CRecompilerOps::BLEZ_Compare() if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); JmpLabel32("BranchToJump", 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1429,23 +1429,23 @@ void CRecompilerOps::BLEZ_Compare() if (m_Section->m_Jump.FallThrough) { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JlLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; } else if (m_Section->m_Cont.FallThrough) { JgLabel8("Continue", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); if (m_Section->m_Jump.FallThrough) @@ -1453,34 +1453,34 @@ void CRecompilerOps::BLEZ_Compare() JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); if (g_System->b32BitCore()) { - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } if (Jump) { CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); if (Jump) { CPU_Message(" continue:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); JmpLabel32("BranchToJump", 0); - m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1489,19 +1489,19 @@ void CRecompilerOps::BLEZ_Compare() if (m_Section->m_Jump.FallThrough) { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JleLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1551,19 +1551,19 @@ void CRecompilerOps::BLTZ_Compare() if (m_Section->m_Jump.FallThrough) { JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else if (IsSigned(m_Opcode.rs)) @@ -1572,19 +1572,19 @@ void CRecompilerOps::BLTZ_Compare() if (m_Section->m_Jump.FallThrough) { JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1606,19 +1606,19 @@ void CRecompilerOps::BLTZ_Compare() if (m_Section->m_Jump.FallThrough) { JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Cont.FallThrough) { JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1659,19 +1659,19 @@ void CRecompilerOps::BGEZ_Compare() if (m_Section->m_Cont.FallThrough) { JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else if (IsSigned(m_Opcode.rs)) @@ -1680,19 +1680,19 @@ void CRecompilerOps::BGEZ_Compare() if (m_Section->m_Cont.FallThrough) { JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } else @@ -1714,19 +1714,19 @@ void CRecompilerOps::BGEZ_Compare() if (m_Section->m_Cont.FallThrough) { JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } } @@ -1737,19 +1737,19 @@ void CRecompilerOps::COP1_BCF_Compare() if (m_Section->m_Cont.FallThrough) { JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1759,19 +1759,19 @@ void CRecompilerOps::COP1_BCT_Compare() if (m_Section->m_Cont.FallThrough) { JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else if (m_Section->m_Jump.FallThrough) { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } else { JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); - m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Cont.LinkLocation = (uint32_t *)(*g_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); - m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + m_Section->m_Jump.LinkLocation = (uint32_t *)(*g_RecompPos - 4); } } @@ -1866,7 +1866,7 @@ void CRecompilerOps::JAL() bool bCheck = TargetPC <= m_CompilePC; UpdateCounters(m_RegWorkingSet, bCheck, true); - m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck, true, NULL); + CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck, true, NULL); } m_NextInstruction = END_BLOCK; } @@ -1973,18 +1973,18 @@ void CRecompilerOps::SLTIU() CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), ((int16_t)m_Opcode.immediate >> 31)); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetbVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); SetbVariable(&m_BranchCompare, "m_BranchCompare"); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rt, false, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); } @@ -2009,11 +2009,11 @@ void CRecompilerOps::SLTIU() CompConstToVariable(((int16_t)m_Opcode.immediate >> 31), &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); JneLabel8("CompareSet", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); CPU_Message(""); CPU_Message(" CompareSet:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); SetbVariable(&m_BranchCompare, "m_BranchCompare"); Map_GPR_32bit(m_Opcode.rt, false, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); @@ -2046,18 +2046,18 @@ void CRecompilerOps::SLTI() CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), ((int16_t)m_Opcode.immediate >> 31)); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetlVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); SetbVariable(&m_BranchCompare, "m_BranchCompare"); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rt, false, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); } @@ -2105,20 +2105,20 @@ void CRecompilerOps::SLTI() uint8_t * Jump[2] = { NULL, NULL }; CompConstToVariable(((int16_t)m_Opcode.immediate >> 31), &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetlVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); SetbVariable(&m_BranchCompare, "m_BranchCompare"); if (Jump[1]) { CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } Map_GPR_32bit(m_Opcode.rt, false, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); @@ -2605,7 +2605,7 @@ void CRecompilerOps::SPECIAL_JR() { if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) { - m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); } else { @@ -2622,7 +2622,7 @@ void CRecompilerOps::SPECIAL_JR() { MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); } - m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); if (m_Section->m_JumpSection) { m_Section->GenerateSectionLinkage(); @@ -2688,7 +2688,7 @@ void CRecompilerOps::SPECIAL_JALR() { if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) { - m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); } else { @@ -2705,7 +2705,7 @@ void CRecompilerOps::SPECIAL_JALR() { MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); } - m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); if (m_Section->m_JumpSection) { m_Section->GenerateSectionLinkage(); @@ -2722,7 +2722,7 @@ void CRecompilerOps::SPECIAL_JALR() void CRecompilerOps::SPECIAL_SYSCALL() { CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall, true, NULL); + CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall, true, NULL); m_NextInstruction = END_BLOCK; } @@ -2855,16 +2855,16 @@ void CRecompilerOps::SPECIAL_DSLLV() Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); CompConstToX86reg(x86_ECX, 0x20); JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; ShiftLeftDouble(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; //MORE32: CPU_Message(""); CPU_Message(" MORE32:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); MoveX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); AndConstToX86Reg(x86_ECX, 0x1F); @@ -2873,7 +2873,7 @@ void CRecompilerOps::SPECIAL_DSLLV() //continue: CPU_Message(""); CPU_Message(" continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } void CRecompilerOps::SPECIAL_DSRLV() @@ -2941,16 +2941,16 @@ void CRecompilerOps::SPECIAL_DSRLV() Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); CompConstToX86reg(x86_ECX, 0x20); JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; //MORE32: CPU_Message(""); CPU_Message(" MORE32:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); AndConstToX86Reg(x86_ECX, 0x1F); @@ -2959,7 +2959,7 @@ void CRecompilerOps::SPECIAL_DSRLV() //continue: CPU_Message(""); CPU_Message(" continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } } @@ -2984,16 +2984,16 @@ void CRecompilerOps::SPECIAL_DSRAV() Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); CompConstToX86reg(x86_ECX, 0x20); JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); ShiftRightSign(GetMipsRegMapHi(m_Opcode.rd)); JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; //MORE32: CPU_Message(""); CPU_Message(" MORE32:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); ShiftRightSignImmed(GetMipsRegMapHi(m_Opcode.rd), 0x1F); AndConstToX86Reg(x86_ECX, 0x1F); @@ -3002,7 +3002,7 @@ void CRecompilerOps::SPECIAL_DSRAV() //continue: CPU_Message(""); CPU_Message(" continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } void CRecompilerOps::SPECIAL_MULT() @@ -3068,7 +3068,7 @@ void CRecompilerOps::SPECIAL_DIV() { CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); } - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::DivByZero, false, JeLabel32); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::DivByZero, false, JeLabel32); } /* lo = (SD)rs / (SD)rt; hi = (SD)rs % (SD)rt; */ @@ -3130,7 +3130,7 @@ void CRecompilerOps::SPECIAL_DIVU() CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); } JneLabel8("NoExcept", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); @@ -3138,11 +3138,11 @@ void CRecompilerOps::SPECIAL_DIVU() MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); JmpLabel8("EndDivu", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" NoExcept:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); } /* lo = (UD)rs / (UD)rt; @@ -3171,7 +3171,7 @@ void CRecompilerOps::SPECIAL_DIVU() { CPU_Message(""); CPU_Message(" EndDivu:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } } @@ -4233,19 +4233,19 @@ void CRecompilerOps::SPECIAL_SLT() Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) ); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetlVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); SetbVariable(&m_BranchCompare, "m_BranchCompare"); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); } @@ -4281,7 +4281,7 @@ void CRecompilerOps::SPECIAL_SLT() Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31) ); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; if (MappedReg == m_Opcode.rs) { SetlVariable(&m_BranchCompare, "m_BranchCompare"); @@ -4291,11 +4291,11 @@ void CRecompilerOps::SPECIAL_SLT() SetgVariable(&m_BranchCompare, "m_BranchCompare"); } JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); if (MappedReg == m_Opcode.rs) { @@ -4307,7 +4307,7 @@ void CRecompilerOps::SPECIAL_SLT() } CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); } @@ -4376,7 +4376,7 @@ void CRecompilerOps::SPECIAL_SLT() } } JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) { SetgVariable(&m_BranchCompare, "m_BranchCompare"); @@ -4386,11 +4386,11 @@ void CRecompilerOps::SPECIAL_SLT() SetlVariable(&m_BranchCompare, "m_BranchCompare"); } JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); if (IsConst(KnownReg)) { CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); @@ -4408,7 +4408,7 @@ void CRecompilerOps::SPECIAL_SLT() } CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); } @@ -4479,21 +4479,21 @@ void CRecompilerOps::SPECIAL_SLT() x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetlVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); SetbVariable(&m_BranchCompare, "m_BranchCompare"); if (Jump[1]) { CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); @@ -4549,19 +4549,19 @@ void CRecompilerOps::SPECIAL_SLTU() Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) ); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetbVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); SetbVariable(&m_BranchCompare, "m_BranchCompare"); CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); } @@ -4599,7 +4599,7 @@ void CRecompilerOps::SPECIAL_SLTU() Map_GPR_32bit(m_Opcode.rd, true, -1); CompConstToX86reg(MappedRegHi, ConstHi); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; if (MappedReg == m_Opcode.rs) { SetbVariable(&m_BranchCompare, "m_BranchCompare"); @@ -4609,11 +4609,11 @@ void CRecompilerOps::SPECIAL_SLTU() SetaVariable(&m_BranchCompare, "m_BranchCompare"); } JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompConstToX86reg(MappedRegLo, ConstLo); if (MappedReg == m_Opcode.rs) { @@ -4625,7 +4625,7 @@ void CRecompilerOps::SPECIAL_SLTU() } CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); } @@ -4703,7 +4703,7 @@ void CRecompilerOps::SPECIAL_SLTU() } } JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) { @@ -4714,11 +4714,11 @@ void CRecompilerOps::SPECIAL_SLTU() SetbVariable(&m_BranchCompare, "m_BranchCompare"); } JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); if (IsConst(KnownReg)) { CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); @@ -4739,7 +4739,7 @@ void CRecompilerOps::SPECIAL_SLTU() { CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } } Map_GPR_32bit(m_Opcode.rd, true, -1); @@ -4760,21 +4760,21 @@ void CRecompilerOps::SPECIAL_SLTU() x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); JeLabel8("Low Compare", 0); - Jump[0] = m_RecompPos - 1; + Jump[0] = *g_RecompPos - 1; SetbVariable(&m_BranchCompare, "m_BranchCompare"); JmpLabel8("Continue", 0); - Jump[1] = m_RecompPos - 1; + Jump[1] = *g_RecompPos - 1; CPU_Message(""); CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); + SetJump8(Jump[0], *g_RecompPos); CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); SetbVariable(&m_BranchCompare, "m_BranchCompare"); if (Jump[1]) { CPU_Message(""); CPU_Message(" Continue:"); - SetJump8(Jump[1], m_RecompPos); + SetJump8(Jump[1], *g_RecompPos); } Map_GPR_32bit(m_Opcode.rd, true, -1); MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); @@ -5435,16 +5435,16 @@ void CRecompilerOps::COP0_MT() XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); TestConstToX86Reg(STATUS_FR, OldStatusReg); JeLabel8("FpuFlagFine", 0); - Jump = m_RecompPos - 1; + Jump = *g_RecompPos - 1; BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); Call_Direct(AddressOf(&CRegisters::FixFpuLocations), "CRegisters::FixFpuLocations"); AfterCallDirect(m_RegWorkingSet); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); //TestConstToX86Reg(STATUS_FR,OldStatusReg); - //BreakPoint(__FILEW__,__LINE__); //m_Section->CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,false,JneLabel32); + //BreakPoint(__FILEW__,__LINE__); //CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,false,JneLabel32); BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); @@ -5574,7 +5574,7 @@ void CRecompilerOps::COP0_CO_ERET(void) Call_Direct((void *)compiler_COP0_CO_ERET, "compiler_COP0_CO_ERET"); UpdateCounters(m_RegWorkingSet, true, true); - m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); m_NextInstruction = END_BLOCK; } @@ -6655,6 +6655,17 @@ void CRecompilerOps::ExitCodeBlock() Ret(); } +void CRecompilerOps::CompileExitCode() +{ + for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++) + { + CPU_Message(""); + CPU_Message(" $Exit_%d",ExitIter->ID); + SetJump32(ExitIter->JumpLoc,(uint32_t *)*g_RecompPos); + m_NextInstruction = ExitIter->NextInstruction; + CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL); + } +} void CRecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles) { if (!g_SyncSystem) @@ -6691,7 +6702,7 @@ void CRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool Cle if (CheckTimer) { JnsLabel8("Continue_From_Timer_Test", 0); - uint8_t * Jump = m_RecompPos - 1; + uint8_t * Jump = *g_RecompPos - 1; Pushad(); MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); Call_Direct(AddressOf(&CSystemTimer::TimerDone), "CSystemTimer::TimerDone"); @@ -6699,7 +6710,7 @@ void CRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool Cle CPU_Message(""); CPU_Message(" $Continue_From_Timer_Test:"); - SetJump8(Jump, m_RecompPos); + SetJump8(Jump, *g_RecompPos); } } @@ -6707,7 +6718,7 @@ void CRecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegS { CompConstToVariable(0, (void *)&g_SystemEvents->DoSomething(), "g_SystemEvents->DoSomething()"); JeLabel32("Continue_From_Interrupt_Test", 0); - uint32_t * Jump = (uint32_t *)(m_RecompPos - 4); + uint32_t * Jump = (uint32_t *)(*g_RecompPos - 4); if (TargetPC != (uint32_t)-1) { MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); @@ -6726,7 +6737,7 @@ void CRecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegS ExitCodeBlock(); CPU_Message(""); CPU_Message(" $Continue_From_Interrupt_Test:"); - SetJump32(Jump, (uint32_t *)m_RecompPos); + SetJump32(Jump, (uint32_t *)*g_RecompPos); } void CRecompilerOps::OverflowDelaySlot(bool TestTimer) @@ -6767,4 +6778,257 @@ void CRecompilerOps::OverflowDelaySlot(bool TestTimer) ExitCodeBlock(); m_NextInstruction = END_BLOCK; -} \ No newline at end of file +} + +void CRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)) +{ + if (!CompileNow) + { + char String[100]; + sprintf(String, "Exit_%d", m_ExitInfo.size()); + if (x86Jmp == NULL) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + return; + } + x86Jmp(String, 0); + + CExitInfo ExitInfo; + ExitInfo.ID = m_ExitInfo.size(); + ExitInfo.TargetPC = TargetPC; + ExitInfo.ExitRegSet = ExitRegSet; + ExitInfo.reason = reason; + ExitInfo.NextInstruction = m_NextInstruction; + ExitInfo.JumpLoc = (uint32_t *)(*g_RecompPos - 4); + m_ExitInfo.push_back(ExitInfo); + return; + } + + //CPU_Message("CompileExit: %d",reason); + ExitRegSet.WriteBackRegisters(); + + if (TargetPC != (uint32_t)-1) + { + MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + UpdateCounters(ExitRegSet, TargetPC <= JumpPC && JumpPC != -1, reason == CExitInfo::Normal); + } + else + { + UpdateCounters(ExitRegSet, false, reason == CExitInfo::Normal); + } + + switch (reason) + { + case CExitInfo::Normal: case CExitInfo::Normal_NoSysCheck: + ExitRegSet.SetBlockCycleCount(0); + if (TargetPC != (uint32_t)-1) + { + if (TargetPC <= JumpPC && reason == CExitInfo::Normal) + { + CPU_Message("CompileSystemCheck 1"); + CompileSystemCheck((uint32_t)-1, ExitRegSet); + } + } + else + { + if (reason == CExitInfo::Normal) + { + CPU_Message("CompileSystemCheck 2"); + CompileSystemCheck((uint32_t)-1, ExitRegSet); + } + } + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } +#ifdef LinkBlocks + if (bSMM_ValidFunc == false) + { + if (LookUpMode() == FuncFind_ChangeMemory) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + // uint8_t * Jump, * Jump2; + // if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) { + // uint32_t pAddr = TargetPC & 0x1FFFFFFF; + // + // MoveVariableToX86reg((uint8_t *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX); + // Jump2 = NULL; + // } else { + // MoveConstToX86reg((TargetPC >> 12),x86_ECX); + // MoveConstToX86reg(TargetPC,x86_EBX); + // MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); + // TestX86RegToX86Reg(x86_ECX,x86_ECX); + // JeLabel8("NoTlbEntry",0); + // Jump2 = *g_RecompPos - 1; + // MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_EAX); + // } + // MoveX86RegToX86Reg(x86_EAX,x86_ECX); + // AndConstToX86Reg(x86_ECX,0xFFFF0000); + // CompConstToX86reg(x86_ECX,0x7C7C0000); + // JneLabel8("NoCode",0); + // Jump = *g_RecompPos - 1; + // AndConstToX86Reg(x86_EAX,0xFFFF); + // ShiftLeftSignImmed(x86_EAX,4); + // AddConstToX86Reg(x86_EAX,0xC); + // MoveVariableDispToX86Reg(OrigMem,"OrigMem",x86_ECX,x86_EAX,1); + // JmpDirectReg(x86_ECX); + // CPU_Message(" NoCode:"); + // *((uint8_t *)(Jump))=(uint8_t)(*g_RecompPos - Jump - 1); + // if (Jump2 != NULL) { + // CPU_Message(" NoTlbEntry:"); + // *((uint8_t *)(Jump2))=(uint8_t)(*g_RecompPos - Jump2 - 1); + // } + } + else if (LookUpMode() == FuncFind_VirtualLookup) + { + MoveConstToX86reg(TargetPC, x86_EDX); + MoveConstToX86reg((uint32_t)&m_Functions, x86_ECX); + Call_Direct(AddressOf(&CFunctionMap::CompilerFindFunction), "CFunctionMap::CompilerFindFunction"); + MoveX86RegToX86Reg(x86_EAX, x86_ECX); + JecxzLabel8("NullPointer", 0); + uint8_t * Jump = *g_RecompPos - 1; + MoveX86PointerToX86regDisp(x86_EBX, x86_ECX, 0xC); + JmpDirectReg(x86_EBX); + CPU_Message(" NullPointer:"); + *((uint8_t *)(Jump)) = (uint8_t)(*g_RecompPos - Jump - 1); + } + else if (LookUpMode() == FuncFind_PhysicalLookup) + { + uint8_t * Jump2 = NULL; + if (TargetPC >= 0x80000000 && TargetPC < 0x90000000) + { + uint32_t pAddr = TargetPC & 0x1FFFFFFF; + MoveVariableToX86reg((uint8_t *)JumpTable + pAddr, "JumpTable + pAddr", x86_ECX); + } + else if (TargetPC >= 0x90000000 && TargetPC < 0xC0000000) + { + } + else + { + MoveConstToX86reg((TargetPC >> 12), x86_ECX); + MoveConstToX86reg(TargetPC, x86_EBX); + MoveVariableDispToX86Reg(TLB_ReadMap, "TLB_ReadMap", x86_ECX, x86_ECX, 4); + TestX86RegToX86Reg(x86_ECX, x86_ECX); + JeLabel8("NoTlbEntry", 0); + Jump2 = *g_RecompPos - 1; + AddConstToX86Reg(x86_ECX, (uint32_t)JumpTable - (uint32_t)RDRAM); + MoveX86regPointerToX86reg(x86_ECX, x86_EBX, x86_ECX); + } + if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000) + { + JecxzLabel8("NullPointer", 0); + uint8_t * Jump = *g_RecompPos - 1; + MoveX86PointerToX86regDisp(x86_EAX, x86_ECX, 0xC); + JmpDirectReg(x86_EAX); + CPU_Message(" NullPointer:"); + *((uint8_t *)(Jump)) = (uint8_t)(*g_RecompPos - Jump - 1); + if (Jump2 != NULL) + { + CPU_Message(" NoTlbEntry:"); + *((uint8_t *)(Jump2)) = (uint8_t)(*g_RecompPos - Jump2 - 1); + } + } + } + } + ExitCodeBlock(); +#else + ExitCodeBlock(); +#endif + break; + case CExitInfo::DoCPU_Action: + MoveConstToX86reg((uint32_t)g_SystemEvents, x86_ECX); + Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + //g_System->SyncCPU(g_SyncSystem); + ExitCodeBlock(); + break; + case CExitInfo::DoSysCall: + { + bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; + PushImm32(bDelay ? "true" : "false", bDelay); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + ExitCodeBlock(); + } + break; + case CExitInfo::COP1_Unuseable: + { + bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; + PushImm32("1", 1); + PushImm32(bDelay ? "true" : "false", bDelay); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + ExitCodeBlock(); + } + break; + case CExitInfo::ExitResetRecompCode: + g_Notify->BreakPoint(__FILE__, __LINE__); +#ifdef legacycode + if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT) + { + X86BreakPoint(__FILEW__, __LINE__); + } + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + X86BreakPoint(__FILEW__, __LINE__); + MoveVariableToX86reg(this, "this", x86_ECX); + Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode"); +#endif + ExitCodeBlock(); + break; + case CExitInfo::TLBReadMiss: + MoveVariableToX86reg(g_TLBLoadAddress, "g_TLBLoadAddress", x86_EDX); + Push(x86_EDX); + PushImm32(m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + ExitCodeBlock(); + break; + case CExitInfo::TLBWriteMiss: + X86BreakPoint(__FILE__, __LINE__); + ExitCodeBlock(); + break; + case CExitInfo::DivByZero: + AddConstToVariable(4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + if (!g_System->b32BitCore()) + { + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + } + MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + ExitCodeBlock(); + break; + default: + WriteTrace(TraceRecompiler, TraceError, "how did you want to exit on reason (%d) ???", reason); + g_Notify->BreakPoint(__FILE__, __LINE__); + } +} diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h index 028dad4d8..cd7b9f17c 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,7 @@ class CRecompilerOps : protected CN64SystemSettings, protected CRecompilerSettings { -protected: +public: enum BRANCH_TYPE { BranchTypeCop1, BranchTypeRs, BranchTypeRsRt @@ -36,8 +37,8 @@ protected: typedef void ( * BranchFunction )(); /************************** Branch functions ************************/ - static void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link); - static void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link); + void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link); + void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link); static void BNE_Compare(); static void BEQ_Compare(); static void BGTZ_Compare(); @@ -49,7 +50,7 @@ protected: /************************* OpCode functions *************************/ static void J (); - static void JAL (); + void JAL (); static void ADDI (); static void ADDIU (); static void SLTI (); @@ -93,9 +94,9 @@ protected: static void SPECIAL_SLLV (); static void SPECIAL_SRLV (); static void SPECIAL_SRAV (); - static void SPECIAL_JR (); - static void SPECIAL_JALR (); - static void SPECIAL_SYSCALL(); + void SPECIAL_JR (); + void SPECIAL_JALR (); + void SPECIAL_SYSCALL(); static void SPECIAL_MFLO (); static void SPECIAL_MTLO (); static void SPECIAL_MFHI (); @@ -105,7 +106,7 @@ protected: static void SPECIAL_DSRAV (); static void SPECIAL_MULT (); static void SPECIAL_MULTU (); - static void SPECIAL_DIV (); + void SPECIAL_DIV (); static void SPECIAL_DIVU (); static void SPECIAL_DMULT (); static void SPECIAL_DMULTU (); @@ -141,7 +142,7 @@ protected: static void COP0_CO_TLBWI (); static void COP0_CO_TLBWR (); static void COP0_CO_TLBP (); - static void COP0_CO_ERET (); + void COP0_CO_ERET (); /************************** COP1 functions **************************/ static void COP1_MF (); @@ -206,13 +207,14 @@ protected: /************************** Other functions **************************/ static void UnknownOpcode (); + void CompileExitCode(); static void BeforeCallDirect(CRegInfo & RegSet); static void AfterCallDirect(CRegInfo & RegSet); static void EnterCodeBlock(); static void ExitCodeBlock(); - static void CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg); - static void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); - static void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); + void CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg); + void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); + void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles); static void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false); static void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet); @@ -334,4 +336,7 @@ protected: public: static uint32_t CompilePC() { return m_CompilePC; } + + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)); + EXIT_LIST m_ExitInfo; }; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp index 6302f47fd..69ac1cc75 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp @@ -14,8 +14,6 @@ #include #include -uint8_t * CX86Ops::m_RecompPos; - char CX86Ops::m_fpupop[2][2] = { "", "p" @@ -216,7 +214,7 @@ void CX86Ops::Call_Direct(void * FunctAddress, const char * FunctName) { CPU_Message(" call offset %s", FunctName); AddCode8(0xE8); - AddCode32((uint32_t)FunctAddress - (uint32_t)*m_RecompPos - 4); + AddCode32((uint32_t)FunctAddress - (uint32_t)*g_RecompPos - 4); } void CX86Ops::Call_Indirect(void * FunctAddress, const char * FunctName) @@ -4294,18 +4292,36 @@ void * CX86Ops::GetAddressOf(int value, ...) void CX86Ops::AddCode8(uint8_t value) { - (*((uint8_t *)(m_RecompPos)) = (uint8_t)(value)); - m_RecompPos += 1; +#ifdef _DEBUG + if (g_RecompPos == NULL) + { + g_Notify->BreakPoint(__FILE__,__LINE__); + } +#endif + (*((uint8_t *)(*g_RecompPos))=(uint8_t)(value)); + *g_RecompPos += 1; } void CX86Ops::AddCode16(uint16_t value) { - (*((uint16_t *)(m_RecompPos)) = (uint16_t)(value)); - m_RecompPos += 2; +#ifdef _DEBUG + if (g_RecompPos == NULL) + { + g_Notify->BreakPoint(__FILE__,__LINE__); + } +#endif + (*((uint16_t *)(*g_RecompPos))=(uint16_t)(value)); + *g_RecompPos += 2; } void CX86Ops::AddCode32(uint32_t value) { - (*((uint32_t *)(m_RecompPos)) = (uint32_t)(value)); - m_RecompPos += 4; +#ifdef _DEBUG + if (g_RecompPos == NULL) + { + g_Notify->BreakPoint(__FILE__,__LINE__); + } +#endif + (*((uint32_t *)(*g_RecompPos))=(uint32_t)(value)); + *g_RecompPos += 4; } diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h index a68588825..eee933d65 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h @@ -290,7 +290,6 @@ protected: static bool Is8BitReg(x86Reg Reg); static uint8_t CalcMultiplyCode(Multipler Multiply); - static uint8_t * m_RecompPos; static void * GetAddressOf(int32_t value, ...); static void SetJump32(uint32_t * Loc, uint32_t * JumpLoc); diff --git a/Source/Project64-core/N64System/SystemGlobals.cpp b/Source/Project64-core/N64System/SystemGlobals.cpp index 53f0214bc..c9f699718 100644 --- a/Source/Project64-core/N64System/SystemGlobals.cpp +++ b/Source/Project64-core/N64System/SystemGlobals.cpp @@ -30,5 +30,6 @@ CSystemEvents * g_SystemEvents = NULL; uint32_t * g_TLBLoadAddress = NULL; uint32_t * g_TLBStoreAddress = NULL; CDebugger * g_Debugger = NULL; +uint8_t ** g_RecompPos = NULL; int * g_NextTimer; \ No newline at end of file diff --git a/Source/Project64-core/N64System/SystemGlobals.h b/Source/Project64-core/N64System/SystemGlobals.h index 80b338b21..3251cf994 100644 --- a/Source/Project64-core/N64System/SystemGlobals.h +++ b/Source/Project64-core/N64System/SystemGlobals.h @@ -58,3 +58,5 @@ extern uint32_t * g_TLBStoreAddress; __interface CDebugger; extern CDebugger * g_Debugger; + +extern uint8_t ** g_RecompPos;