您的位置:首页 > 其它

win7 下 bochs 运行 Hello World OS

2015-12-05 18:56 302 查看
安装 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



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: