★ CODING ★ THE AMSDOS HEX|Amstrad Action) ★ |
The Amsdos hex |
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 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
|