MS-DOS - description of the MS-DOS system.

ZX-Files #01
 A few words about MS-DOS.

 A lot of time has passed since I
wrote my MSCOM v0.0. Actually the idea
was not bad, but as you know, the first
damn it's lumpy. In general, the main distinguishing
a feature of my MSCOM was that she
according to the idea, it had to take into account everything
features of MSDOS, and in particular the segment
file transfer. (By the way, this explains -
slowdown of disk operations as in
IS-DOS is the same in MSCOM.) To this day
not a single program that converts from a PC,
except these two, does not support segment-
file transfer.  Because I'm not soon yet
if I take on the task of rewriting MSCOM, then I
decided to release information on MSDOS in order to
if there is a guy who wants it
write another converter, I want something
he would have taken everything into account and not
stole another leim.  Yes, by the way, that's all
I’m writing from memory, and that’s why I’m 100% accurate.
I can’t guarantee it.

    1.1 General information.

I’ll make a reservation right away: All information is given
on for MSDOS disk format on 720, like
the only one suitable for reading on
Spectrum.
  So: the MSDOS disk format is as follows:
structure:

  1. Sector size: ....... 512 bytes.
  2. Number of sectors in the track: 9
  3. Number of tracks: ........ 80 (160)

 It is also worth noting that if you re-
suddenly decided to write an MSDOS formatter, then
make the first sync space bigger,
otherwise you are doomed to not reading the first one
sectors on PC.

 1.2 System sector.

 The zero sector on the zero track is
is systemic.  It contains important
information about the disk structure as a whole,
file and physical structure thereof.
  This information is called Block
Parameters of BIOS (BPB). Here is its view:

 +12 SectSiz : Word;

 Number of bytes in the sector. Always with
holds 512.

 +14 ClustSize : Byte;

 Number of sectors in the cluster (see
same). For 720 format it always contains 2.

 +15 ResSect : Word;

 Number of sectors before FAT. (see below)

 +17 FatCnt : Byte;

 Number of FAT copies. usually 2 for disk.

 +18 RootSiz : Word;

 Number of elements in the root directory.

 +20 TopSecs : Word;

 Number of sectors on the disk.

 +22 Media : Byte;

 Media descriptor.

 +23 FatSize : Word;

 FAT size in sectors.

  The Media field specifies the media type
formations:

 ╔════╤═════════════════════════════╗
 ║ Bit│ Sign ║
 ╟────┼─────────────────────────────╢
 ║ 0 │ Double/single sided media.║
 ╟────┼─────────────────────────────╢
 ║ 1 │ 8/not 8 sectors on the track.   ║
 ╟────┼─────────────────────────────╢
 ║ 2 │ Wincheter/Disk drive ║
 ║ │ ║
 ╚════╧═════════════════════════════╝

 Immediately after the BPB there is the following information:
formation:

 +25 TrkSecs : Word;

 Number of sectors on the track;

 +27 HeadCnt : Word;

 Number of device heads;

 +29 HidnSecs : Word;

 Number of hidden sectors.

 The further structure relates to wine-
chester, and there is no need to describe it here
sense.



 1.3 FAT - structure.

 ForThe boot sector is located
the so-called FAT structure. The beginning of it
can be found by stepping back from the beginning of the disk
number of sectors contained
in the ResSecs field (from BPB).
FAT (File Allocation Table) - the most important
structure on disk. As follows from the name
location, FAT contains information about the location
file placement.
 Now let me get lyrical
retreat.  The entire disk is in MS-DOS format
is divided into so-called clusters.
A cluster is a group of adjacent
sectors (1 or more, in our service
tea, with a 720 format, - 2). Cluster -
this is an elementary unit in the system
MS-DOS, i.e. it's the least you can do
read from disk.  Cluster is defined
its absolute number and with a format of
720 this number is specified by a 12-bit number
scrap
 Let's return to FAT. So, from all the above-
It follows that FAT determines the
clusters' ownership of their files, and
Here's how it works: FAT structure
keeps chains of links: somewhere in the description
every file contains the number of its first
cluster, the program takes this number,
reads into memory the corresponding
cluster, and then looks into the cell
FAT with the same number, and in this cell
contains the number of the next cluster,
at the same time being a link further.
So the programslowly reads the file
for now instead of the next cluster number
will not get the end control code from FAT
reading.


