bochs使用教程[Linux篇]

參考:
在bochs上運行的第一個操作系統
Ubuntu上使用Bochs
界面預覽:


安裝

  • 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章