Exemplo n.º 1
0
void lc3_run(lc3machine* state, int num_steps)
{
    // If machine is haled, do nothing.  Otherwise, step through the program.
    if (state->mem[state->pc] != LC3_TRAP_FULL_HALT) {
        if (num_steps == -1) {
            while(state->mem[state->pc] != LC3_TRAP_FULL_HALT) {
                lc3_step_one(state);
            }
        } else {
            for (int i = 0; i < num_steps; i++) {
                lc3_step_one(state);
            }
        }
    }
}
Exemplo n.º 2
0
void lc3_run(lc3machine* state, int num_steps)
{
	state->halted = 0;
	if (num_steps == -1){
		while(!state->halted){ 		//while not halted
			lc3_step_one(state);
		}
	}
	else{
		int i;
		for (i = 0; i < num_steps; i++)
		{
			if (!state->halted) 	// if not halted
				lc3_step_one(state);  // do as many steps as specified
			else 
				break;
		}
	}
}
Exemplo n.º 3
0
void lc3_run(lc3machine* state, int num_steps)
{
    // set up an instruction counter
    int step = 0;
    
    // run until halted or reach number of steps
    while (!state->halted && (num_steps < 0 ? 1 : step < num_steps)) {
        lc3_step_one(state);
        step ++;
    }
}