produce combined source with PC fence checks, and run assembler to get binary
This commit is contained in:
1 parent
d30950da7b
commit
a4a4e0c443
1 file changed
+23
-7
+23
-7
@@ -186,10 +186,12 @@ int main(int argc,char **argv)
|
||||
|
||||
// Start at beginning of actual kernal data
|
||||
int address=0xe4d3;
|
||||
|
||||
unlink("temp.s");
|
||||
out=fopen("temp.s","w");
|
||||
if (!out) DO_ERROR("Could not write to temp.s");
|
||||
|
||||
char filename[8192];
|
||||
snprintf(filename,8192,"%s/combined.s",directory);
|
||||
unlink(filename);
|
||||
out=fopen(filename,"w");
|
||||
if (!out) DO_ERROR("Could not write to combined.s");
|
||||
fprintf(out,"\t.org $%04x\n",address);
|
||||
for(int i=0;i<source_count;i++) source_files[i].written=0;
|
||||
int written_count;
|
||||
@@ -203,7 +205,7 @@ int main(int argc,char **argv)
|
||||
int next_fixed_routine=-1;
|
||||
for(int i=0;i<source_count;i++)
|
||||
if (!source_files[i].written) {
|
||||
if (source_files[i].address>address)
|
||||
if (source_files[i].address>=address)
|
||||
if (source_files[i].address<next_allocated_address) {
|
||||
next_allocated_address=source_files[i].address;
|
||||
next_fixed_routine=i;
|
||||
@@ -225,6 +227,9 @@ int main(int argc,char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if done
|
||||
if (next_fixed_routine==-1&&biggest==-1) break;
|
||||
|
||||
fprintf(stderr,"At address $%04x, next allocated address is $%04X. Current space is %d bytes\n",
|
||||
address,next_allocated_address,space);
|
||||
if (biggest>-1)
|
||||
@@ -233,7 +238,7 @@ int main(int argc,char **argv)
|
||||
if (biggest==-1) {
|
||||
// Nothing else fits here. So write next_fixed_routine
|
||||
fprintf(stderr,"Writing file %s\n",source_files[next_fixed_routine].file);
|
||||
fprintf(out,"; Source file %s\n",source_files[next_fixed_routine].file);
|
||||
fprintf(out,"\n; Source file %s @ $%04X\n",source_files[next_fixed_routine].file,address);
|
||||
fprintf(out,"\t.checkpc $%04x\n\t.advance $%04x,$00\n",
|
||||
next_allocated_address,next_allocated_address);
|
||||
char filename[8192];
|
||||
@@ -242,7 +247,7 @@ int main(int argc,char **argv)
|
||||
source_files[next_fixed_routine].written=1;
|
||||
address=next_allocated_address+source_files[next_fixed_routine].size;
|
||||
} else {
|
||||
fprintf(out,"; Source file %s\n",source_files[biggest].file);
|
||||
fprintf(out,"\n; Source file %s @ $%04x\n",source_files[biggest].file,address);
|
||||
fprintf(stderr,"Writing file %s\n",source_files[biggest].file);
|
||||
char filename[8192];
|
||||
snprintf(filename,8192,"%s/%s",directory,source_files[biggest].file);
|
||||
@@ -254,6 +259,17 @@ int main(int argc,char **argv)
|
||||
fclose(out);
|
||||
|
||||
if (retVal) break;
|
||||
|
||||
for(int i=0;i<source_count;i++)
|
||||
if (!source_files[i].written) {
|
||||
fprintf(stderr,"ERROR: Did not write source file '%s'\n",source_files[i].file);
|
||||
DO_ERROR("Did not write all source files. Did they not fit?");
|
||||
}
|
||||
if (retVal) break;
|
||||
|
||||
fprintf(stderr,"Assembling combined source...\n");
|
||||
snprintf(cmd,8192,"Ophis/bin/ophis %s/combined.s -o %s/OUT.BIN",directory,directory);
|
||||
system(cmd);
|
||||
|
||||
} while(0);
|
||||
|
||||
|
||||
Reference in new issue
Block a user