Using Part
Using Part
To do the first two steps in NASM, simply end your bootsector with this bit of code:
times 512-($-$$)-2 db 0
dw 0AA55h
I'm assuming that your are using Windows. For Windows your need to go to John Fine's webpage and get his
program PartCopy. For Linux you will need to use dd(anyone interested in writting a tutorial on dd?). Now,
you need to copy your bootsector to the first 512 bytes of the floppy disk. To just test a bootsector(in this
example called bootsec.bin) use PartCopy like this:
That copies bytes 0-512(PartCopy uses hex, 0x200=512) of bootsec.bin to the first floppy drive(-f0). Note
that after -f0 we could put a destination offset, but since the bootsector has to be at the start of the floppy we
just leave out a destination offset(PartCopy's default is 0).
If your bootsector has no bugs, the floppy will be bootable. One thing that you will notice however, is that if
you try and read the floppy in Windows/DOS/Linux you are told that the floppy isn't formated. This is
because of the way in which we just copied our bootsector to the floppy. The way we did it we overwrote
some important information.
To not overwrite this information(the "DOS boot record") we need to add some more code to our bootsector.
At the start of your bootsector(right after your org 0x7C00) do this:
start:
jmp short begin
nop
times 0x3B db 0
begin:
the rest of your code goes here
Now, this time it will take 2 steps to copy your boot sector to a floppy(if you're using the previous, be sure to
format it first):
1 of 2
Copying Your Bootsector to a Floppy
And there you have it. A bootable floppy disk with your own bootsector on it!
2 of 2