win7 下 bochs 运行 Hello World OS

安装 bochs,dd for windows(dd for windows 是 Linux 下 dd 命令的 Windows ,可以做磁盘的块传输,例如将映像文件写入到磁盘或者U盘中。),nasm,并将安装目录加入到环境变量中。

用 bochs 中 bximage.exe 创建新的 img 文件

编写 Hello.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 ; 填充剩下的空间,使生成的二进制代码恰好为 
	dw 0xaa55 ; 结束标志

在 cmd 下输入 nasm Hello.asm -o Hello.bin,生成 Hello.bin。

将 Hello.bin 和 Hello.img 放在一个目录下,在 cmd 中使用指令dd if=Hello.bin of=Hello.img bs=512 count=1

配置 bochsrc.txt(没有的话,新建一个),输入

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

#filename of ROM images
romimage:file=BIOS-bochs-latest,address=Oxf0000
vgaromimage:file=VGABIOS-elpin-2.40

#what disk images will be used
floppya:1_44=Hello.img,status=inserted

#Choose the boot disk
boot:a

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


最后输入 bochs -q -f bochsrc.txt

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值