From 66feea732ecb17230e298a7cc887a3f0fe4298cd Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Thu, 18 Apr 2019 21:14:45 +0930 Subject: [PATCH] more work on preprocessor to get routine sizes for packing --- src/preprocess.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/src/preprocess.c b/src/preprocess.c index 81bc0e8f..d44295fc 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -17,6 +17,11 @@ typedef struct source_file { char *file; int address; + + // For getting routine sizes from first run of ophis + int low_addr; + int high_addr; + int size; } source_file; source_file source_files[MAX_FILES]; @@ -32,6 +37,25 @@ static int compare_source(const void* a, const void* b) return strcmp(aa->file,bb->file); } +int dump_file(FILE *out,const char *name) +{ + int retVal=0; + FILE *f=NULL; + + do { + f=fopen(name,"r"); + if (!f) DO_ERROR("Failed to read file for input"); + char line[8192]; + while(!feof(f)) { + line[0]=0; fgets(line,8192,f); + fprintf(out,"%s",line); + } + } while(0); + + if (f) fclose(f); + return retVal; +} + void usage(void) { fprintf(stderr,"usage: preprocess [-d ]\n"); @@ -98,10 +122,62 @@ int main(int argc,char **argv) fprintf(stderr,"Sorted.\n"); for(int i=0;i