Save label file as understood by vice

This commit is contained in:
drmortalwombat 2021-10-16 21:21:44 +02:00
parent 55cd076f7b
commit 13dd453728
3 changed files with 32 additions and 1 deletions

View File

@ -298,7 +298,7 @@ bool Compiler::GenerateCode(void)
bool Compiler::WriteOutputFile(const char* targetPath)
{
char prgPath[200], mapPath[200], asmPath[200];
char prgPath[200], mapPath[200], asmPath[200], lblPath[200];
strcpy_s(prgPath, targetPath);
int i = strlen(prgPath);
@ -308,10 +308,12 @@ bool Compiler::WriteOutputFile(const char* targetPath)
strcpy_s(mapPath, prgPath);
strcpy_s(asmPath, prgPath);
strcpy_s(lblPath, prgPath);
strcat_s(prgPath, "prg");
strcat_s(mapPath, "map");
strcat_s(asmPath, "asm");
strcat_s(lblPath, "lbl");
printf("Writing <%s>\n", prgPath);
mLinker->WritePrgFile(prgPath);
@ -322,6 +324,9 @@ bool Compiler::WriteOutputFile(const char* targetPath)
printf("Writing <%s>\n", asmPath);
mLinker->WriteAsmFile(asmPath);
printf("Writing <%s>\n", lblPath);
mLinker->WriteLblFile(lblPath);
return true;
}

View File

@ -379,6 +379,31 @@ bool Linker::WriteMapFile(const char* filename)
return false;
}
bool Linker::WriteLblFile(const char* filename)
{
FILE* file;
fopen_s(&file, filename, "wb");
if (file)
{
for (int i = 0; i < mObjects.Size(); i++)
{
LinkerObject* obj = mObjects[i];
if (obj->mFlags & LOBJF_REFERENCED)
{
if (obj->mIdent)
fprintf(file, "al %04x .%s\n", obj->mAddress, obj->mIdent->mString);
}
}
fclose(file);
return true;
}
else
return false;
}
bool Linker::WriteAsmFile(const char* filename)
{
FILE* file;

View File

@ -129,6 +129,7 @@ public:
bool WritePrgFile(const char* filename);
bool WriteMapFile(const char* filename);
bool WriteAsmFile(const char* filename);
bool WriteLblFile(const char* filename);
GrowingArray<LinkerReference*> mReferences;
GrowingArray<LinkerRegion*> mRegions;