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
+22
-6
+22
-6
@@ -187,9 +187,11 @@ int main(int argc,char **argv)
|
|||||||
// Start at beginning of actual kernal data
|
// Start at beginning of actual kernal data
|
||||||
int address=0xe4d3;
|
int address=0xe4d3;
|
||||||
|
|
||||||
unlink("temp.s");
|
char filename[8192];
|
||||||
out=fopen("temp.s","w");
|
snprintf(filename,8192,"%s/combined.s",directory);
|
||||||
if (!out) DO_ERROR("Could not write to temp.s");
|
unlink(filename);
|
||||||
|
out=fopen(filename,"w");
|
||||||
|
if (!out) DO_ERROR("Could not write to combined.s");
|
||||||
fprintf(out,"\t.org $%04x\n",address);
|
fprintf(out,"\t.org $%04x\n",address);
|
||||||
for(int i=0;i<source_count;i++) source_files[i].written=0;
|
for(int i=0;i<source_count;i++) source_files[i].written=0;
|
||||||
int written_count;
|
int written_count;
|
||||||
@@ -203,7 +205,7 @@ int main(int argc,char **argv)
|
|||||||
int next_fixed_routine=-1;
|
int next_fixed_routine=-1;
|
||||||
for(int i=0;i<source_count;i++)
|
for(int i=0;i<source_count;i++)
|
||||||
if (!source_files[i].written) {
|
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) {
|
if (source_files[i].address<next_allocated_address) {
|
||||||
next_allocated_address=source_files[i].address;
|
next_allocated_address=source_files[i].address;
|
||||||
next_fixed_routine=i;
|
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",
|
fprintf(stderr,"At address $%04x, next allocated address is $%04X. Current space is %d bytes\n",
|
||||||
address,next_allocated_address,space);
|
address,next_allocated_address,space);
|
||||||
if (biggest>-1)
|
if (biggest>-1)
|
||||||
@@ -233,7 +238,7 @@ int main(int argc,char **argv)
|
|||||||
if (biggest==-1) {
|
if (biggest==-1) {
|
||||||
// Nothing else fits here. So write next_fixed_routine
|
// Nothing else fits here. So write next_fixed_routine
|
||||||
fprintf(stderr,"Writing file %s\n",source_files[next_fixed_routine].file);
|
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",
|
fprintf(out,"\t.checkpc $%04x\n\t.advance $%04x,$00\n",
|
||||||
next_allocated_address,next_allocated_address);
|
next_allocated_address,next_allocated_address);
|
||||||
char filename[8192];
|
char filename[8192];
|
||||||
@@ -242,7 +247,7 @@ int main(int argc,char **argv)
|
|||||||
source_files[next_fixed_routine].written=1;
|
source_files[next_fixed_routine].written=1;
|
||||||
address=next_allocated_address+source_files[next_fixed_routine].size;
|
address=next_allocated_address+source_files[next_fixed_routine].size;
|
||||||
} else {
|
} 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);
|
fprintf(stderr,"Writing file %s\n",source_files[biggest].file);
|
||||||
char filename[8192];
|
char filename[8192];
|
||||||
snprintf(filename,8192,"%s/%s",directory,source_files[biggest].file);
|
snprintf(filename,8192,"%s/%s",directory,source_files[biggest].file);
|
||||||
@@ -255,6 +260,17 @@ int main(int argc,char **argv)
|
|||||||
|
|
||||||
if (retVal) break;
|
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);
|
} while(0);
|
||||||
|
|
||||||
if (d) closedir(d);
|
if (d) closedir(d);
|
||||||
|
|||||||
Reference in new issue
Block a user