Skip to content

Commit

Permalink
Add local variables to debug file
Browse files Browse the repository at this point in the history
  • Loading branch information
drmortalwombat committed Apr 9, 2023
1 parent 373ef6c commit e23ab50
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 256 deletions.
4 changes: 2 additions & 2 deletions include/c64/asm6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ inline byte asm_zp(byte * ip, AsmIns ins, byte addr)
return 2;
}

inline byte asm_rl(byte * ip, AsmIns ins, byte addr)
inline byte asm_rl(byte * ip, AsmIns ins, sbyte addr)
{
ip[0] = ins & 0xff;
ip[1] = addr;
ip[1] = (byte)addr;
return 2;
}

Expand Down
2 changes: 1 addition & 1 deletion include/c64/asm6502.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline byte asm_ac(byte * ip, AsmIns ins);
inline byte asm_zp(byte * ip, AsmIns ins, byte addr);

// relative branch
inline byte asm_rl(byte * ip, AsmIns ins, byte addr);
inline byte asm_rl(byte * ip, AsmIns ins, sbyte addr);

// immediate
inline byte asm_im(byte * ip, AsmIns ins, byte value);
Expand Down
30 changes: 21 additions & 9 deletions oscar64/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,17 +1048,16 @@ bool Compiler::WriteDbjFile(const char* filename)
InterVariable* v(p->mParamVars[i]);
if (v && v->mIdent)
{
if (v->mLinkerObject)
{
}
else
{
if (!vfirst)
fprintf(file, ",\n");
vfirst = false;
if (!vfirst)
fprintf(file, ",\n");
vfirst = false;

if (p->mFastCallProcedure)
fprintf(file, "\t\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"typeid\": %d}", v->mIdent->mString, i + BC_REG_FPARAMS, i + BC_REG_FPARAMS + v->mSize, types.IndexOrPush(v->mDeclaration->mBase));
}
else if (p->mFramePointer)
fprintf(file, "\t\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"base\": %d, \"typeid\": %d}", v->mIdent->mString, v->mOffset, v->mOffset + v->mSize, BC_REG_LOCALS, types.IndexOrPush(v->mDeclaration->mBase));
else
fprintf(file, "\t\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"base\": %d, \"typeid\": %d}", v->mIdent->mString, v->mOffset, v->mOffset + v->mSize, BC_REG_STACK, types.IndexOrPush(v->mDeclaration->mBase));
}
}
for (int i = 0; i < p->mLocalVars.Size(); i++)
Expand All @@ -1077,8 +1076,21 @@ bool Compiler::WriteDbjFile(const char* filename)
fprintf(file, "\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"typeid\": %d}", v->mIdent->mString, v->mLinkerObject->mAddress, v->mLinkerObject->mAddress + v->mLinkerObject->mSize, types.IndexOrPush(v->mDeclaration->mBase));
}
}
else if (p->mFramePointer)
{
if (!vfirst)
fprintf(file, ",\n");
vfirst = false;

fprintf(file, "\t\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"base\": %d, \"typeid\": %d}", v->mIdent->mString, v->mOffset, v->mOffset + v->mSize, BC_REG_LOCALS, types.IndexOrPush(v->mDeclaration->mBase));
}
else
{
if (!vfirst)
fprintf(file, ",\n");
vfirst = false;

fprintf(file, "\t\t\t{\"name\": \"%s\", \"start\": %d, \"end\": %d, \"base\": %d, \"typeid\": %d}", v->mIdent->mString, v->mOffset, v->mOffset + v->mSize, BC_REG_STACK, types.IndexOrPush(v->mDeclaration->mBase));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions oscar64/GlobalAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ Declaration * GlobalAnalyzer::Analyze(Expression* exp, Declaration* procDec, boo

return exp->mDecType;
}
else
return Analyze(exp->mLeft, procDec, false);
break;
case EX_POSTFIX:
break;
Expand Down
2 changes: 1 addition & 1 deletion oscar64/InterCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14531,7 +14531,7 @@ InterCodeProcedure::InterCodeProcedure(InterCodeModule * mod, const Location & l
mIdent(ident), mLinkerObject(linkerObject),
mNativeProcedure(false), mLeafProcedure(false), mCallsFunctionPointer(false), mCalledFunctions(nullptr), mFastCallProcedure(false),
mInterrupt(false), mHardwareInterrupt(false), mCompiled(false), mInterruptCalled(false),
mSaveTempsLinkerObject(nullptr), mValueReturn(false),
mSaveTempsLinkerObject(nullptr), mValueReturn(false), mFramePointer(false),
mDeclaration(nullptr)
{
mID = mModule->mProcedures.Size();
Expand Down
2 changes: 1 addition & 1 deletion oscar64/InterCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class InterCodeProcedure
GrowingIntArray mTempOffset, mTempSizes;
int mTempSize, mCommonFrameSize, mCallerSavedTemps, mFreeCallerSavedTemps, mFastCallBase;
bool mLeafProcedure, mNativeProcedure, mCallsFunctionPointer, mHasDynamicStack, mHasInlineAssembler, mCallsByteCode, mFastCallProcedure;
bool mInterrupt, mHardwareInterrupt, mCompiled, mInterruptCalled, mValueReturn;
bool mInterrupt, mHardwareInterrupt, mCompiled, mInterruptCalled, mValueReturn, mFramePointer;
GrowingInterCodeProcedurePtrArray mCalledFunctions;

InterCodeModule * mModule;
Expand Down
17 changes: 17 additions & 0 deletions oscar64/NativeCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38229,6 +38229,11 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mFrameOffset = 0;
mNoFrame = (mStackExpand + proc->mCommonFrameSize) < 64 && !proc->mHasDynamicStack;// && !(proc->mHasInlineAssembler && !proc->mLeafProcedure);

#if 0
if (!(proc->mCompilerOptions & COPT_OPTIMIZE_BASIC) && (proc->mCompilerOptions & COPT_DEBUGINFO))
mNoFrame = mStackExpand + proc->mCommonFrameSize == 0 && !proc->mHasDynamicStack;
#endif

if (mNoFrame)
proc->mLinkerObject->mFlags |= LOBJF_NO_FRAME;

Expand Down Expand Up @@ -38614,6 +38619,18 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
}
}

proc->mFramePointer = !mNoFrame;
for (int i = 0; i < proc->mParamVars.Size(); i++)
{
if (proc->mParamVars[i])
proc->mParamVars[i]->mOffset = i + proc->mLocalSize + 2 + mFrameOffset;
}
for (int i = 0; i < proc->mLocalVars.Size(); i++)
{
if (proc->mLocalVars[i])
proc->mLocalVars[i]->mOffset += mFrameOffset;
}

if (proc->mHardwareInterrupt)
mExitBlock->mIns.Push(NativeCodeInstruction(nullptr, ASMIT_RTI, ASMIM_IMPLIED));
else
Expand Down
2 changes: 1 addition & 1 deletion oscar64/oscar64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main2(int argc, const char** argv)

#else
strcpy(strProductName, "oscar64");
strcpy(strProductVersion, "1.18.196");
strcpy(strProductVersion, "1.18.197");

#ifdef __APPLE__
uint32_t length = sizeof(basePath);
Expand Down
8 changes: 4 additions & 4 deletions oscar64/oscar64.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,18,196,0
PRODUCTVERSION 1,18,196,0
FILEVERSION 1,18,197,0
PRODUCTVERSION 1,18,197,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -43,12 +43,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "oscar64"
VALUE "FileDescription", "oscar64 compiler"
VALUE "FileVersion", "1.18.196.0"
VALUE "FileVersion", "1.18.197.0"
VALUE "InternalName", "oscar64.exe"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "oscar64.exe"
VALUE "ProductName", "oscar64"
VALUE "ProductVersion", "1.18.196.0"
VALUE "ProductVersion", "1.18.197.0"
END
END
BLOCK "VarFileInfo"
Expand Down
Loading

0 comments on commit e23ab50

Please sign in to comment.