Add cartridge bank lookup for lables in asm file
This commit is contained in:
parent
1407d9d948
commit
0d95a74813
|
@ -718,29 +718,29 @@ void NativeCodeDisassembler::Disassemble(FILE* file, const uint8* memory, int ba
|
|||
break;
|
||||
case ASMIM_ZERO_PAGE:
|
||||
addr = memory[ip++];
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
case ASMIM_ZERO_PAGE_X:
|
||||
addr = memory[ip++];
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s,x %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s,x %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
case ASMIM_ZERO_PAGE_Y:
|
||||
addr = memory[ip++];
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s,y %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s %s,y %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
case ASMIM_ABSOLUTE:
|
||||
addr = memory[ip] + 256 * memory[ip + 1];
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(bank, addr, abuffer, proc, linker));
|
||||
ip += 2;
|
||||
break;
|
||||
case ASMIM_ABSOLUTE_X:
|
||||
addr = memory[ip] + 256 * memory[ip + 1];
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x,x %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x,x %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(bank, addr, abuffer, proc, linker));
|
||||
ip += 2;
|
||||
break;
|
||||
case ASMIM_ABSOLUTE_Y:
|
||||
addr = memory[ip] + 256 * memory[ip + 1];
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x,y %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x %02x %s $%04x,y %s\n", iip, memory[iip], memory[iip + 1], memory[iip + 2], AsmInstructionNames[d.mType], addr, AddrName(bank, addr, abuffer, proc, linker));
|
||||
ip += 2;
|
||||
break;
|
||||
case ASMIM_INDIRECT:
|
||||
|
@ -750,11 +750,11 @@ void NativeCodeDisassembler::Disassemble(FILE* file, const uint8* memory, int ba
|
|||
break;
|
||||
case ASMIM_INDIRECT_X:
|
||||
addr = memory[ip++];
|
||||
fprintf(file, "%04x : %02x %02x __ %s (%s,x) %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s (%s,x) %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
case ASMIM_INDIRECT_Y:
|
||||
addr = memory[ip++];
|
||||
fprintf(file, "%04x : %02x %02x __ %s (%s),y %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s (%s),y %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], TempName(addr, tbuffer, proc, linker), AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
case ASMIM_RELATIVE:
|
||||
addr = memory[ip++];
|
||||
|
@ -762,14 +762,14 @@ void NativeCodeDisassembler::Disassemble(FILE* file, const uint8* memory, int ba
|
|||
addr = addr + ip - 256;
|
||||
else
|
||||
addr = addr + ip;
|
||||
fprintf(file, "%04x : %02x %02x __ %s $%04x %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], addr, AddrName(addr, abuffer, proc, linker));
|
||||
fprintf(file, "%04x : %02x %02x __ %s $%04x %s\n", iip, memory[iip], memory[iip + 1], AsmInstructionNames[d.mType], addr, AddrName(bank, addr, abuffer, proc, linker));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char* NativeCodeDisassembler::AddrName(int addr, char* buffer, InterCodeProcedure* proc, Linker* linker)
|
||||
const char* NativeCodeDisassembler::AddrName(int bank, int addr, char* buffer, InterCodeProcedure* proc, Linker* linker)
|
||||
{
|
||||
if (linker)
|
||||
{
|
||||
|
@ -794,7 +794,7 @@ const char* NativeCodeDisassembler::AddrName(int addr, char* buffer, InterCodePr
|
|||
if (proc && proc->mLinkerObject && addr >= proc->mLinkerObject->mAddress && addr < proc->mLinkerObject->mAddress + proc->mLinkerObject->mSize)
|
||||
obj = proc->mLinkerObject;
|
||||
else
|
||||
obj = linker->FindObjectByAddr(addr);
|
||||
obj = linker->FindObjectByAddr(bank, addr);
|
||||
|
||||
if (obj && obj->mIdent)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
void DumpMemory(FILE* file, const uint8* memory, int bank, int start, int size, InterCodeProcedure* proc, const Ident* ident, Linker* linker, LinkerObject * lobj);
|
||||
protected:
|
||||
const char* TempName(uint8 tmp, char* buffer, InterCodeProcedure* proc, Linker* linker);
|
||||
const char* AddrName(int addr, char* buffer, InterCodeProcedure* proc, Linker* linker);
|
||||
const char* AddrName(int bank, int addr, char* buffer, InterCodeProcedure* proc, Linker* linker);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -3170,7 +3170,7 @@ void InterInstruction::FilterStaticVarsUsage(const GrowingVariableArray& staticV
|
|||
}
|
||||
else if (mSrc[0].mMemory == IM_GLOBAL)
|
||||
{
|
||||
if (!providedVars[mSrc[0].mVarIndex])
|
||||
if (mSrc[0].mVarIndex >= 0 && !providedVars[mSrc[0].mVarIndex])
|
||||
requiredVars += mSrc[0].mVarIndex;
|
||||
}
|
||||
}
|
||||
|
@ -3186,10 +3186,13 @@ void InterInstruction::FilterStaticVarsUsage(const GrowingVariableArray& staticV
|
|||
}
|
||||
else if (mSrc[1].mMemory == IM_GLOBAL)
|
||||
{
|
||||
if (mSrc[1].mIntConst == 0 && mSrc[1].mOperandSize == staticVars[mSrc[1].mVarIndex]->mSize)
|
||||
providedVars += mSrc[1].mVarIndex;
|
||||
else if (!providedVars[mSrc[1].mVarIndex])
|
||||
requiredVars += mSrc[1].mVarIndex;
|
||||
if (mSrc[1].mVarIndex >= 0)
|
||||
{
|
||||
if (mSrc[1].mIntConst == 0 && mSrc[1].mOperandSize == staticVars[mSrc[1].mVarIndex]->mSize)
|
||||
providedVars += mSrc[1].mVarIndex;
|
||||
else if (!providedVars[mSrc[1].mVarIndex])
|
||||
requiredVars += mSrc[1].mVarIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mCode == IC_COPY || mCode == IC_CALL || mCode == IC_CALL_NATIVE || mCode == IC_RETURN || mCode == IC_RETURN_STRUCT || mCode == IC_RETURN_VALUE || mCode == IC_STRCPY || mCode == IC_DISPATCH)
|
||||
|
@ -3696,7 +3699,8 @@ bool InterInstruction::RemoveUnusedStaticStoreInstructions(InterCodeBasicBlock*
|
|||
}
|
||||
else if (mSrc[0].mMemory == IM_GLOBAL)
|
||||
{
|
||||
requiredVars += mSrc[0].mVarIndex;
|
||||
if (mSrc[0].mVarIndex >= 0)
|
||||
requiredVars += mSrc[0].mVarIndex;
|
||||
}
|
||||
|
||||
int k = 0;
|
||||
|
@ -3709,7 +3713,7 @@ bool InterInstruction::RemoveUnusedStaticStoreInstructions(InterCodeBasicBlock*
|
|||
}
|
||||
else if (mCode == IC_STORE)
|
||||
{
|
||||
if (mSrc[1].mMemory == IM_GLOBAL)
|
||||
if (mSrc[1].mMemory == IM_GLOBAL && mSrc[1].mVarIndex >= 0)
|
||||
{
|
||||
if (requiredVars[mSrc[1].mVarIndex])
|
||||
{
|
||||
|
@ -17973,10 +17977,15 @@ bool InterCodeProcedure::ReferencesGlobal(int varindex)
|
|||
{
|
||||
if (mGlobalsChecked)
|
||||
{
|
||||
if (mModule->mGlobalVars[varindex]->mAliased)
|
||||
return mLoadsIndirect || mStoresIndirect;
|
||||
else if (varindex < mReferencedGlobals.Size())
|
||||
return mReferencedGlobals[varindex];
|
||||
if (varindex >= 0)
|
||||
{
|
||||
if (mModule->mGlobalVars[varindex]->mAliased)
|
||||
return mLoadsIndirect || mStoresIndirect;
|
||||
else if (varindex < mReferencedGlobals.Size())
|
||||
return mReferencedGlobals[varindex];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -17988,10 +17997,15 @@ bool InterCodeProcedure::ModifiesGlobal(int varindex)
|
|||
{
|
||||
if (mGlobalsChecked)
|
||||
{
|
||||
if (mModule->mGlobalVars[varindex]->mAliased)
|
||||
return mStoresIndirect;
|
||||
else if (varindex < mModifiedGlobals.Size())
|
||||
return mModifiedGlobals[varindex];
|
||||
if (varindex >= 0)
|
||||
{
|
||||
if (mModule->mGlobalVars[varindex]->mAliased)
|
||||
return mStoresIndirect;
|
||||
else if (varindex < mModifiedGlobals.Size())
|
||||
return mModifiedGlobals[varindex];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -241,6 +241,24 @@ LinkerObject* Linker::FindObjectByAddr(int addr)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
LinkerObject* Linker::FindObjectByAddr(int bank, int addr)
|
||||
{
|
||||
for (int i = 0; i < mObjects.Size(); i++)
|
||||
{
|
||||
LinkerObject* lobj = mObjects[i];
|
||||
if (lobj->mFlags & LOBJF_PLACED)
|
||||
{
|
||||
if (lobj->mRegion && ((1ULL << bank) & lobj->mRegion->mCartridgeBanks))
|
||||
{
|
||||
if (addr >= lobj->mAddress && addr < lobj->mAddress + lobj->mSize)
|
||||
return lobj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FindObjectByAddr(addr);
|
||||
}
|
||||
|
||||
LinkerObject * Linker::AddObject(const Location& location, const Ident* ident, LinkerSection * section, LinkerObjectType type, int alignment)
|
||||
{
|
||||
LinkerObject* obj = new LinkerObject;
|
||||
|
|
|
@ -237,6 +237,7 @@ public:
|
|||
LinkerRegion* FindRegionOfSection(LinkerSection* section);
|
||||
|
||||
LinkerObject* FindObjectByAddr(int addr);
|
||||
LinkerObject* FindObjectByAddr(int bank, int addr);
|
||||
|
||||
bool IsSectionPlaced(LinkerSection* section);
|
||||
|
||||
|
|
Loading…
Reference in New Issue