说起Bochs这个PC模拟器真的是要好好推荐使用,前几天已经将30天打造OS!作业系统自作入门还回去了,还在想没有书要怎么玩下去,就随意在Google搜寻ORG 0x7c00这个用法,找到了The booting process,Gregor Brunmar推荐三个工具:
- For assembly: Nasm
- For C-code: Gcc (I use Djgpp, but that’s because I do my work on the Win32-platform, although, everything should work on any platform)
- For PC-emulation: Bochs (You don’t want to reboot every time you want to test something)
其中这个Bochs PC模拟器是我没用过的,所以就下载来玩玩看,随后就在想能不能模拟USB开机啊,后来试了一个早上,感觉是没有支援,不然就是我不知道如何操作!
正准备放弃时,骨仔的这一篇DOS in Bochs给我一个灵感,因为里面有这样一个指令码:
# how much memory the emulated machine will have
# if you have less than 64MB of memory in your actuall computer, set this lower(16 is good)
megs: 32
# filename of ROM images
# note that if before a filename we put “../” then the file is looked
# for in the directory above that the current directory(the one the configuration
# file is in).
romimage: file=”C:/Program Files/Bochs-2.4/BIOS-bochs-latest”
vgaromimage: file=”C:/Program Files/Bochs-2.4/VGABIOS-elpin-2.40″
# we want a floppy drive(called a), the disk image that we are using is called “1.44”
floppya: 1_44=d:/os/Dos6.22.img, status=inserted
ata0-master: type=disk, path=d:/os/c.img, mode=flat, cylinders=20, heads=16, spt=63
# choose the boot disk.
boot: a
# disable the mouse unless your OS uses it
mouse: enabled=0
———- bochsrc-dos.bxrc ———-
# if you have less than 64MB of memory in your actuall computer, set this lower(16 is good)
megs: 32
# filename of ROM images
# note that if before a filename we put “../” then the file is looked
# for in the directory above that the current directory(the one the configuration
# file is in).
romimage: file=”C:/Program Files/Bochs-2.4.5/BIOS-bochs-latest”
vgaromimage: file=”C:/Program Files/Bochs-2.4.5/VGABIOS-elpin-2.40″
# we want a floppy drive(called a), the disk image that we are using is called “1.44”
floppya: 1_44=d:/os/helloos.img, status=inserted
ata0-master: type=disk, path=d:/os/c.img, mode=flat, cylinders=20, heads=16, spt=63
# choose the boot disk.
boot: a
# disable the mouse unless your OS uses it
mouse: enabled=0———- bochsrc-dos.bxrc ———-
没错hello world!回来了,看来课本里的内容跟程式可以不用再转换到USB开机玩了,直接用这个pC模拟器玩不是很方便吗?太cool,不过我课本还回去了,只有程式码,也忘记如何编译了,下次再把编译的方法抄回来好了!