CODING ★ THE AMSDOS HEX|Amstrad Action) ★

The Amsdos hex
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Alastair Scott, of Grangemouth. in Stirlingshire, writes:

Ql would be grateful if you could help me with the AMSDOS disc format.

On examining the directory entry with a disc sector editor, I get a display such as:

00 45 4E 56 45 4C 4F 50 45 42 41 53 00 00 00 4A 20 69 79 7H 7B TE 80 83 00 00 00 00 00 00

I realise that the highlighted hex digits refer to the track sector that the file (in this case Envelope.Bas) is stored at. How can you convert these digits into track and sector numbers?

A CP/M disc (for this is what it is) is not set out in the way you might think. The file is split into portions that will fit into the available places on the disc. The directory tells the operating system where the various pieces are. The directory entry is read as follows.

Byte / Contents / Meaning

0 00 Set to 0 if file is valid, E5 if erased
1 E
2 N
3 V Eight
4 E byte
5 L filename
6 O
7 P
8 E
9 B Three byte
10 A file
11 S extension
12 00 Extent
13 00 s1
14 00 s2
15 4A Number of records in this extent
16 26 The
17 69 rest
18 79 are
19 7 A allocation
20 7B units
21 7E which
22 80 are
23 83 set
24 84 to
25 85 zero
26 00 if
27 00 they
28 00 are
29 00 unused
30 00
31 00

These 32 bytes tell the operating system all of the information it needs to know about the file. The filename and extension are obvious. Files are stored on disc as records of 128 bytes, each allocation unit represents 8 records, and there is space in one directory entry for 16 allocation units, hence 16*8*128=16384 bytes.

The extent entry is used when the file exceeds 16K. If this happens, another extent is opened up creating a new directory entry with the same filename and type but with the extent number set to one (or more if the file is really big, calling for more directory entries).

The allocation units are stored in the directory entry from byte 16 to 31 (16 entries as above) and each refers to a block of eight sectors each sector being 128 bytes long. The blocks are numbered sequentially from track 0 sector 0 through the last track and sector (depending on the density).

So to find where a file is stored on disc, look at the allocation units, and then read the eight consecutive sectors that each one points to. In your example, the first block is stored in block 26 (38 decimal) or sector 304 (38x8); just divide by the number of sectors per track to get the track number, the remainder is the sector on this track where the file starts. At the end of this block, use the next allocation number to work out the position of the next block.

When you get to the last block, it may not be full, the remainder of the 'number of records' entry divided by 8 will tell you how many records are used.

The numbers s1 and s2 are used by the system for something but I don't know what, the number of records in the extent is exactly that on single density system (such as the 6128) but is a little more convoluted on double density systems.

Popular Computing Weekly Issue 1986-09-25

★ PUBLISHER: Popular Computing Weekly
★ YEAR: 1986
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ AUTHOR: Alastair Scott
 

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Coding » AMSLIVE n°07 - HAPPY DRIVERS : LES RSX AMSDOS
» Coding » Clefs2 48 - Amsdos - Analye de l'En - Tete d'un Fichier
» Coding » Clefs2 04 - Messages Erreurs Amsdos
» Coding » Clefs2 01 - Amsdos
» Coding » Clefs2 50 - Amsdos - Ouverture Fantome d'un Fichier
» Coding » AMSLIVE n°06 - Rsx Amsdos
Je participe au site:

» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 356 millisecondes et consultée 411 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.