当一个文件的第511, 512个字节是0x55, 0xaa时,就被认为是x86 boot sector
#dd if=/dev/zero of=test.bin bs=512 count=1
然后用hexedit将0x1fe位置设为0x55, 0x1ff位置设为0xaa
#file test.bin
test.bin: x86 boot sector
然后将loader.bin写入test.bin的前510个字节就制成一个启动盘了。
loader.bin, 149个字节
dd if=loader.bin of=test.bin conv=notrunc
#qemu test.bin
就可以启动, 运行boot loader中的代码了。
loader.asm
org 07c00h
...
#nasm -o loader.bin loader.asm