在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