question about "Bootloaders 4"

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
scorpion007
Posts:7
Joined:Sun Nov 18, 2007 9:32 am
question about "Bootloaders 4"

Post by scorpion007 » Wed Jan 23, 2008 6:00 am

Hi,

I was looking in the code for this tute, namely the ReadSectors routine, and I was wondering why you always read 1 sector at a time, and loop, instead of passing the amount of sectors directly to AL?

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Post by Andyhhp » Wed Jan 23, 2008 3:31 pm

In theory (and practice), it is perfectly possible to set AL to something other than 1.

However, you get into problems if you try to read past the end of a track. e.g. reading 10 sectors starting at sector 15.

Some floppy drives will automatically adjust to move to the next logical sector when you try reading past the end of a track. However, some will not and continue reading round on the same track in which case you are reading incorrect sectors.

From a practical point of view, it would be perfectly good to write a driver that reads more than 1 sector at a time so long as it knows it isnt going to read off the end of a track. This also limits the maximum number of sectors to read at one time to 18 on a floppy disk.

The problem with making a driver such as the one above is that it just increases the length of the bootloader code in which you will struggle to keep it less than 512 bytes.

Also, given that almost all FAT12 volumes have 1 sector per cluster and 512 bytes per sector, each cluster will occupy 1 sector. Because of the nature of the FAT12 format, there is no guarantee or need for the clusters to be in sequential order. This is particularly relevant when a file is fragmented. In this case, it is if no use to read more than 1 sector at a time, unless you read all of the data out of the FAT and know you are assembling the file in the correct order.
Image

scorpion007
Posts:7
Joined:Sun Nov 18, 2007 9:32 am

Post by scorpion007 » Wed Jan 23, 2008 11:19 pm

Ah, I see.

Thanks for the explanation :)

Post Reply