OrangeS一个操作系统的实现: bochs的使用

1. bximage: 生成磁盘映像

bximage

bximage

2. nasm: 生成.bin文件

	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				; 结束标志
nasm boot.asm -o boot.bin

3. 将引导扇区写进软盘

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

4. 编写bochs配置文件

###############################################################
# Configuration file for Bochs
###############################################################

# how much memory the emulated machine will have
megs: 32

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

# what disk images will be used 
floppya: image="a.img", status=inserted

# choose the boot disk.
boot: floppy

# where do we send log messages?
log: bochsout.txt

# disable the mouse
mouse: enabled=0

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

5. 启动bochs

bochs -f bochsrc

启动bochs
需要特别注意的是, 在启动后, 需要输入c并回车, 否则会显示黑屏

6. 结果展示

启动bochs结果

猜你喜欢

转载自blog.csdn.net/Bat_Reality/article/details/122359474