Aoysme

十分钟操作系统代码boot.asm如下编译执行过程如下

	org	07c00h			; 告诉编译器程序加载到7c00处
	mov	ax, cs			;
	mov	ds, ax			;
	mov	es, ax
	call	DispStr		; 调用显示字符串例程
	jmp	$			    ; 无限循环
DispStr:
	mov	ax, BootMessage
	mov	bp, ax			; ES:BP = 串地址
	mov	cx, 16			; CX = 串长度
	mov	ax, 01301h		; AH = 13,  AL = 01h
	mov	bx, 000ch		; 页号为0(BH = 0) 黑底红字(BL = 0Ch,高亮)
	mov	dl, 0
	int	10h			    ; 10h 号中断
	ret
BootMessage:		db	"Hello, OS world!"
times 	510-($-$$)	db	0	; 填充剩下的空间,使生成的二进制代码恰好为512字节
dw 	0xaa55				    ; 结束标志

a.编译boot.asm

   nasm boot.asm –o boot.bin

b.创建虚拟软盘

   >输入命令bximage(bochs自带),创建名为1.44M的a.img的虚拟软盘

c.将引导扇区boot.bin写入a.img

   dd if=boot.bn of=a.img bs=512 count=1 conv=notrunc

d.修改bochsrc文件(bochs2.4.5需要修改)

# filename of ROM images
romimage: file=/usr/share/bochs/BIOS-bochs-latest
vgaromimage: /usr/share/vgabios/vgabios.bin

# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map

修改为:

# filename of ROM images
romimage: file=$BXSHARE/BIOS-bochs-latest
vgaromimage: file= $BXSHARE/VGABIOS-lgpl-latest

# enable key mapping, using US layout as default.
keyboard_mapping: enabled=1, map=$BXSHARE/keymaps/x11-pc-us.map

 

   e.将a.img和bochsrc放在相同目录,进入此目录,输入bochs即可

   f.因为安装bochs时选择的编译安装时debug模式,所以运行后出现bochs窗口黑乎乎的一片,

     这是你需要到终端窗口输入c,按回车即可执行

分类:

技术点:

相关文章:

  • 2021-06-18
  • 2021-12-12
  • 2021-11-27
  • 2021-12-12
  • 2021-04-03
  • 2021-07-09
  • 2021-12-05
猜你喜欢
  • 2021-05-01
  • 2021-12-10
  • 2021-10-16
  • 2020-05-06
  • 2021-09-12
  • 2021-09-28
  • 2021-11-17
相关资源
相似解决方案