编译命令
./configure --prefix=‘/usr/local/bochs2.7’ --enable-debugger --enable-disasm --enable-iodebug --enable-x86-debugger --with-x --with-x11
make
sudo make install
配置文件
bochsrc
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1
config_interface: textconfig
#display_library: x, options="gui_debug"
display_library: xmemory: host=32, guest=32
#文件在安装目录下
romimage: file="/usr/local/bochs/share/bochs/BIOS-bochs-latest"
vgaromimage: file="/usr/local/bochs/share/bochs/VGABIOS-lgpl-latest"
#硬盘启动
boot: disk
floppy_bootsig_check: disabled=1
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
#硬盘参数,使用bximage查看C/H/S
ata0-master: type=disk, mode=vpc, translation=auto, path="/home/Sun/Desktop/virtualbox/Other.vhd", cylinders=1003, heads=12, spt=17, biosdetect=auto, model="Generic 1234"
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0
ata3: enabled=0
pci: enabled=0
vga: extension=vbe, update_freq=5
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: family=6, model=0x03, stepping=3, mmx=1, apic=xapic, sse=sse2, sse4a=0, sep=1, aes=0, xsave=0, xsaveopt=0, movbe=0, adx=0, smep=0, mwait=1
cpuid: vendor_string="GenuineIntel"
cpuid: brand_string=" Intel(R) Pentium(R) 4 CPU "print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
keyboard: type=mf, serial_delay=250, paste_delay=100000, keymap=
user_shortcut: keys=none
mouse: enabled=0, type=ps2, toggle=ctrl+mbutton
parport1: enabled=1, file=""
parport2: enabled=0
com1: enabled=1, mode=null, dev=""
com2: enabled=0
com3: enabled=0
com4: enabled=0
引导扇区
start:mov ax,0xb800
mov ds,ax
mov byte [0],'a'
mov byte [1],02h
jmp $
times 510-($-$$) db 0
db 0x55,0xaa
引导扇区写入脚本附启动vritualbox
#run
#!/usr/bin/bash
VBoxManage controlvm "asm" poweroff
nasm -f bin ./test.asm -o test
dd if=test of=Other.vhd bs=512 count=1 conv=notrunc
hexdump -C Other.vhd | head -10
bash ./start > /dev/null 2>&1
echo "-------- start successfully ---------"
#start
#!/usr/bin/bash
while true
do sleep 0.3 if VBoxManage startvm "asm" | grep -q "successfully" then break fi
done