|
@@ -62,13 +62,31 @@ Instruction : tCPY tNB tNB {increment_time();
|
62
|
62
|
|
63
|
63
|
%%
|
64
|
64
|
|
65
|
|
-int main(void) {
|
66
|
|
- file = fopen("output.asm", "w");
|
67
|
|
- file2 = fopen("output_bin.txt", "w");
|
|
65
|
+#include <string.h>
|
|
66
|
+
|
|
67
|
+int main(int argc, char *argv[]) {
|
|
68
|
+ char *output_filename = "output_cross";
|
|
69
|
+
|
|
70
|
+ if (argc >= 2) {
|
|
71
|
+ output_filename = argv[1];
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ char *asm_filename = malloc(strlen(output_filename) + 5);
|
|
75
|
+ char *bin_filename = malloc(strlen(output_filename) + 9);
|
|
76
|
+ strcpy(asm_filename, output_filename);
|
|
77
|
+ strcpy(bin_filename, output_filename);
|
|
78
|
+ strcat(asm_filename, ".asm");
|
|
79
|
+ strcat(bin_filename, "_bin.txt");
|
|
80
|
+
|
|
81
|
+ file = fopen(asm_filename, "w");
|
|
82
|
+ file2 = fopen(bin_filename, "w");
|
68
|
83
|
init();
|
69
|
|
- yyparse();
|
|
84
|
+ yyparse();
|
70
|
85
|
flush_and_init();
|
71
|
|
- write_asm(file);
|
72
|
|
- write_code_machine(file2);
|
73
|
|
- return 0;
|
|
86
|
+ write_asm(file);
|
|
87
|
+ write_code_machine(file2);
|
|
88
|
+
|
|
89
|
+ free(asm_filename);
|
|
90
|
+ free(bin_filename);
|
|
91
|
+ return 0;
|
74
|
92
|
}
|