┌───────┬┬───┬┬┬┬┬┬┬┬┬───┬───┬──┬─────┐
│ Myfile txt │tim│dat│02│Length│
└───────┴┴───┴┴┴┴┴┴┴┴┴───┴───┴╫─┴─────┘
       ╔══════════════════════╝
┌──┬──┬──┬──┬──┬──┬──┬─────┐
│ID│FF│03>04>05>08│1E│09>FF│
└──┴──┴──┴──┴──┴─║┴──┴ ^ ──┘
                 ╚═════╝

 The FAT structure uses the following
control codes:

 from #FFO to #FFb - Reserved cluster
van.

 #FF7 - Failed cluster.

from #FF8 to #FFF end of file.

 I remind you that FAT elements are 12-bit,
and three bytes fit exactly two elements
cop.  Well, perhaps with the most difficult
figured it out. At the conclusion of this chapter,
I just want to add that on the disk usually
there are several copies of FAT, which ensures
ensures the reliability of information security
tions.

       1.4 Directory structure.

 Immediately after the last copy of the FAT there is
The root directory containing the description is shown.
satelators of the tackles registered in it -
logs and files. Each directory item
describing a 32-byte data structurenykh:


╔═══╤═══════╤═════╤═ ═══════════════════╗
║See│ Field │Length│ Meaning ║
╟───┼───────┼─────┼─ ───────────────────╢
║+00│ Name │ 8 │ File name.         ║
╟───┼───────┼─────┼─ ───────────────────╢
║+08│ Ext │ 3 │ Expansion.        ║
╟───┼───────┼─────┼─ ───────────────────╢
║+11│ Fattr │Byte │ File attributes.    ║
╟───┼───────┼─────┼─ ───────────────────╢
║+12│Reserv │ 10 │ 10 bytes Brad.     ║
╟───┼───────┼─────┼─ ───────────────────╢
║+22│ Time │Word │ Time of creation.    ║
╟───┼───────┼─────┼─ ───────────────────╢
║+24│ Date │Word │ Creation date.     ║
╟───┼───────┼─────┼─ ───────────────────╢
║+26│FistC │Word │Number of the 1st cluster.║
╟───┼───────┼─────┼─ ───────────────────╢
║+28│Size │4 │Size. file in bytes║
║ │ │ │ ║
╚═══╧═══════╧═════╧═ ═══════════════════╝

 The following table reflects the value
for Fattr.

 ╔════╤════════════════════════╗
    ║bit │ Meaning ║
    ╟────┼────────────────────────╢
    ║ 0 │ Protection against changes.   ║
    ║ 1 │ Hidden file.          ║
    ║ 2 │ System file.        ║
    ║ 3 │ Volume ID ??? ║
    ║ 4 │ Subdirectory ║
    ║ 5 │ Archiving sign ║
    ║ │ ║
    ╚════╧════════════════════════╝

 FirstC fieldcontains the number of the first
cluster file or directory. Subdirectories
have the same structure as the root ca-
Talog. Byte #00 at the beginning of the file descriptor
indicates the end of the directory, and #120 indicates
that this file has been erased. For each sub-
directory element named "." contains
link to the root directory, and ".." - to
previous level.

 1.5 Conclusion.

 That's probably all you need to know
Sinclairist about the MSDOS system. I can't yet
not to mention the one who recently came to me in
head to the idea regarding the amelioration of the op-
walkie-talkies with MSDOS disk. Very often the class
tera files lie one after another and therefore
mu so as not to read clusters one by one
(and this is the main brake), you can
view the FAT table, select groups
adjacent clusters and read these
groups are like packs of sectors. In my opinion
once again, the speed should increase by 3-4 times
for, since the disk will not do left
turns where it is not necessary.
 In general, I think there is enough information
to write a competent converter. If
additional information is needed or
any sources please contact me
(KotSoft).  Then I'll scrape...

 When writing the article we used
reference materials from the book by V.V. Headlight-
onova.  "Turbo Pascal 7.0 - Workshop
programming"

 (C) KotSoft 31.08.00

Share your thoughts about the article