forked from pfaure/CrossAssembleur
add an argument for filenames
This commit is contained in:
parent
2fbae7f7fe
commit
84c51d9446
2 changed files with 30 additions and 10 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -1,6 +1,8 @@
|
|||
*.o
|
||||
lex.yy.c
|
||||
lex.yy.*
|
||||
as.tab.*
|
||||
output.asm
|
||||
output_bin.txt
|
||||
*.asm
|
||||
!input.asm
|
||||
*.txt
|
||||
cross_assembleur
|
||||
|
||||
|
|
24
as.y
24
as.y
|
@ -62,13 +62,31 @@ Instruction : tCPY tNB tNB {increment_time();
|
|||
|
||||
%%
|
||||
|
||||
int main(void) {
|
||||
file = fopen("output.asm", "w");
|
||||
file2 = fopen("output_bin.txt", "w");
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *output_filename = "output_cross";
|
||||
|
||||
if (argc >= 2) {
|
||||
output_filename = argv[1];
|
||||
}
|
||||
|
||||
char *asm_filename = malloc(strlen(output_filename) + 5);
|
||||
char *bin_filename = malloc(strlen(output_filename) + 9);
|
||||
strcpy(asm_filename, output_filename);
|
||||
strcpy(bin_filename, output_filename);
|
||||
strcat(asm_filename, ".asm");
|
||||
strcat(bin_filename, "_bin.txt");
|
||||
|
||||
file = fopen(asm_filename, "w");
|
||||
file2 = fopen(bin_filename, "w");
|
||||
init();
|
||||
yyparse();
|
||||
flush_and_init();
|
||||
write_asm(file);
|
||||
write_code_machine(file2);
|
||||
|
||||
free(asm_filename);
|
||||
free(bin_filename);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue