diff --git a/y86sim.c b/y86sim.c index 7fd0d14..970a9b9 100644 --- a/y86sim.c +++ b/y86sim.c @@ -443,6 +443,10 @@ void y86_load_reset(Y_data *y) { void y86_load(Y_data *y, Y_char *begin) { Y_char *inst = begin; Y_char *end = &(y->mem[y->reg[yr_len]]); + while (*end) { + y->reg[yr_len]++; + end = &(y->mem[y->reg[yr_len]]); + } Y_word pc = y->reg[yr_pc]; @@ -512,9 +516,9 @@ void y86_ready(Y_data *y, Y_word step) { void y86_trace_ip(Y_data *y) { if (y->x_map[y->reg[yr_pc]]) { - y->reg[yr_rey] = (Y_word) y->x_map[y->reg[yr_pc]]; + y->reg[yr_rey] = (Y_word) y->x_map[y->reg[yr_pc]]; } else { - // TODO + y86_load(y, &(y->mem[y->reg[yr_pc]])); } } @@ -602,11 +606,11 @@ void __attribute__ ((noinline)) y86_exec(Y_data *y) { "y86_int_imc:" "\n\t" - // If mm4 < inst_size, handle by outer + // If mm4 <= current inst size, handle by outer "movd %%mm4, %%eax" "\n\t" - "andl $" Y_MASK_NOT_INST ", %%eax" "\n\t" - "jnz y86_check_2" "\n\t" + "cmpl 16(%%esp), %%eax" "\n\t" + "jg y86_check_2" "\n\t" "jmp y86_fin" "\n\t" @@ -690,7 +694,6 @@ void y86_go(Y_data *y, Y_word step) { case ys_imc: // y86_trace_pc(y); - // TODO: checking if (y86_get_im_ptr() + 4 < y->reg[yr_len]) { y->reg[yr_len] = y86_get_im_ptr() + 4; } diff --git a/y86sim_max.c b/y86sim_max.c index e1bd4c7..c4b2208 100644 --- a/y86sim_max.c +++ b/y86sim_max.c @@ -375,6 +375,10 @@ void y86_load_reset(Y_data *y) { void y86_load(Y_data *y, Y_char *begin) { Y_char *inst = begin; Y_char *end = &(y->mem[y->reg[yr_len]]); + while (*end) { + y->reg[yr_len]++; + end = &(y->mem[y->reg[yr_len]]); + } Y_word pc = y->reg[yr_pc]; @@ -443,11 +447,7 @@ void y86_ready(Y_data *y) { } void y86_trace_ip(Y_data *y) { - if (y->x_map[y->reg[yr_pc]]) { - y->reg[yr_rey] = (Y_word) y->x_map[y->reg[yr_pc]]; - } else { - // TODO - } + y->reg[yr_rey] = (Y_word) &(y->x_inst[0]); } void __attribute__ ((noinline)) y86_exec(Y_data *y) { @@ -492,27 +492,13 @@ void __attribute__ ((noinline)) y86_exec(Y_data *y) { void y86_trace_pc(Y_data *y) { Y_word index; - Y_word diff; - Y_word index_x; - Y_word diff_x = Y_X_INST_SIZE; for (index = 0; index < Y_Y_INST_SIZE; ++index) { - diff = y->reg[yr_rey] - (Y_word) y->x_map[index]; - - // After step - if (!diff) { - index_x = index; - break; - } - - // After interrupt - if (diff > 0 && diff < diff_x) { - index_x = index; - diff_x = diff; + if (y->reg[yr_rey] == (Y_word) y->x_map[index]) { + y->reg[yr_pc] = index; + return; } } - - y->reg[yr_pc] = index_x; } Y_word y86_trace_pc_2(Y_data *y, Y_word value) {