<aside> 💡 Author: 李纪 Student No.1711342
</aside>
cprintf vs printf
printf,但是后面出现错误 "undefined reference".cprintf,改了之后这句话就通过编译了.下面的这段代码为什么是 “+2”?

(在我的代码里)经过强制类型转换 (uint32_t*)ebp 后,“+2” 相当于往上 2 * 4 = 8 个字节,因为指针的大小都为 4B。现在 ebp 上方 8 个字节后,正好是开始存储 args 的地方。(可参考下图)

一开始我的 for 循环如下,但是编译时提示报错,因为 MOOCOS 里的 GCC 默认使用 C99 标准编译。
for(int i = 0; i < 4; ++i) {*stmt*}

for 循环报错图
/* Gate descriptors for interrupts and traps */
struct gatedesc {
unsigned gd_off_15_0 : 16; // low 16 bits of offset in segment
unsigned gd_ss : 16; // segment selector
unsigned gd_args : 5; // # args, 0 for interrupt/trap gates
unsigned gd_rsv1 : 3; // reserved(should be zero I guess)
unsigned gd_type : 4; // type(STS_{TG,IG32,TG32})
unsigned gd_s : 1; // must be 0 (system)
unsigned gd_dpl : 2; // descriptor(meaning new) privilege level
unsigned gd_p : 1; // Present
unsigned gd_off_31_16 : 16; // high bits of offset in segment
};
Visual Studio 在本地打开项目文件夹,然后就会发现很多优秀的功能能帮到你。(比如 速览定义,转到定义,查找所有引用,鼠标悬停查看函数形参 等等一系列友好操作)Copy of 练习 1:理解通过 make 生成执行文件的过程。
Copy of 练习 2:使用 qemu 执行并调试 lab1 中的软件