0% found this document useful (0 votes)
320 views2 pages

Using Part

The document provides instructions for copying a bootsector to a floppy disk to make it bootable. It explains that the bootsector must be exactly 512 bytes with 0xAA55 at the end. It recommends using NASM to compile the bootsector as a flat binary. It describes using PartCopy on Windows or dd on Linux to copy the bootsector file to the first 512 bytes of the floppy. However, this overwrites important information so an additional step is needed, adding code to the bootsector to not overwrite the "DOS boot record". The full process then involves using PartCopy twice, first to copy bytes 0-3 and then bytes 3e-1c2, to successfully make a bootable

Uploaded by

GameAlert
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
320 views2 pages

Using Part

The document provides instructions for copying a bootsector to a floppy disk to make it bootable. It explains that the bootsector must be exactly 512 bytes with 0xAA55 at the end. It recommends using NASM to compile the bootsector as a flat binary. It describes using PartCopy on Windows or dd on Linux to copy the bootsector file to the first 512 bytes of the floppy. However, this overwrites important information so an additional step is needed, adding code to the bootsector to not overwrite the "DOS boot record". The full process then involves using PartCopy twice, first to copy bytes 0-3 and then bytes 3e-1c2, to successfully make a bootable

Uploaded by

GameAlert
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Copying Your Bootsector to a Floppy

Copying Your Bootsector to a Floppy


So you've made a bootsector and now you want to copy it to a floppy. Before we get to that, you need to make
sure of 3 things:

1. Your bootsector is exactly 512 bytes long.


2. Your bootsector ends with 0xAA55.
3. Your bootsector is compiled as a flat binary.

To do the first two steps in NASM, simply end your bootsector with this bit of code:

times 512-($-$$)-2 db 0
dw 0AA55h

For the last step, compile(using NASM) with:

nasm yourbootsector.asm -f bin -o bootsec.bin

Now let's get your bootsector onto a floppy.

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:

partcopy bootsec.bin 0 200 -f0

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):

partcopy bootsec.bin 0 3 -f0


partcopy bootsec.bin 3e 1c2 -f0 3e

1 of 2
Copying Your Bootsector to a Floppy

And there you have it. A bootable floppy disk with your own bootsector on it!

Download an example with full source code.

Written by K.J. [email protected]

2 of 2

You might also like