在bochs上啟動並執行第一個作業系統(Windows版)

來源:互聯網
上載者:User
在windows上運行息的作業系統的步驟:.asm->.bim->.img->載入和運行

一、製作img鏡像檔案

方法一:

1.使用bochs內建的工具bximage.exe產生一個.img檔案,產生的是一個全0的空檔案,需要往裡面寫入內容

2.建立自己的引導程式boot.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 ; 結束標誌

3.使用nasm boot.asm -o boot.bin命令進行反組譯碼,得到一個512B的.bin檔案

4.使用UltraEdit分別開啟boot.bin和boot.img,把boot.bin複製到boot.img的前512B中,boot.img製作完成

方法二

1.運行WinImage,選擇Options -> Setting -> Image ,設定Compression為None

2.File -> New, 選擇容量是1.44MB的格式

3.Image -> Boot Sector properties -> MS-DOS

4.儲存檔案,類型為All files(*.*)

5.用UltraEdit開啟boot.img,保留EB 3C 90 4D開頭、55 AA結尾的資料,大小剛好為512B,其餘的刪去

二、製作bochs配製檔案,假設新作業系統的檔案夾位置是D:\Program Files\Bochs-2.5.1,檔案夾名是floppy

方法一:

設定檔:bochsrc.txt

#how much memory the emulated machine will havemegs:4#filename of ROM imagesromimage:file=../BIOS-bochs-latest,address=Oxf0000vgaromimage:file=../VGABIOS-elpin-2.40#what disk images will be usedfloppya:1_44=boot.img,status=inserted#Choose the boot diskboot:a#where do we send log messages?log:bochsout.txt

執行檔案run.bat

cd "d:\Program Files\Bochs-2.5.1\floppy"..\bochs -q -f bochsrc.txt

方法二:

設定檔:bochsrc.txt

#how much memory the emulated machine will havemegs:4#filename of ROM imagesromimage:file=$BXSHARE/BIOS-bochs-latest,address=Oxf0000#vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latestvgaromimage: file=$BXSHARE/VGABIOS-elpin-2.40#what disk images will be usedfloppya:1_44=boot.img,status=inserted#Choose the boot diskboot:a#where do we send log messages?log:bochsout.txt

執行檔案:run.bat

SET BXSHARE=d:\Program Files\Bochs-2.5.1..\bochs -q -f bochsrc.txt

三、運行run.bat

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.