VirtualBox下载

    Ubuntu 20.04下载

    bochs-2.6.10

    共享文件夹: 开发环境搭建 - 图1

    挂载文件夹:

    1. mount -t vboxsf Share /mnt/myShare
    2. # 自动挂载 /etc/fstab文件中添加一行代码
    3. Share /mnt/myShare vboxsf rw,gid=100,uid=1000,auto 0 0
    1. ./configure \
    2. --prefix=/usr/local/bochs \
    3. --enable-debugger \
    4. --enable-disasm \
    5. --enable-iodebug \
    6. --enable-x86-debugger \
    7. --with-x \
    8. --with-x11
    1. apt install fluxbox xinit xterm
    1. sudo apt install vim
    2. sudo apt install build-essential
    3. sudo apt install xorg-dev
    4. sudo apt install libgtk2.0-dev
    5. sudo apt install g++

    修改配置:allowed_users = anybody

    sudo vi /etc/X11/Xwrapper.config

    bochsrc.disk内容:

    1. megs : 32
    2. romimage: file=/usr/local/bochs/share/bochs/BIOS-bochs-latest
    3. vgaromimage: file=/usr/local/bochs/share/bochs/VGABIOS-lgpl-latest
    4. boot: disk
    5. log: bochs.out
    6. mouse:enabled=0
    7. keyboard:keymap=/usr/local/bochs/share/bochs/keymaps/x11-pc-us.map
    8. ata0:enabled=1,ioaddr1=0x1f0,ioaddr2=0x3f0,irq=14
    9. ata0-master: type=disk, path="/usr/local/bochs/bin/hd60M.img", mode=flat,cylinders=121,heads=16,spt=63
    10. #gdbstub:enabled=1,port=1234,text_base=0,data_base=0,bss_base=0
    1. nasm -o boot.bin boot.asm
    2. dd if=boot.bin of=hd60M.img bs=512 count=1 conv=notrunc

    测试代码:

    1. org 07c00h ; 告诉编译器程序加载到 7c00
    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, ax ; ES:BP = 串地址
    10. mov cx, 16 ; CX = 串长度
    11. mov ax, 01301h ; AH = 13, AL = 01h
    12. mov bx, 000ch ; 页号为 0(BH = 0) 黑底红字(BL = 0Ch, 高亮)
    13. mov dl, 0
    14. int 10h ; 10h 号中断
    15. ret
    16. BootMessage: db "Hello, OS world!"
    17. times 510-($-$$) db 0 ; 填充剩下的空间, 使生成的二进制代码恰好为 512 字节
    18. dw 0xaa55 ; 结束标志

    开发环境搭建 - 图2