首页 > 代码库 > Orange's笔记(1)

Orange's笔记(1)

第一章

写一个小的引导程序 代码:

 1     org    07c00h 2     mov    ax,cs 3     mov    ds,ax 4     mov     es,ax 5     call     DispStr 6     jmp    $ 7 DispStr: 8     mov    ax,BootMessage 9     mov    bp,ax10     mov    cx,1611     mov    ax,01301h12     mov    bx,000ch13     mov    dl,014     int    10h15     ret16 BootMessage:    db    "Hello, OS World!"17 times    510-($-$$)    db    018 dw    0xaa55

用NASM编译

nasm boot.asm -o boot.bin

安装 bochs

安装环境 :

sudo apt-get install build-essential xorg-dev libgtk2.0-dev

 

在官网下载最新版本 然后安装

 

./configure --enable-debugger --enable-disasmmakesudo make install

make的时候提示

/usr/bin/ld: gui/libgui.a(gtk_enh_dbg_osdep.o): undefined reference to symbol pthread_create@@GLIBC_2.1//lib/i386-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command linecollect2: error: ld returned 1 exit statusmake: *** [bochs] 错误 1

解决方法

在makefile的libs中添加如下内容 :

-lz -lrt -lm -lpthread 

利用bximage生成虚拟软盘,将引导扇区写入虚拟软盘:

dd if=boot.bin of=a.img bs=512 conv=notrunc

配置 bochs  然后启动

################################################################ Configuration file for Bochs################################################################ how much memory the emulated machine will have megs: 32# filename of ROM images romimage: file=/usr/local/share/bochs/BIOS-bochs-latest vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest# 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/local/share/bochs/keymaps/sdl-pc-us.map

 

 在新版bochs中无dump_cpu命令。