1、安装
指令安装
- sudo apt-get install vgabios bochs bochs-x bximage
源码安装,如果不需要调试功能configure后不用加选项,源码包下载地址
- tar vxzf bochs-xxx.tar.gz
- cd bochs-xxx
- ./configure --enable-debugger --enable-disasm
- make
- make install
2、配置文件
在当前路径下编辑该配置文件bochsrc
############################################################################################
# Configuration file Bochs
############################################################################################# How much memory the emulated will have
# 指定内存大小
megs: 32# filename of ROM images
# ROM镜像,使用时检查一下该目录下有没有对应文件
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest
vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest# What disk images will be used
# 指定A盘软盘
floppya: 1_44=abytec.img, status=inserted# Choose the boot disk
# 选择一个启动盘
boot: floppy# Where do we send log messages?
# 日志发送位置
log: bochsout.log# disable the mouse
# 禁用鼠标
mouse: enabled=0# Enable key mapping, using US layout as default.
# 设置键盘
keyboard: keymap=/usr/local/share/bochs/keymaps/x11-pc-us.map
3、启动
bochs默认在当前路径下寻找.bochsrc、bochsrc、bochsrc.txt作为配置文件。选项-f指定配置文件
- bochs -f bochsrc
选项6开始模拟
4、调试选项
b addr: 在对应地址设置断点。例:b 0x7c00
info break: 显示当前所以断点信息。例:info break
c: 继续下执行,直到遇到断点。例:c
s: 单步执行。例:s
n: 单步执行,遇到函数跳过。例:n
info cpu: 查看寄存器信息。例:info cpu
r: 查看寄存器信息。例:r
fp: 查看寄存器信息。例:fp
sreg: 查看寄存器信息。例:sreg
creg: 查看寄存器信息。例:creg
print-stack: 查看堆栈。例:print-stack
xp /nuf addr: 查看内存物理地址内容。例:xp /64bx 0x7c00
x /nuf addr: 查看线性地址内容。例:x /64bx 0x7c00
u start end: 反汇编一段内存。例:u 0x7c00 0x7c0d
trace-on: 反汇编执行的每一条指令。例:trace-on
trace-reg: 每执行一条指令就显示cpu信息。例:trace-reg
5、创建软盘镜像
- bximage