From 1d4d6bab83b72c1b02ee1db6b19a65e885f7953d Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 14 Aug 2016 18:19:13 +0200 Subject: -d -> copyasm --- bfcomp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bfcomp.c b/bfcomp.c index 804b8a5..fa52087 100644 --- a/bfcomp.c +++ b/bfcomp.c @@ -43,6 +43,7 @@ void usage(const char *argv0){ "Reads a Brainfuck program from and saves the compiled executable\n" "in .\n" "Uses nasm for assembling and gcc for linking.\n" + " -d Copies generated assembly to .asm\n" " -h Show help\n" " -H Calculate heatmap while executing\n" " -L Output last cell reached\n" @@ -59,9 +60,9 @@ __attribute__((noreturn)) void usage1(const char *argv0){ typedef struct Params{ int memsize; const char *srcfname,*dstfname; - bool lastcell,verbose,heatmap; + bool lastcell,verbose,heatmap,copyasm; } Params; -Params params={30000,NULL,NULL,false,false,false}; +Params params={30000,NULL,NULL,false,false,false,false}; void parseargs(int argc,char **argv){ if(argc<2)usage1(argv[0]); @@ -71,6 +72,10 @@ void parseargs(int argc,char **argv){ if(argv[i][0]=='-'){ for(int j=1;argv[i][j];j++){ switch(argv[i][j]){ + case 'd': + params.copyasm=true; + break; + case 'h': usage(argv[0]); exit(0); @@ -95,6 +100,9 @@ void parseargs(int argc,char **argv){ case 'v': params.verbose=true; break; + + default: + usage1(argv[0]); } } } else if(params.srcfname==NULL)params.srcfname=argv[i]; @@ -424,10 +432,13 @@ int main(int argc,char **argv){ fclose(asmf); - /*char *b; - asprintf(&b,"cp %s %s.asm",asmfname,params.srcfname); - runcmd(b); - free(b);*/ + if(params.copyasm){ + char *b; + asprintf(&b,"cp %s %s.asm",asmfname,params.srcfname); + runcmd(b); + free(b); + } + int ret=compilechain(asmfname,params.dstfname); unlink(asmfname); if(params.verbose)fprintf(stderr,"unlink(%s) (asmfname)\n",asmfname); -- cgit v1.2.3-70-g09d2