bochs使用教程[Linux篇]

参考:
在bochs上运行的第一个操作系统
Ubuntu上使用Bochs
界面预览:

《bochs使用教程[Linux篇]》 bochs

《bochs使用教程[Linux篇]》 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
    原文作者:靳一鸣
    原文地址: https://www.jianshu.com/p/742a61ce3e58
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