目录:
软件和工具下载
Bochs虚拟机配置文件
Hello World编辑编译
1. 软件和工具下载
Bochs虚拟机下载安装
下载地址:
http://download.pchome.net/system/sysenhance/down-19486.html
dd for windows下载安装
下载地址:
http://www.downxia.com/downinfo/17093.html
nasm for windows下载安装
下载地址:
http://download.csdn.net/detail/linux801/510317
nasm和dd可以自己下载,也可以用我已经下载好的.
附件system不仅包含了nasm和dd工具还包含了最简单的在Bochs虚拟机中运行的hello world程序.
2. Bochs虚拟机配置文件
配置文件也已经放在附件system中,从注释里不难看出我也是根据已有的配置文件作为模版进行修改的.
需要注意以下几点:
(1) floppya: 1.44=./src/a.img, status=inserted
(2) boot: floppy
这里将floppy作为系统的启动介质,在floppy上我们烧录了a.img,也就是说当你双击bochsrc运行bochs虚拟机时,Bochs就会自动的从执行a.img
############################################################### # bochsrc.txt file for DLX Linux disk image. ############################################################### # how much memory the emulated machine will have megs: 32 # filename of ROM images romimage: file=./BIOS-bochs-latest vgaromimage: file=./VGABIOS-lgpl-latest # what disk images will be used floppya: 1_44=./src/a.img, status=inserted #floppyb: 1_44=floppyb.img, status=inserted # hard disk ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 #ata0-master: type=disk, path="hd10meg.img", cylinders=306, heads=4, spt=17 # choose the boot disk. boot: floppy # default config interface is textconfig. #config_interface: textconfig #config_interface: wx #display_library: x # other choices: win32 sdl wx carbon amigaos beos macintosh nogui rfb term svga # where do we send log messages? log: bochsout.txt # disable the mouse, since DLX is text only mouse: enabled=0 # set up IPS value and clock sync cpu: ips=15000000 clock: sync=both # enable key mapping, using US layout as default. # # NOTE: In Bochs 1.4, keyboard mapping is only 100% implemented on X windows. # However, the key mapping tables are used in the paste function, so # in the DLX Linux example I'm enabling keyboard_mapping so that paste # will work. Cut&Paste is currently implemented on win32 and X windows only. keyboard: keymap=./keymaps/x11-pc-us.map #keyboard: keymap=../keymaps/x11-pc-fr.map #keyboard: keymap=../keymaps/x11-pc-de.map #keyboard: keymap=../keymaps/x11-pc-es.map
3. Hello World编辑编译
(1) 代码
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!" times510-($-$$)db 0 dw0xaa55
(2) 编译和制作floppy image
我是在source insight 3.5中进行编辑和编译的.
如何在source insight 3.5中进行编译呢?在Options->Custom Commands中添加命令
nasm编译源代码:
F:\自己动手写操作系统\Software\nasm-2.03.01\nasm %f -o boot.bin
dd制作floppy image
F:\自己动手写操作系统\Software\dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
还有一些小技巧,可以将OS_Build和OS_Image放到菜单中或者跟快捷键相关联,这样可以将更多的时间放在系统上,减少很多其它开销.读者可以自己去添加.作为开发者对开发工具的使用也是一项技能