Chapter 1
Write a small Bootstrap code:
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
Compile with NASM
nasm boot.asm -o boot.bin
Install bochs
Installation environment:
sudo apt-get install build-essential xorg-dev libgtk2.0-dev
Download and install the latest version from the official website.
./configure --enable-debugger --enable-disasmmakesudo make install
Prompt when making
/Usr/bin/ld: Gui/libgui. A (gtk_enh_dbg_osdep.o): Undefined reference to symbol' [email protected] @ 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] Error 1
Solution
Add the following content to libs of makefile:
-lz -lrt -lm -lpthread
Use bximage to generate a virtual floppy disk and write the Boot Sector to the virtual floppy disk:
dd if=boot.bin of=a.img bs=512 conv=notrunc
Configure bochs and then start
################################################################ 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
The dump_cpu command is not available in the new bochs.