1.编写mbr汇编程序
SECTION MBR vstart=0x7c00
mov ax,cs
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov sp,0x7c00
; 清屏
mov ax,0x600
mov bx,0x700
mov cx,0
mov dx, 0x184f
int 0x10
; 设置光标结束
mov ah,3
mov bh,0
int 0x10
mov ax,message
mov bp,ax
mov cx,5
mov ax,0x1301
mov bx,0x2 ; bl=0x2 字符属性:黑底绿字
int 0x10
jmp $
message db "1 MBR"
times 510-($-$$) db 0
db 0x55,0xaa
2.编译
nasm -o mbr.bin /home/truthos/oscode/c2/a/boot/mbr.S
3.将mbr.bin通过dd工具写入到虚拟磁盘中。
dd if=/home/truthos/oscode/c2/a/boot/mbr.bin of=/home/truthos/bochs/hd60M.img bs=512 count=1 conv=notrunc
4.启动bochs
bin/bochs -f bochsrc.disk
程序运行成功。 "1 MBR"字符串正常显示。