Forget the CHS scheme and think in terms of LBA since the translation between the two makes the CHS organisation very easy to understand.
A 1.44mb 3.5 inch floppy has 2 heads/80 cylinders/18 sectors per cylinder. Because there is only one platter one cylinder represents a single track (See Schol-R-Lea's very good explanation here
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=2494 if you don't get that).
Now that gives you a total of 2*80*18 sectors on the disk, ie 2880 sectors. In LBA scheme you start at sector 0. So the range for a 1.44mb 3.5 floppy is 0-2779.
To convert to CHS scheme from LBA you use these formulae.
Sector = ((LBA Sector) mod (Sectors per track)) + 1
Head = floor((LBA Sector) / (Sectors per track)) mod (Heads per cylinder)
Cylinder = floor(((LBA Sector) / (Sectors per track)) / (Heads per cylinder))
Some examples on 1.44mb 3.5inch floppy:
Sectors per track = 18
Heads per cylinder = 2
LBA sector=0 (Ie the 1st sector on the disk)
Sector = 1
Head = 0
Cylinder = 0
LBA sector=18 (Ie the 19th sector on the disk)
Sector=1
Head=1
Cylinder=0
Now the important thing to take from these examples is that in CHS scheme
THE SECTOR VALUE STARTS AT 1 NOT 0. Bios 13h uses CHS.
Here's the details of BIOS Int 13h, 0x02
AH=0x02 - Indicates that you are using the read sectors function
AL=Number of
contiguous sectors to read
CH=Start Cylinder
CL=Start Sector
DH=Start Head
DL=Drive number
This interrupt function returns this information:
AH=Status of operation
AL=Number of sectors read (Not always what you expect)
CF=Set on error, cleared otherwise
Now AL acts as a
counter. So when load al with 0x11 it will read 17 sectors, that 17 sectors includes the sector you instruct Int 13h, 0x02 to start the read at.
BIOS will
not change the head/cylinder for you. Ie all the sectors you want to read in a single Int 13, 0x02 call
must be on the same track.
To load a full track you set up CHS to be the first sector on the track and AL to be 0x12, ie 18 sectors including the start sector.
Hopefully that clarifies a few things. Sorry it's not more use Tom, but I reached the point of seeing you incrementing the heads value 3 times on a floppy and figured these might be worth pointing out seeing as from recent posts a few people are having problems with int 13h, 0x02. I'll look again sometime tomorrow.
**
I think C uses % for mod, can't be sure though.