void write_verbose(t_data *data) { if (data->verbose == 0) return ; ft_printf("\033[31;1m%s :\033[0m\n%s\n", NAME_CMD_STRING, data->name); ft_printf("\033[31;1m%s :\033[0m\n%s\n", COMMENT_CMD_STRING, data->comment); ft_printf("\033[31;1mSize of cor in bytes : \033[0m%d\n", data->prog_size); ft_printf("\033[31;1mProgram in hexadecimal : \033[0m"); print_prog(data); }
static void print_pipe(cmds* cmd) { prog_args* prog; for (prog=&cmd->prog; prog!=NULL; prog=prog->next) { print_prog(prog); if (prog->next!=NULL) { printf("| "); } } }
/* print/dump/visualize a command list */ void parser_print(cmds* cmd) { if (cmd==NULL) { printf("NULL\n"); return; } switch (cmd->kind) { case EXIT: printf("EXIT "); break; case CD: printf("CD %s ",cmd->cd.path); break; case PROG: print_prog(&cmd->prog); break; case PIPE: print_pipe(cmd); break; case ENV: if (cmd->env.value != NULL) { printf("SET %s=%s ",cmd->env.name,cmd->env.value); } else { printf("UNSET %s ",cmd->env.name); } break; case JOB: switch (cmd->job.kind) { case INFO: printf("JOBS "); break; case BG: printf("BG "); break; case FG: printf("FG "); } if (cmd->job.id!=-1) printf("%d ",cmd->job.id); break; } if (cmd->next!=NULL) { printf(";\n"); parser_print(cmd->next); } else { printf("\n"); } }
void print_t_plr(t_list_player *lplr) { t_list_player *tmp; tmp = lplr; char *buff; buff= NULL; while (tmp) { ft_printf("__dans BIN __\nnumplr:%u\n", tmp->plr->num_plyr); print_magic(*tmp->plr, buff); print_prog_name(*tmp->plr); print_prog_size(*tmp->plr, buff); print_comment(*tmp->plr); print_prog(*tmp->plr); tmp = tmp->next; } }
int main(int argc, char **argv) { FILE *iFile, // point to assembly code input *oFile; // point to output log handle_arg(argc, argv, &iFile, &oFile); // handle the execution arguments word instrs[MAXFILE]; // container for assem program word *prog = instrs; // reference to assem program //------------------------------- // I1 || I2 || I3 || ...... //------------------------------- word words[MAXFILE]; // word memory for use by $gp word *mem = words; // reference to words in mem //------------------------------- // W1 || W2 || W3 || ...... //------------------------------- word reg_arr[MAXREGS]; // word memory for use by $gp word *regs = reg_arr; // reference to words in mem //------------------------------- // R1 || R2 || R3 || ...... //------------------------------- char metadata[MAXLINE]; // 1st line has num_instr / num_data size PC, // program / instruction counter GP; // global ptr to memory fgets(metadata, sizeof(metadata), iFile); // grab metadata sscanf(metadata, "%d %d", &PC, &GP); // store metadata // This is the layout of the machine code file. The first // line contains the metadata. This is read in above^^. // The lines following will contain instructions and then // data, according to the counts given in the metadata. // #I #W <------Metadata //--------- <------PC=0 (text segment) // I1 | //--------- <------PC=1 // I2 | //--------- <------PC=2 // I3 | //--------- // ...... | //--------- // ...... | //--------- <------GP=0 (data segment) // W1 | //--------- <------GP=1 // W2 | //--------- <------GP=2 // ...... | //-------- get_program(&iFile, prog, mem, &PC, &GP); // store program regs[28] = PC; // set the GP reg print_prog(&oFile, prog, &PC); // print program print_data(&oFile, mem, &GP, &PC); // print dataseg simulate(&oFile, regs, prog, mem, &PC, &GP); // run program fprintf(oFile, "exiting simulator\n"); // successful exit message print_logo(); return 0; // exit successfully }