bochs使用教程[Linux篇]

bochs

bochs x86-64 emulator
安裝
- debian系:
sudo apt install bochs bochs-x
- centos:
sudo yum install bochs
- archlinux :
sudo pacman -S bochs
準備工作
自行尋找一個合適的目錄
在目錄下通過vim新建一個檔案
vim 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 ; 結束標誌
儲存後執行如下命令:
nasm boot.asm -o boot.bin dd if=boot.bin of=a.img dd if=/dev/zero of=a.img seek=1 bs=512 count=2879
通過vim再建立個檔案:
vim bochsrc
貼上如下內容:
############################################################### # Configuration file for Bochs ############################################################### # how much memory the emulated machine will have megs: 32 # filename of ROM images romimage: file=/usr/share/bochs/BIOS-bochs-latest vgaromimage: file=/usr/share/bochs/VGABIOS-elpin-2.40 # what disk images will be used floppya: 1_44=a.img, status=inserted # choose the boot disk. boot: floppy # where do we send log messages? # log: bochsout.txt # disable the mouse mouse: enabled=0 # enable key mapping, using US layout as default. #keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
執行:
在當前目錄下執行
bochs -f bochsrc