
BOOTSECT = scboot.o

LOADER = scbtest.o

CFLAGS += -std=c99 -c

all: bootsect loader fd0.img hd0.img

bootsect: $(BOOTSECT)
	$(LD) -T bootsect.ld $(BOOTSECT)

loader: $(LOADER)
	$(LD) -Map loader.map -T loader.ld $(LOADER)

# 1.44 MB floppy drive
fd0.img: bootsect loader
	# boot sector address (seek=x)
	dd if=bootsect of=fd0.img bs=512 count=1 seek=0 
	# boot loader address (seek=x)
	dd if=loader of=fd0.img bs=512 count=8 seek=1 
	# disk size (seek=xxx)
	dd if=/dev/zero of=fd0.img bs=512 count=1 seek=2879

# 20 MB hard drive
hd0.img: bootsect loader
	# boot sector address (seek=x)
	dd if=bootsect of=hd0.img bs=512 count=1 seek=0 
	# boot loader address (seek=x)
	dd if=loader of=hd0.img bs=512 count=8 seek=1 
	# disk size (seek=xxx)
	dd if=/dev/zero of=hd0.img bs=512 count=1 seek=20971008
	
clean:
	rm -f bootsect loader *.map *.img *.o
	
.s.o:
	nasm -f elf64 $<

	
