大佬教程收集整理的这篇文章主要介绍了linux – 自定义操作系统的引导加载程序没有跳转到内核的麻烦,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
由于软盘是开发操作系统的最简单的存储介质,我购买了3.5英寸软盘驱动器.
我使用NASM作为汇编编译器,qemu作为模拟器.
使用dd命令,我将一个现有的和空的(就文件而言)软盘克隆到一个名为floppy.img.bak的文件中.
之后,我在x86程序集中编写了一个简单的bootloader:
bootloader.asm
org 7C00h jmp 0x0000:start ;go msg db 'Loading Kernel...',0 start: ;update the segment registers mov ax,cs mov ds,ax mov es,ax mov si,msg print: ;prints a String lodsb ;load next char cmp al,0 ;if null terminator... je reset ;...jump to reset: mov ah,0Eh ;print aL mov bx,7 int 10h jmp print ;if not null terminator,conTinue prinTing reset: ;resets the floppy drive mov ax,0 ; mov dl,0 ;drive=0 (=A) int 13h ; jc reset ;if error resetTing,reset again read: mov ax,1000h ;ES:BX = 1000:000 mov es,ax ;es is 1000h Now mov bx,0 ;bx is 0 Now mov ah,2 ;load disk data into ES:BX mov al,1 ;load 1 sector mov ch,0 ;cylinder=0 mov cl,2 ;sector=2 mov dh,0 ;head=0 mov dl,0 ;drive=0 int 13h ;read! jc read ;if error then try again jmp 1000h:0000;jump to the program times 510-($-$$) db 0 dw 0AA55h
到现在为止还挺好.
我的简单临时存根内核如下:
kernel.asm
kstart: mov ah,9 mov al,'k' mov bx,7 mov cx,5 int 10h hang: jmp hang times 510-($-$$)+2 db 0
compile-and-run.sh
cd ~/Dev/OS # cd to here rm asm-bin/bootloader.bin # remove old compiled bootloader rm asm-bin/kernel.bin # remove old compiled kernel nasm asm-src/bootloader.asm -f bin -o asm-bin/bootloader.bin # compile bootloader nasm asm-src/kernel.asm -f bin -o asm-bin/kernel.bin # compile kernel rm images/floppy.img # remove old floppy image cp images/floppy.img.bak images/floppy.img # copy original floppy image to fresh one dd if=asm-bin/bootloader.bin of=images/floppy.img bs=512 count=1 seek=0 # write bootloader to first sector dd if=asm-bin/kernel.bin of=images/floppy.img bs=512 count=1 seek=1 # write kernel to second sector qemu-system-i386 images/floppy.img # start qemu and boot floppy.img
现在,qemu的预期输出将是(至少我理解的):
Loading Kernel... kkkkk
但相反,它是:
Loading Kernel...
所以,显然,跳跃有些不对劲,我只是不知道是什么.
也许你可以帮助我?我会很感激.
以上是大佬教程为你收集整理的linux – 自定义操作系统的引导加载程序没有跳转到内核的麻烦全部内容,希望文章能够帮你解决linux – 自定义操作系统的引导加载程序没有跳转到内核的麻烦所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。