NJU NEMU
PA1:
1.返回q值出现的错误:2021 NEMU PA1 RTFSC 优美地退出_LoveAsukaFoever的博客-CSDN博客
将 nemu/src/utils state.c 中的最后!good该为good即可
2.在cmd_c()函数中, 调用cpu_exec()的时候传入了参数-1, 你知道这是什么意思吗?:
答:在cpu_exec.c文件中找到了函数 cpu_exec()。
n是无符号整型,所以-1就是无符号最大的数字,那么函数里的for循环可以执行最大次数的循环,从而让cpu处理之后的指令
3.单步执行:nemu/src/monitor/sdb/sdb.c 中加上:
//增加
static int cmd_si(char *args) {int step;if (args == NULL) step = 1;else sscanf(args, "%d", &step);cpu_exec(step);return 0;
}//修改
static struct {const char *name;const char *description;int (*handler) (char *);
} cmd_table [] = {{ "help", "Display informations about all supported commands", cmd_help },{ "c", "Continue the execution of the program", cmd_c },{ "q", "Exit NEMU", cmd_q },{"si","单步执行", cmd_si},/* TODO: Add more commands */};
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
