輸入優惠碼現折100元
首頁 / CompScience / Programming / Languages / 組合語言 / Bochs is really slick

Bochs is really slick

說起Bochs這個PC模擬器真的是要好好推薦使用,前幾天已經將30天打造OS!作業系統自作入門還回去了,還在想沒有書要怎麼玩下去,就隨意在Google搜尋ORG  0x7c00這個用法,找到了The booting processGregor Brunmar推薦三個工具:

  • For : 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給我一個靈感,因為裡面有這樣一個指令碼:

———- bochsrc-dos.bxrc ———-
# 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/-2.4/BIOS--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 ———-

floppya: 1_44=d:/os/Dos6.22.img, status=inserted這一行不就是模擬DOS 6.22磁片的開機嗎?突然No boot with the USB就有了一個新的嘗試想法,那個helloos.img是不是也可以這樣用?
所以我稍微改了一下這個指令碼:
———- bochsrc-dos.bxrc ———-
# 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.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,不過我課本還回去了,只有程式碼,也忘記如何編譯了,下次再把編譯的方法抄回來好了!

Print Friendly, PDF & Email
馬上成為工作達人的Fans

About ㄚ琪

工作達人Fun Taiwan的創辦者及總編,可以在這裡更認識他。

發表迴響

你的電子郵件位址並不會被公開。 Required fields are marked *

*

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料

Scroll To Top