为了学习《Orange's 一个操作系统的实现》,先要准备好环境。
准备工作,安装bochs依赖的软件:
sudo apt-get install build-essential
sudo apt-get install xorg-dev
sudo apt-get install bison
1. 下载安装包 bochs-2.4.5.tar.gz
2. 解压 tar vxzf bochs-2.4.5.tar.gz
3. 配置 ./configure --enable-debugger --enable-disasm --with-nogui
4. 编译 make
5. cp bochs bochsdbg
避免安装时错误
6. 真正开始安装 sudo make install
7. 创建快捷方式 sudo ln -s /usr/local/bin/bochs /usr/bin/bochs
好了,安装完毕,写一个简单的bochsrc配置文件,然后启动bochs,
看是否能调试boot.asm
~/Study/boot.asm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
org 07c00h mov ax, cs mov ds, ax mov es, ax call DispStr jmp $ DispStr: mov ax, BootMessage mov bp, ax mov cx, 16 mov ax, 01301h mov bx, 000ch mov dl, 0 int 10h ret BootMessage: db "Hello OS World!" times 510 - ($-$$) db 0 dw 0xaa55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
user1: ~/Study/: nasm boot.asm -o boot.com
user1: ~/Study/: dd if=boot.bin of=b.img bs=512 count=2880 conv=notrunc
user1: ~/Study/: vi bochsrc
megs: 32 romimage:file=/usr/local/share/bochs/BIOS-bochs-latest vgaromimage:file=/usr/share/vgabios/vgabios.bin floppya: 1_44=a.img, status=inserted boot: floppy
保存 :wq
user1: ~/Study/: bochs
运行bochs,出现 <bochs:1>,具有调试功能的bochs已经启动!