《30天自制操作系统》harib09c的编译和调试

9 篇文章 0 订阅

今天是《30天自制操作系统》学习的第12天,今天的工程目录是harib09c,我起的目录名称是day12_boyC,我们一起来调试一下。
day12_boyC目录下直接运行make命令就开始编译了,如下图所示:
make编译harib09c项目,出错
编译的结果如下(部分截取):

E:\techdoc\30dayOS\code\tolset\day12_boyC>make

E:\techdoc\30dayOS\code\tolset\day12_boyC>..\z_tools\make.exe
../z_tools/make.exe -r img
make.exe[1]: Entering directory `E:/techdoc/30dayOS/code/tolset/day12_boyC'
......
//部分正常结果省略
......
../z_tools/gas2nask.exe -a sheet.gas sheet.nas
../z_tools/nask.exe sheet.nas sheet.obj sheet.lst
../z_tools/cc1.exe -I../z_tools/haribote/ -Os -Wall -quiet -o timer.gas timer.c
timer.c: In function `inthandler20':
timer.c:22: structure has no member named `out'
timer.c:24: warning: passing arg 1 of `fifo8_put' from incompatible pointer type
timer.c: At top level:
timer.c:30: warning: `struct FIFO08' declared inside parameter list
timer.c:30: warning: its scope is only this definition or declaration, which is probably not what you want
timer.c: In function `settimer':
timer.c:35: warning: assignment from incompatible pointer type
make.exe[2]: *** [timer.gas] Error 1
rm graphic.gas graphic.nas dsctbl.gas dsctbl.nas memory.gas memory.nas sheet.gas sheet.nas mouse.gas mouse.nas timer.gas bootpack.gas int.gas fifo.gas int.nas fifo.nas keyboard.gas keyboard.nas
make.exe[2]: Leaving directory `E:/techdoc/30dayOS/code/tolset/day12_boyC'
make.exe[1]: *** [img] Error 2
make.exe[1]: Leaving directory `E:/techdoc/30dayOS/code/tolset/day12_boyC'
..\z_tools\make.exe: *** [default] Error 2

E:\techdoc\30dayOS\code\tolset\day12_boyC>

有一些错误发生,我们仔细查看一下:

timer.c:22: structure has no member named `out'

上面的提示是说:timer.c文件的第22行,结构体没有名称是out的成员。
打开timer.c文件,查看第22行的代码:

	if(timerctl.timeout > 0){
		timerctl.out--;
		if(timerctl.timeout <= 0 ){
			fifo8_put(timerctl.fifo, timerctl.data);
		}
	}

原来是结构体成员写错了,把out修改成timeout就好了。
修改错误代码
再把后面提示的错误逐一修改过来,重新编译,报错都消失了,如下图所示:
make编译harib09c项目OK

【友情提醒】有的时候报错比较多,其实好些都是前面某个错误的连带错误,把前面的错误改掉了,后面的一些错误提示就自动消失了。所以,从前到后,逐一改错,随时编译,是个不错的调试方法。

使用make run命令,运行day12_boyC正常,10秒过后,qemu模拟器的屏幕上出现了"10[sec]"提示信息。运行结果如下图所示:
运行harib09c项目,OK
【最后说一下】day12_boyC初次运行时,并没有出现"10[sec]"提示信息,经过仔细比对光盘代码,发现是我的代码出了问题。敲(抄)代码的过程中多注意细节,川合秀实老师在《30天自制操作系统》一书中把代码差异列举的还是比较详尽,运行结果和书中不一样的话,记得及时去比对代码,光盘中每一天学习目录中的代码是最完善的。
错误代码:

E:\techdoc\30dayOS\code\tolset\day12_boyC\bootpack.c
		//没有做timerfifo的状态判断,所以运行不正确。
		if(fifo8_status(&keyfifo) + fifo8_status(&mousefifo) == 0){
			io_sti();//不做hlt
		}

正确代码:

		if(fifo8_status(&keyfifo) + fifo8_status(&mousefifo) + fifo8_status(&timerfifo) == 0){ 
			io_sti();//不做hlt
		}else{

(全文完)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ycjnx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值