makefile.boot

本文介绍了一个使用Makefile来组织和构建两个关键组件——引导程序(boot.bin)和加载器(loader.bin)的过程。通过详细的Makefile规则说明了如何利用nasm进行编译,并通过dd命令创建映像文件,最后将加载器复制到该映像中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Code:
  1. #makefile for boot   
  2.   
  3. #this program   
  4. TARGET = boot/boot.bin boot/loader.bin   
  5.   
  6. #programs,flags,etc   
  7. ASM = nasm  
  8. ASMFLAGS = -I boot/include/   
  9.   
  10. #PHONY for boot   
  11. .PHONY:everything clean all buildimg   
  12.   
  13. #default starting position   
  14. buildimg:everything   
  15.     sudo dd if=boot/boot.bin of=b.img bs=512 count=1 conv=notrunc  
  16.     sudo mount -o loop b.img /mnt/floppy   
  17.     sudo cp -fv boot/loader.bin /mnt/floppy/   
  18.     sudo umount /mnt/floppy   
  19.   
  20. everything:$(TARGET)   
  21.   
  22. clean:   
  23.     sudo rm -f $(TARGET)   
  24.   
  25. all:everything clean   
  26.   
  27. boot/boot.bin:boot/boot.asm   
  28.     sudo $(ASM) $(ASMFLAGS) -o $@ $<  
  29.   
  30. boot/loader.bin:boot/loader.asm boot/include/pm.inc boot/include/lib_in_real_mode.inc boot/include/lib_in_protect_mode.inc   
  31.     sudo $(ASM) $(ASMFLAGS) -o $@ $<  
  32.   
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值