Our Project/corewarV3/corewarV3.cpp
// just sets n_procs to 2 and reads from two files (with file names hard coded)
//
just sets n_procs to 2 and reads from two files (with file names hard coded)
just sets n_procs to 2 and reads from two files ( with file names hard coded )
void init_cw(memory_cell mem[MEMORY_SIZE], int pcs[N_PROGRAMS][MAX_PROCESSES], int c_proc[N_PROGRAMS], int n_proc[N_PROGRAMS])
{
  ifstream file_one("program_one.txt");
  ifstream file_two("program_two.txt");
  int i;
  memory_cell blank;
  blank.code = DAT;
  blank.arg_A = 0;
  blank.arg_B = 0;
  blank.mode_A = DIR;
  blank.mode_B = DIR;
  for(i=0;i<MEMORY_SIZE;i++){
    mem[i] = blank;
  }
  for(i = 0; i < 5; i++){ 
    file_one >> mem[i];
  }
  pcs[0][0] = 0; 
  c_proc[0] = 0; 
  n_proc[0] = 1; 
  for(i = 20; i < 25; i++){ 
    file_two >> mem[i];
  }
  pcs[1][0] = 20; 
  c_proc[1] = 0; 
  n_proc[1] = 1; 
  file_one.close();
  file_two.close();
  return;
}
void init_cw ( memory_cell mem [ MEMORY_SIZE ] , int pcs [ N_PROGRAMS ] [ MAX_PROCESSES ] , int c_proc [ N_PROGRAMS ] , int n_proc [ N_PROGRAMS ] ) { ifstream file_one ( " " ) ; ifstream file_two ( " " ) ; int i ; memory_cell blank ; blank . code = DAT ; blank . arg_A = 0 ; blank . arg_B = 0 ; blank . mode_A = DIR ; blank . mode_B = DIR ; for ( i = 0 ; i < MEMORY_SIZE ; i ++ ) { mem [ i ] = blank ; } for ( i = 0 ; i < 5 ; i ++ ) { file_one >> mem [ i ] ; } pcs [ 0 ] [ 0 ] = 0 ; c_proc [ 0 ] = 0 ; n_proc [ 0 ] = 1 ; for ( i = 20 ; i < 25 ; i ++ ) { file_two >> mem [ i ] ; } pcs [ 1 ] [ 0 ] = 20 ; c_proc [ 1 ] = 0 ; n_proc [ 1 ] = 1 ; file_one . close ( ) ; file_two . close ( ) ; return ; }
just sets n_procs to 2 and reads from two files (with file names hard coded)
just sets n_procs to 2 and reads from two files ( with file names hard coded )
// Clear Memory // Load program one // first program starts at location 0 // first program starts at location 0 // with only one process // Load program two // second program starts at location 20 // second program starts at location 20 // with only one process