lab1

发布时间 2023-06-11 17:29:50作者: QianFa01

Part 1 :PC Bootstrap

exercise1

exercise2

Part2 : The Boot Loader

exercise3

exercise4

exercise5

exercise6

Part3 : The Kernel

exercise7

movl %eax, %cr0

exercise8

case 'o':
		// Replace this with your code.
		num = getuint(&ap,lflag);
		base = 8;
		goto number;

注意这儿是无符号八进制的写法;有符号的写法为:

case 'o':
	num = getint(&ap, lflag);
	if ((long long) num < 0) {
		putch('-', putdat);
		num = -(long long) num;
	}
	base = 10;
	goto number;

说明:对于该exercise下的6个问题,前三个方法:先在kern/printf.c文件下的vcprintf函数处打一个断点,接着在kern/monitor.c文件中的mon_backtrace函数打一个断点,执行,使用bt查看栈使用情况;x/s fmt ; x/3wx [ap的地址];
可以发现,对于可变参数的cprintf函数:可变参数先入栈,格式串后入栈,对应于第六个问题;
对于va_arg函数,参考:
https://learn.microsoft.com/zh-cn/cpp/c-runtime-library/reference/va-arg-va-copy-va-end-va-start?view=msvc-170

exercise9

mov    $0xf0110000,%esp
#define KSTKSIZE	(8*PGSIZE)  

区间为: 0xf0107000 - 0xf0110000

exercise10

1、%esp = 0xf010ffe0; %ebp = 0xf010fff8
call之前,%esp = 0xf010ffd0; %ebp = 0xf010ffd8
五次调用之后 %esp = 0xf010ff30; %ebp = 0xf010ffd8
结束调用与文档不同

exercise11

exercise12

stab表用于存储源文件以及编译后文件对应关系的一张表。
函数stab_binsearch,是找到对应类型的条目,并打印出来;