#targets : prerequisites # command # ... # kernel : floppy.bin object floppy.bin : bootsect.asm nasm bootsect.asm -o floppy.bin / -DNUMBER=1234 object : test.c test.h gcc -o object test.c clean : rm -f object rm -f floppy.bin 使用NASM在编译时传递信息给启动程序 -D ; This macro is used to calculate padding needed ; to ensure that the boot sector is exactly 512 bytes ; in size. The argument is the desired offset to be ; padded to. %macro PadFromStart 1 times (%1 - ($ - BeginText)) db 0 %endmacro [BITS 16] [ORG 0x07c00] BeginText: mov ax, 0 mov ds, ax mov es, ax