一,首先编写boot引导程序的汇编代码:

	org	0x7c00	

BaseOfStack	equ	0x7c00

Label_Start:

	mov	ax,	cs
	mov	ds,	ax
	mov	es,	ax
	mov	ss,	ax
	mov	sp,	BaseOfStack

;=======	clear screen

	mov	ax,	0600h
	mov	bx,	0700h
	mov	cx,	0
	mov	dx,	0184fh
	int	10h

;=======	set focus

	mov	ax,	0200h
	mov	bx,	0000h
	mov	dx,	0000h
	int	10h

;=======	display on screen : Start Booting......

	mov	ax,	1301h
	mov	bx,	000fh
	mov	dx,	0000h
	mov	cx,	10
	push	ax
	mov	ax,	ds
	mov	es,	ax
	pop	ax
	mov	bp,	StartBootMessage
	int	10h

;=======	reset floppy

	xor	ah,	ah
	xor	dl,	dl
	int	13h

	jmp	$

StartBootMessage:	db	"Start Boot"

;=======	fill zero until whole sector

	times	510 - ($ - $$)	db	0
	dw	0xaa55

编译生成.bin(二进制)文件,使用nasm

nasm boot.asm -o boot.bin

二,制作虚拟软盘,使用bochs中的bximage完成

在命令行中输入bximage即可

然后依据提示信息完成软盘的制作。

相关参数:fd or hd   ---> fd   size:1.44M

Boot引导程序

三,将编译好的二进制boot引导文件写入软盘中

dd if=boot.bin of=/home/hjw/Downloads/bochs-2.6.9/boot.img bs=512 count=1 conv=notrunc

其中of后跟boot.img的path,试个人情况而定。

生成的日志如下:

Boot引导程序

四,一切就绪,运行

bochs

Boot引导程序

选择:6

<bochs:1>后输入 c/count/continue,虚拟机便开始执行Boot引导程序了.

Boot引导程序

Boot引导完成,下一步便是加载Loader到内存了.

未完待续

相关文章:

  • 2021-07-23
  • 2021-07-07
  • 2021-12-22
  • 2022-12-23
  • 2021-07-08
  • 2021-12-28
  • 2021-04-20
  • 2021-06-08
猜你喜欢
  • 2022-01-10
  • 2022-01-10
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2021-10-27
  • 2021-10-14
相关资源
相似解决方案