制作最简单的OS
一、生成.bin文件
1.创建Boot.asm文件,输入相应的汇编代码
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, 00ch mov dl, 0 int 10h ret BootMessage: db "Hello,OS world!" times 510-($-$$) db 0 dw 0xaa55
2.使用NASM编译Boot.asm文件为Boot.bin
nasm Boot.asm -o Boot.bin
二、dd制作软盘镜像
1.复制Boot.bin到Boot.img中
dd if=Boot.bin of=Boot.img bs=512 count=1
2.制作空白软盘镜像文件diska.img
dd if=/dev/zero of=diska.img bs=512 count=2880
3.复制diska.img中从第512字节往后的内容添加到Boot.img中
dd if=diska.img of=Boot.img skip=1 seek=1 bs=512 count=2879
(seek=x从输出文件开头跳过x个扇区,skip=x从输入文件开头跳过x个扇区)