         ABOUT THE DISK FORMAT

             by nir darey



A diskette is composed of a thin
magnetic disk covered by thin plastic
usually black. The cover has an open
area on both sides exposing the
magnetic disk surface to the drive
for reading or writing.
As the diskette spins in the drive,
the read/write head is actually
over the opening, reading/writing the
disk surface like a cassette recorder
would.

The diskette is divided into tracks.
A track is a ring about the center
of the diskette.
The drive head can be positioned
over any one of the tracks, and data
can be readed from the surface.

A disk can be formated in different
formats. Single Density format is
dividing the disk into 40 tracks of
18 sectors each with 128 bytes per
sector, total of 720 sectors on the
disk, that give us 90 kilobytes on
the disk.
Dual Density or as most known as
1050 Density, the disk is divided
to 40 tracks of 26 sectors with 128
byte each, that give us 130 kb. on
a disk.
Double Density format is dividing the
disk to 40 tracks of 18 sectors each
with 256 bytes per sector for a total
of 720 sector, which give us 180 kb.

now we will talk about how data is
transferred from the diskette into
the computer.
A sector data is a magnetic fields
that being converted into electric
pulses which are fed to the floppy
disk controller.
The floppy disk controller is the
interface between the read and write
head and the drive microprocessor.
the floppy disk controller performs
all sector searches and uses to
transfer data between the
microprocessor and the physical disk.

The disk drives processor receives
a full sector of data every 1/18 of
a disk spin.
This is about 0.0555 seconds.

About the Disk Operating System
format.
DOS 2.0 format the disk at Single
Density total of 720 sectors.
DOS 2.5 can format the disk in Dual
Density total of 1040 sectors.
both formats uses sectors which
contains 128 bytes of data.
in DOS 2.0 there are 707 sectors
free for files, and in DOS 2.5 there
are 1011 free sectors.
you probably ask what happened to the
missing sectors ?, well the DOS uses
most of those sectors as information
about the disk and the files that
are on the disk.

The disk sector map for DOS 2.0:

sectors :   contents       :
----------------------------
1-3      boot information
4-369    free for files
360      VTOC
361-368  directory information
369-719  free for files
720      not used

The disk sector map for DOS 2.5 is
the same as DOS 2.0 with the
additions of the following:

sectors  :   contents       :
-----------------------------
721-1023  free for files
1024      extended VTOC
1025-1040 not used

Now time we will examine how the DOS
uses sectors to store and keep track
of programs or data files.

lets look at a DOS disk.
The first three sectors contains the
boot information. Sectors 4 - 359 are
free for files. Sector 360 is the
VTOC. Sectors 361 - 368 are the
directory information. Sectors 369 -
719 are free for files. Sectors 720
is not used. Sectors 712 - 1023 are
free for files in enhanced density
only. Sector 1024 is the extended
VTOC for enhanced density only.
Sectors 1025 - 1040 are not used.

There are three different kinds of
sectors that stores information about
the whole disk.
First the BOOT SECTORS. first we must
understand what is a boot sector.
well, a boot sector is the first
sector on a disk. the boot sector
is actually the header of the whole
disk. The most important at the boot
sector are it's first six bytes.
Byte zero is the boot flag, it is
usually unused.
Byte 1 contains the number of sectors
to be read as part of the boot
process. the number can be upto 256.
Bytes 2-3 contains the start address
to load the boot data.
Bytes 4-5 are the initialization
address.
As for the boot sectors in the DOS
disk, the boot flag is always zero,
the number of boot sector are three,
the address to load the boot sectors
is 1792 and the initialization
address is 5440.
Bytes 6-7 are the address that the
computer will jump to continue load.
Byte eight is unused. Byte nine is the
number of sectors buffer ( =3).
Byte ten is the drive enable bits, 
bits 0-7 equal to drives 1-8. byte
ten is usualy 131 in decimal, in 
binary it's equal to 10000011. As you
can see drives 1,2 and 8 are is use.
Byte eleven is unused.
Bytes 12 and 13 are the start address
for the buffers, equal to 6604.
The 14 byte indicates if there is DOS
on the disk or not. If the byte is
equal to zero means that there is no
Dos on the disk, if the byte is 1
then DOS.SYS is on the disk.
Bytes 15 - 16 is the first sector of
DOS.SYS file usualy it's 4.
The 17 byte is the offset to sector
link data, the byte is equal to 125.
Bytes 18 - 19 indicates the start of
main DOS.SYS file, it's equal to 1995
The 20 byte is the first byte of the
boot data.
those values can be changed with the
wright tool.

secondly the Volume Table Of Contents
or as known the VTOC. the VTOC data
is located in sector 360, and in this
sector you can find how many sectors
are free, what sector is used or
unused and more
The first 10 bytes contains general
information about the disk.
Byte zero is used to indicate the DOS
type normally it's equal to 2 for DOS
2.0/2.5.
Bytes one and two contains the total
or sectors on the disk. for DOS 2.0
it's 707 and for DOS 2.5 it's 1010.
Bytes three and four contains the
number or currently free sectors.
Bytes 10 to 99 contains the values
representing the first 719 sector of
the disk. Let me explain how it's
done: divide bytes 10 to 99 into
bits. Byte 10, bit 7 is sector 0.
Byte 10, bit 6 is sector 1.
and so on...
Byte 10, bit 0 is sector 7.
Byte 11, bit 7 is sector 8.
and so on...
byte 99, bit 0 is sector 719.
now check if the bit is equal to one
then the sector is free. If the bit
is equal to zero then the sector is
in use.
The rest of the bytes, bytes 100 to
127 are unused.
DOS 2.5 have an extended VTOC that
located is sector 1024.
Bytes 0 to 121 represent sectors:
48-1023 the same way as before.
Byte 0, bit 7 is sector 48.
and so on...
Byte 121, bit 0 is sector 1023.
Bytes 122 - 123 contain the number
or free sectors on enhanced area
only.
And last the directory sectors.
there are eight sectors that are
reserved for a diskette directory.
each sector able to contain up to
eight files. means the maximum number
of files that can be placed on single
diskette is 64.
There are 16 bytes available for each
file entery.
The first byte is the flag byte. the
flag byte contains the information
about the condition of the file.
divide the flag byte into bits and
check: If bit 0 = 1 then the file is
open for output. If bit 1 = 1 the
file was created by DOS 2.0/2.5.
Bits 2,3,4 are not used. If bit 5 = 1
then the file is locked.
If bit 6 = 1 then the file is normal.
And if bit 7 = 1 then the file has
been deleted.
The second and third bytes contains
the total sectors of the file.
Byte 3-4 contains the starting sector
number of the file.
Bytes 5-12 contains the file name,
And bytes 13-15 contains the file
name extension.

And last let's look at the files
sectors. in one sector there are 128
bytes. Each file sector contains
125 bytes of file data followed by
three bytes of dos information.
Bytes 0 to 124 contains the file
itself, which can be data,text,basic
program or anything else.
Byte 125 contains the total number
of bytes that are actually used,
which is normally 125.
The next two bytes (126-127) contains
two pieces of information.
The first six bits of byte 126 holds
the file number, the number can be
from 0 to 63. for example, the first
file in the directory would have the
value of zero here and the second
file would give the value of one.
The final two bits of byte 126 and
the whole byte 127 when put together
to give a 10 bit number which point
the next sector of the file. This
value will be set to zero of this
sector is the end of the file.

that's all, if you have any question
please contact me and i will be happy
to reply.
