Reading Sectors
Use this information only if you agree to the terms in my Disclaimer
And writing them as well.
This final non-technical bit will be brief and slightly off topic but
it's the best place I could think of to put it so here goes.
I talked before about a disk being analogous to a notepad, and it is
from a programming point of view for the most part, but at the disk
level the sectors are not arranged one after the other in a straight line.
You see the thing about disks is that they are, well disk shaped, and the thing
about notepads is that they aren't.
If you've ever taken a disk to bits you'll have found a circular
piece of material, this unsurprisingly stores all the data.
(If you're even remotely interested the coating on floppy disks
is either ferrite (in the case of older disks) cobalt or barium(2.88MB disks), not important
just another bit of useless information).
On this disk either one or both sides can hold data this is a diagram
of one side:
Firstly sorry for the incredibly badly drawn diagram, pictures are
not one of my strong points. The picture depicts a disk, obviously
the green bits aren't present in reality but are there to indicate something.
A disk has so many concentric circles called tracks on it, these are
invisible to the eye, but are where the sectors are located.
On a 3 1/2" 1.44Mb disk there are 80 tracks (on each side so 160 in total),
and each track holds 18 sectors.
The outer most track is track 0 the next one
in is 1, etc. All the tracks which are lined up over the surfaces are
referred to as a cylinder, for instance all track 0's on each surface
constitute cylinder 0.
If you imagine that the above diagram shows a sideways on view of the inside
of a hard drive (don't say it, I know, just try hard), then the dots on all the
platters indicate cylinder 0.
So you see at the lowest level a sector has to be specified by the
head (which surface it's on), the cylinder and finally which sector in the
track.
Well that's the end of the track (pun intended) if you don't want to get
the in depth technical details, I hope that this has been of use to you
whatever you wanted to read it for. You could help me out by going to
the feedback section and telling my what you think of this.
Technical Information: On accessing a disk.
There are two main ways about this as far I'm aware, the first and hardest
is to use the BIOS functions, secondly use DOS functions.
The old INT 13h services require you to use triplet format to specify which
sector(s) you want to access. If LBA extensions are available these require a
"starting absolute block number". Both of these begin reading from the first
sector on a HDD (the MBR).
The DOS services on the other hand start reading from the beginning of the
partition, so the boot sector is the first sector.
There are three main functions provided by DOS, the old INT 25 and INT 26 services,
limited to partitions under 32Mb; the newer INT 25 and INT 26 services and
the latest FAT32 "EXTENDED ABSOLUTE DISK READ/WRITE" INT 21h AX = 7305h.
The best idea now is to go and read the appropriate area in Ralf Brown's
Interrupt list. There's a list of where to look in the
Bibliography section. Before you do that however do
me a favour and send me some feedback, let me know if there's any
code snippets which you'd like added, I have some planned already so you
may want to check back every now and again and see if I've added anything.