Page 2 of 2

Re: Need help to understand Floppy Disk Drive program..

Posted: Mon Mar 14, 2011 9:26 pm
by Brynet-Inc
Note; the CHS geometry is almost entirely bogus on newer drives.. but it usually translates properly to the LBA size.

EDIT: Somehow didn't notice this thread was about floppy drives, brain fart.

Re: Need help to understand Floppy Disk Drive program..

Posted: Mon Mar 14, 2011 10:09 pm
by osdevkid
Brendan wrote:Hi,
osdevkid wrote: I think, a head/surface has more than one tracks, please refer this link http://www.jegsworks.com/Lessons/lesson6/lesson6-3.htm
If the head/s are not moved, then a track is all the sectors that pass under one head. If there's 20 heads and none of them are moved, then a cylinder is all the sectors that pass under all the heads (20 tracks).
Hi Brendan, I have confused, please leave the concept "when head/s move or not move", In a floppy disk case, if we take one surface, there will be more than one tracks available, each track has several sectors, is it correct or not?

In case, more than one tracks are there in a single surface of floppy then, to read all tracks in a surface, it is required to move the head on linear direction, to do that on BIOS interrupt 0x13, whether we need to increment track number or head number (defnitely not head number, I think so, because incrementing head number will go to read the next surface of the floppy drive).

And one more concept, shared in this thread is, BIOS interrupt 0x13 will read all tracks and its sectors in a surface at one shot.

I am looking for better FLOPPY drive program guide. help me if you guys know better tutorial.

Re: Need help to understand Floppy Disk Drive program..

Posted: Mon Mar 14, 2011 11:40 pm
by bewing
A floppy drive is just a small hard drive, that only has two heads, and one "platter". Look back at Brendan's image, and mentally imagine one disk, instead of many. There are no other tutorials specific to floppies only. They are obsolete technology, and not worth the effort of a tutorial.

You must be very very careful with terminology when working with hardware. A cylinder is not a track.

You seem to want to use the word "surface" to include all the tracks that are on one side of a disk? OK, we can do that. It is not a useful concept, but we can do that. On a typical floppy disk there are 80 tracks on one side of a floppy disk, and 80 tracks on the other side. You use head 0 to read the tracks on one side, and head 1 to read the tracks on the other side. You must change the cylinder number whenever you try to read different tracks. No, you cannot read "all the tracks on a surface all at once." Just one. A floppy is not like a CD. The head assembly does not move "in a linear fashion". It moves in steps, when you change the cylinder number.

On a typical floppy disk, there are 18 sectors in a track. You read that track by selecting a cylinder and a head, and then reading 18 sectors (because you know there are 18 to read). That is all a "track" is. 18 sectors all together, read or written using a specific cylinder and head number.

We have tried to explain to you why changing the cylinder number is a bad idea, unless you have no other choice. I suggest at this point that you simply try writing some code that reads a different cylinder number each time, and then run it on real hardware. You will see very quickly why we tell you to A) read all the sectors in the track first, B) then change the "head" number, and read those sectors, and then C) only last do you change the cylinder number.

Re: Need help to understand Floppy Disk Drive program..

Posted: Tue Mar 15, 2011 12:45 am
by osdevkid
Dear Bewing,

Excellent post, thank you very much, now I got some idea.

We have to read floppy in this order
head 0 track 0
head 1 track 0
head 0 track 1
head 1 track 1
etc.

The reason is, I dont know, but it may be, while we write data in to the floppy dirve, it may write in this order, am I right?

Also one more advantage is, it is more efficient to read both heads(a logical change) at the same track rather than add a physical movement up and have to come back later. This minimises head movement.

Re: Need help to understand Floppy Disk Drive program..

Posted: Tue Mar 15, 2011 4:17 am
by Combuster
osdevkid wrote:We have to read floppy in this order
head 0 track 0
head 1 track 0
head 0 track 1
head 1 track 1
Not completely correct - a track is defined by the cylinder (distance from center) and head (side):
head 0 cylinder 0 (first track)
head 1 cylinder 0 (which would be the second track, located opposite of the first one)
head 0 cylinder 1 (third track)
head 1 cylinder 1 (fourth track)
Which is also why track is never an argument to functions - if you want logical addressing you'd use LBA because its only one number, if you want physical addressing, CHS is the most accurate representation of real hardware. There is no Track+Sector addressing as it has the disadvantages of both.
The reason is, I dont know, but it may be, while we write data in to the floppy dirve, it may write in this order, am I right?
It does whatever it was programmed to do.
Also one more advantage is, it is more efficient to read both heads(a logical change) at the same track rather than add a physical movement up and have to come back later. This minimises head movement.
Yes its faster as minimal head movement is involved. The "order" we impose on them is chosen so that if we want to read the entire disk, doing so from start to end is the most efficient way: by switching heads and sectors first the head only needs to move for the number of cylinders.

Re: Need help to understand Floppy Disk Drive program..

Posted: Tue Mar 15, 2011 8:04 am
by bewing
osdevkid wrote: The reason is, I dont know, but it may be, while we write data in to the floppy dirve, it may write in this order, am I right?

... The advantage is, it is more efficient to read both heads (a logical change) at the same track rather than add a physical movement up and have to come back later. This minimises head movement.
You have it basically correct now, and what Combuster said is correct, but I want to add one thing for clarity.

As you say, to minimize physical head movement, it has been standardized that all software that reads or writes data to the floppy disk will read or write sectors in this order. So if there is a file that extends for more than one track, and that file was written to disk by software that is not yours, then you need to read it back in this order or the file will not read properly.