Added `-binary` CLI flag to NEDsim for loading a.out format programs.
[screensavers] / hacks / NEDsim / simulator.c
index f5c56ee..9708486 100644 (file)
@@ -379,7 +379,7 @@ parse_aout_file(FILE * input, struct exec * aout_exec, uint8_t * text_segment,
 }
 
 struct NEDstate *
 }
 
 struct NEDstate *
-init_simulator(void)
+init_simulator(char * input_file)
 {
     struct NEDstate * state = malloc(sizeof(struct NEDstate));
     state->hack = malloc(sizeof(struct NEDhack));
 {
     struct NEDstate * state = malloc(sizeof(struct NEDstate));
     state->hack = malloc(sizeof(struct NEDhack));
@@ -395,16 +395,13 @@ init_simulator(void)
     state->halted = false;
     state->hack->resume_word = false;
 
     state->halted = false;
     state->hack->resume_word = false;
 
-// TODO: This needs to be passed in as a CLI option.
-#define AOUT_PATH "./test.out"
-
     /* Load an initial image into memory. */
     struct exec aout_exec;
     struct nlist * symbol_table;
     uint32_t symbol_count;
     FILE * input = NULL;
     /* Load an initial image into memory. */
     struct exec aout_exec;
     struct nlist * symbol_table;
     uint32_t symbol_count;
     FILE * input = NULL;
-    if ((input = fopen(AOUT_PATH, "r")) == NULL) {
-        fprintf(stderr, "ERROR: %s: %s\n", AOUT_PATH, strerror(errno));
+    if ((input = fopen(input_file, "r")) == NULL) {
+        fprintf(stderr, "ERROR: %s: %s\n", input_file, strerror(errno));
         state->halted = true;
     }
     parse_aout_file(input, &aout_exec, state->ram, &symbol_table, &symbol_count);
         state->halted = true;
     }
     parse_aout_file(input, &aout_exec, state->ram, &symbol_table, &symbol_count);