Page 1 of 1

Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by HOS
hi, i am wondering about the parameters for a standard 3.5" floppy disk. this is what i have picked up so far (correct me if i misunderstood or figured something out incorrectly):

- 2880 sectors total
- 512 bytes per sector
- 18 sectors per cylinder/track
- 80 cylinders per head
- 2 heads total

here is what i need to know: are cylinders the same as tracks, just different names? when reading the disk with a bios interrupt, in what order, sector by sector, would the entire disk be layed out? for example, would it go:
- sectors 1-18 of cylinder 0 of head 0
- sectors 1-18 of cylinder 1 of head 0
...
- sectors 1-18 of cylinder 79 of head 0
- sectors 1-18 of cylinder 0 of head 1
... to the end

or would it be:
- sectors 1-18 of cylinder 0 of head 0
- sectors 1-18 of cylinder 0 of head 1
- sectors 1-18 of cylinder 1 of head 0
... to the end

please let me know, i am a bit confused about this.
also, is it correct that sector #'s start at 1 but cylinder and head #'s start at 0?

thank you very much

RE:Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by Jamethiel
Yes, a cylinder is a track by any other name.

Yes, sectors start at 1 and heads start at 0. I forget about tracks, and am not about to look it up right this second.

The order is sectors, heads, tracks.

Anything else you need to know?

RE:Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by HOS
by "The order is sectors, heads, tracks." do you mean that this psuedocode would work to read the entire disk sector by sector in order:

for track = 0 to 79
for head = 0 to 1
for sector = 1 to 18

[read sector]

next sector
next head
next track

thanks again

RE:Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by Jamethiel
Exactly so.

RE:Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by Robert Lee
A track and a cylinder are sometimes thought of as the same thing but technically a track runs around the surface of a disk on just one side. On a floppy disk with 2 heads, each cylinder contains 2 tracks. On a single-sided disk a cylinder and a track are the same thing. On a hard disk with 16 heads, each cylinder contains 16 tracks, etc.

Another words, tracks are all single-sided. It's the word used to describe a container of 18 sectors. There are 18 sectors per track but 36 sectors per cylinder (18 in each of the 2 tracks).

Cylinders are the distance between the center of the disk and the outer edge. Think of it this way: a track exists for every combination of cylinder and head. In terms of geometry you don't use tracks. The 3 dimensions are cylinders, heads and sectors.

What is more confusing are the different ways that the word "sector" is used. Personally I like to refer to sectors of data as "blocks" which are addressed using linear base addressing. I use the word sector are the name of one of the CHS dimensions and limit its use as a number between 1 and 18. Just remember that LBA addressing is 0-based even though your addressing sectors.

In any case, a usefull routine to have follows (tasm ideal mode syntax):

PROC getCHS NEAR        @@address:WORD
            MOV         AX, [@@address]
            XOR         DX, DX
            DIV         [wSectsPTrk]
            INC         DX
            MOV         [bSECT], DL
            XOR         DX, DX
            DIV         [wDrivHeads]
            MOV         [bCYL], AL
            MOV         [bHEAD], DL
            RET
ENDP getCHS


Where @@address is an LBA address (0 through 2880); wSectsPTrk is a word holding the number of sectors per track (ussually 18); wDrivHeads is a word holding the number of heads the drive uses (ussually 2); bSECT, bHEAD and bCYL are byte variables used to store the function's return values. With this, use LBA addresses for all your "business" logic and convert to CHS just before calling INT 13h.

Hope this helps.

-Robert

RE:Floppy disk parameters

Posted: Sun Jul 27, 2003 11:00 pm
by HOS
It does help, especially with determining the difference between a cylinder and a track.

thanks