TrietPhan_FinalProject.c
// Executes one command, execute the correct function depends on the commond
Executes one command, execute the correct function depends on the commond
Executes one command execute the correct function depends on the commond
int execute_command(char cmd_char, char *cmd_line, CPU *cpu) {
  Word temp = 0;
  if(cmd_char == '?' || cmd_char == 'h') {
    help_message();
  }
  else if(cmd_char == 'd') {
    dump_CPU(cpu);
    dump_memory(cpu);
  }
  else if(cmd_char == 'j' && sscanf(cmd_line, "j x%hx", &temp) && *(cmd_line + 1) != '\n') {
    jump_pc(cmd_line, cpu);
  }
  else if(cmd_char == '\n') {
    one_instruction_cycle(cpu);
  }
  else if(cmd_char == 'q') {
    printf("Quit the simulator\n");
    return 1;
  }
  else {
    printf("Incorrect command, use h or ? for Simulator help guide\n");
  }
  return 0;
}
int execute_command ( char cmd_char , char * cmd_line , CPU * cpu ) { Word temp = 0 ; if ( cmd_char == ' ' || cmd_char == ' ' ) { help_message ( ) ; } else if ( cmd_char == ' ' ) { dump_CPU ( cpu ) ; dump_memory ( cpu ) ; } else if ( cmd_char == ' ' && sscanf ( cmd_line , " " , & temp ) && * ( cmd_line + 1 ) != ' \n ' ) { jump_pc ( cmd_line , cpu ) ; } else if ( cmd_char == ' \n ' ) { one_instruction_cycle ( cpu ) ; } else if ( cmd_char == ' ' ) { printf ( " \n " ) ; return 1 ; } else { printf ( " \n " ) ; } return 0 ; }
Executes one command, execute the correct function depends on the commond
Executes one command execute the correct function depends on the commond
// Temp checks the input