ubuntu平台下安装bochs,直接命令sudo apt-get install bochs即可,但是默认安装没有启动调试.

我采用的手动安装,可以选择打开调试功能.

1.官网下载bochs包。

tar xvzf bochs-2.4.5.tar.gz

cd bochs-2.4.5

./configure --enable-debugger --enable-disasm                 

make 

sudo make install

备注:书上反汇编命令是disasm,但我实际操作的时候发现是ndisasm,不知道enable的时候disasm这个命令对不对

 

2.安装nasm

sudo apt-get install nasm

 

3.安装vi编辑器

sudo apt-get install vim

这样工作环境就算搭建完了

 

然后开始写一个最小的操作系统,体验下bochs

1.boot文件写法

vi boot.asm

  org 07c00h      ;tell nasm address

  mov ax, cs

  mov ds, ax

  mov es, ax

  call    DispStr      ;call string process

  jmp  $

DispStr:

  mov  ax, BootMessage

  mov  bp, ax       ;ES:BP =str address 

  mov  cx, 16       ;cx=string length

  mov  ax, 01301h   ;ah=13,al=01h

  mov  bx, 000ch   ;page num(bh)=0 bl=0ch,highlight

  mov  dl, 0

  int 10h          ;interruptret

      ret

BootMessage:  db  "Hello, OS world!"  

times  510-($-$$)   db  0  ;full other space

dw  0xaa55        ;end

保存退出

nasm boot.asm -o boot.bin    命令行生成bin文件

 

2.bochsrc文件写法

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

log:bochsout.txt

mouse: enabled=0

keyboard_mapping: enabled=1, map=/usr/local/share/bochs/keymaps/x11-pc-us.map

保存退出

 

3.用bximage生成一个a.img镜像文件

bximage    按提示来就行

 

4.进入目录

bochs -f bochsrc

c

行了!

下一篇(从实模式向保护模式跳转)

posted on 2010-11-27 15:45  sunt615  阅读(3530)  评论(0编辑  收藏  举报