Skip to content

Commit

Permalink
modify loading and tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
hczhcz committed May 23, 2014
1 parent deb4e91 commit 5a5bc55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
15 changes: 9 additions & 6 deletions y86sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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]]));
}
}

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
Expand Down
30 changes: 8 additions & 22 deletions y86sim_max.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5a5bc55

Please sign in to comment.