提交 2b723534 编写于 作者: Z Zihao Yu

mips32: finish pa3

上级 ebf7354e
...@@ -30,18 +30,16 @@ make_EHelper(mfc0) { ...@@ -30,18 +30,16 @@ make_EHelper(mfc0) {
#endif #endif
uint32_t val; uint32_t val;
char *name;
switch (id_dest->reg) { switch (id_dest->reg) {
case 12: val = cpu.status; name = "status"; break; case 12: val = cpu.status; print_asm("mfc0 %s, status", id_src2->str); break;
case 13: val = cpu.cause; name = "cause"; break; case 13: val = cpu.cause; print_asm("mfc0 %s, cause", id_src2->str); break;
case 14: val = cpu.epc; name = "epc"; break; case 14: val = cpu.epc; print_asm("mfc0 %s, epc", id_src2->str); break;
default: assert(0); default: assert(0);
} }
rtl_li(&s0, val); rtl_li(&s0, val);
rtl_sr(id_src2->reg, &s0, 4); rtl_sr(id_src2->reg, &s0, 4);
print_asm("mfc0 %s, %s", id_src2->str, name);
} }
make_EHelper(mtc0) { make_EHelper(mtc0) {
...@@ -49,13 +47,11 @@ make_EHelper(mtc0) { ...@@ -49,13 +47,11 @@ make_EHelper(mtc0) {
difftest_skip_ref(); difftest_skip_ref();
#endif #endif
char *name;
switch (id_dest->reg) { switch (id_dest->reg) {
case 12: cpu.status = id_src2->val; name = "status"; break; case 12: cpu.status = id_src2->val; print_asm("mtc0 %s, status", id_src2->str); break;
case 13: cpu.cause = id_src2->val; name = "cause"; break; case 13: cpu.cause = id_src2->val; print_asm("mtc0 %s, cause", id_src2->str); break;
case 14: cpu.epc = id_src2->val; name = "epc"; break; case 14: cpu.epc = id_src2->val; print_asm("mtc0 %s, epc", id_src2->str); break;
default: assert(0); default: assert(0);
} }
print_asm("mtc0 %s, %s", id_src2->str, name);
} }
#include "nemu.h" #include "nemu.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "monitor/watchpoint.h"
/* The assembly code of instructions executed is only output to the screen /* The assembly code of instructions executed is only output to the screen
* when the number of instructions executed is less than this value. * when the number of instructions executed is less than this value.
...@@ -37,6 +38,9 @@ void cpu_exec(uint64_t n) { ...@@ -37,6 +38,9 @@ void cpu_exec(uint64_t n) {
bool print_flag = n < MAX_INSTR_TO_PRINT; bool print_flag = n < MAX_INSTR_TO_PRINT;
for (; n > 0; n --) { for (; n > 0; n --) {
#ifdef DEBUG
vaddr_t temp_pc = cpu.pc;
#endif
/* Execute one instruction, including instruction fetch, /* Execute one instruction, including instruction fetch,
* instruction decode, and the actual execution. */ * instruction decode, and the actual execution. */
exec_wrapper(print_flag); exec_wrapper(print_flag);
...@@ -44,6 +48,13 @@ void cpu_exec(uint64_t n) { ...@@ -44,6 +48,13 @@ void cpu_exec(uint64_t n) {
#ifdef DEBUG #ifdef DEBUG
/* TODO: check watchpoints here. */ /* TODO: check watchpoints here. */
WP *wp = scan_watchpoint();
if(wp != NULL) {
printf("\n\nHint watchpoint %d at address 0x%08x, expr = %s\n", wp->NO, temp_pc, wp->expr);
printf("old value = %#08x\nnew value = %#08x\n", wp->old_val, wp->new_val);
wp->old_val = wp->new_val;
return;
}
#endif #endif
......
...@@ -87,8 +87,8 @@ static bool make_token(char *e) { ...@@ -87,8 +87,8 @@ static bool make_token(char *e) {
char *substr_start = e + position; char *substr_start = e + position;
int substr_len = pmatch.rm_eo; int substr_len = pmatch.rm_eo;
Log("match rules[%d] = \"%s\" at position %d with len %d: %.*s", //Log("match rules[%d] = \"%s\" at position %d with len %d: %.*s",
i, rules[i].regex, position, substr_len, substr_len, substr_start); // i, rules[i].regex, position, substr_len, substr_len, substr_start);
position += substr_len; position += substr_len;
......
...@@ -79,6 +79,8 @@ void difftest_step(vaddr_t pc) { ...@@ -79,6 +79,8 @@ void difftest_step(vaddr_t pc) {
// TODO: Check the registers state with QEMU. // TODO: Check the registers state with QEMU.
if (!isa_difftest_checkregs(&ref_r, pc)) { if (!isa_difftest_checkregs(&ref_r, pc)) {
extern void isa_reg_display(void);
isa_reg_display();
nemu_state.state = NEMU_ABORT; nemu_state.state = NEMU_ABORT;
nemu_state.halt_pc = pc; nemu_state.halt_pc = pc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册