diff --git a/nemu/src/monitor/diff-test/diff-test.cc b/nemu/src/monitor/diff-test/diff-test.cc index 2c290440e513df56d1388e2083dbcef382c4aa2e..75ebdc076f4ed3cc2868ac15d710330ee9a0d6f0 100644 --- a/nemu/src/monitor/diff-test/diff-test.cc +++ b/nemu/src/monitor/diff-test/diff-test.cc @@ -69,7 +69,22 @@ void difftest_step(uint32_t eip) { ref_difftest_exec(1); ref_difftest_getregs(&ref_r); - // TODO: Check the registers state with the reference design. + // Check the registers state with the reference design. // Set `nemu_state` to `NEMU_ABORT` if they are not the same. - TODO(); + #define RLIB_IMPL_REG_DIFF(which) (ref_r.which xor cpu.which) + if( + RLIB_IMPL_REG_DIFF(eax) or + RLIB_IMPL_REG_DIFF(ecx) or + RLIB_IMPL_REG_DIFF(edx) or + RLIB_IMPL_REG_DIFF(ebx) or + RLIB_IMPL_REG_DIFF(esp) or + RLIB_IMPL_REG_DIFF(ebp) or + RLIB_IMPL_REG_DIFF(esi) or + RLIB_IMPL_REG_DIFF(edi) or + RLIB_IMPL_REG_DIFF(eip) or + true + ) { + nemu_state = NEMU_ABORT; + } + #undef RLIB_IMPL_REG_DIFF }