30天自制操作系统-Hello OS

0.准备

  • 代码使用的书本中的,使用8G的fat32格式u盘 ,不过对于Hello OS程序来言,开头的文件格式不需要也可以,只不过调用bios的输出字符函数(int 0x10)。并未读取u盘内的数据。
  • fat32文件格式的书写,可以使用winhex工具,先点击工具->打开磁盘->选择你的u盘。然后再查看->模板管理器->选择Boot Sector FAT32->应用。得到u盘fat32文件格式,里面的一些具体项可以百度得到,这里提供一篇博客写得比较详细的:

FAT32文件系统学习(1) —— BPB的理解

1. helloOS的代码:

; haribote-ipl
; TAB=4

		ORG		0x7c00

		JMP	short	entry
		nop
		DB		'MSDOS5.0'	
		DW		512	
		DB 		8
		DW		36
		DB		2
		DW		0
		DW		0
		db 		0xf8
		dw		0
		dw		63
		dw		255
		dd		1	
		dd		15727634
		dd 		15330	
		dw		0
		dw		0
		dd		2
		dw		1
		dw		6
		times	12	db 0
		db		80h
		db		0
		db		29h
		dd		18467
		DB		"NO NAME    "	
		DB		"FAT32   "
entry:
		MOV		AX,0			
		MOV		SS,AX
		MOV		ES, AX
		MOV		SP,0x7c00
		MOV		DS,AX


		MOV		SI,msg
		call 		putloop
		jmp		fin
putloop:
		MOV		AL,[SI]
		ADD		SI,1			
		CMP		AL,0
		JE		over	
		MOV		AH,0x0e			
		MOV		BX,15			
		INT		0x10			
		JMP		putloop
over:
		ret
fin:
		HLT					
		JMP		fin	
msg:
		DB		0x0a, 0x0a	
		DB		"hello os"
		DB		0x0a			
		DB		0

;		RESB		0x7dfe-$		
		times 		510 - ($ - $$) db 0
		DB		0x55, 0xaa

再windows上用nasm工具生成ipl10.bin

nasm ipl10.nas -o ipl10.bin

可以使用winhex查看生成的二进制信息:

使用dd工具将ipl10.bin写入u盘,百度搜索dd for windows即可下载。

首先获得u盘在windows下的信息,如下图:

图中的removeable to media就是我的u盘了

然后使用命令将ipl10.bin写入u盘,重启F12(我的笔记本电脑,每个人的电脑都不一样)选择u盘启动

dd if=helloOS\ipl10.bin of=\\.\Volume{19572513-924e-11e8-afeb-806e6f6e6963}

2. 结果

猜你喜欢

转载自blog.csdn.net/zkj126521/article/details/81606204