/** * execute a line from a command listing or stdin */ void shell(const char *filename) { const bool interactive = (strncmp(filename, "-", 2) == 0); FILE *fp; cpu_state state; if (interactive) { fp = stdin; } else { fp = fopen(filename, "r"); } if (fp != NULL) { printf("reading from file: %s\n", filename); } else { printf("file not found: %s\n", filename); exit(1); } cpu_reset(&state); parse_instr(fp, &state.instr); cpu_exec(&state); shell_print_state(&state, interactive); return; }
/* Decodes the instructions */ void decode_instrs(Elf_Data *edata) { uint32_t *machine_code = (uint32_t *) edata->d_buf; for (size_t i = 0; i < edata->d_size; i++) { //printf("%0x", machine_code[i]); parse_instr(machine_code[i]); } printf("\n"); }