說起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,不過我課本還回去了,只有程式碼,也忘記如何編譯了,下次再把編譯的方法抄回來好了!