Image Map Image Map
Page 6 of 6 FirstFirst ... 23456
Results 51 to 56 of 56

Thread: CP/M question...

  1. #51
    Join Date
    Feb 2006
    Location
    in the basement
    Posts
    767

    Default Translation Please....

    Would you please explain the following key parameters:

    1- EX = Extent counter, low byte - takes values from 0-31
    2- S2 = Extent counter, high byte

    why low byte and high byte?

    An extent is the portion of a file controlled by one directory entry.
    If a file takes up more blocks than can be listed in one directory entry,
    it is given multiple entries, distinguished by their EX and S2 bytes. The
    formula is: Entry number = ((32*S2)+EX) / (Exm+1) where Exm is the
    extent mask value from the Disc Parameter Block.

    3-RC - Number of records (1 record=128 bytes) used in this extent, low byte.
    The total number of records used in this extent is

    (EX & Exm) * 128 + RC

    If RC is 80h, this extent is full and there may be another one on the disc.
    File lengths are only saved to the nearest 128 bytes.

    ziloo

  2. #52
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    3,458
    Blog Entries
    1

    Default

    The low byte only covers 32 extents which means the largest possible file would be 512kB. Plenty for a 250kB floppy disk. CP/M 2.2 increases the maximum file size to 8 MB through the use of 512 extents; CP/M 3 gives a further increase to maximum file size of 32 MB with 2048 extents. The high byte is multiplied by 32 to get to those larger numbers for extents.

    Just to generate a lot of confusion, CP/M refers to logical extents (file size in 16kB increments) which these calculations apply to and physical extents which are the entries in the directories. Each directory entry gets the value of what its matching logical extent number would have been. The dead hand of compatibility forces these strange structures in order to keep working with earlier code. Partially this is necessary because disks had very limited number of directory entries; 512 extents may need as few as 32 directory entries using this method. 512 directory entries would need 16 kB to process which won't leave much memory for anything on a 64 kB Z-80 system.

    A better explanation and detailed examples of a bunch of disk formats can be seen at http://www.sharpmz.org/succpminfo06.htm Due to a typesetting error, certain values do not show the superscript indicating that it is a power of 2.
    Last edited by krebizfan; November 18th, 2017 at 09:01 AM. Reason: Math mistake

  3. #53
    Join Date
    Feb 2006
    Location
    in the basement
    Posts
    767

    Default

    Thank you for the explanation; now let me retell the directory story;

    1- each time a record is added to the file-> RC is incremented by 1
    RC is one byte;

    what does it mean...low byte ?

    ziloo

  4. #54
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    25,254
    Blog Entries
    20

    Default

    A file's total size is determined by three bytes containing bit fields in the directory, going from least significant to most significant:

    RC (0-127)
    EX (0-31)
    S2 (0-127?)

    Concatenating the three in the last directory entry will give you the apparent total size in 128 byte blocks.

    Why "apparent"? Because of the notion of "sparse" files, which describe a file larger than actually allocated (the notion doesn't exist in the FAT system). CP/M can create files with directory entries where (a) one or more allocation block specifiers are zero and (b) entire extents are not recorded in the directory. So, a file might appear as if it's 65KB long, but actually occupy only 4KB of allocated space.

    This is actually useful in some cases, where some sort of hash code is used to compute a position in a randomly-accessed file. There's no need to actually allocate blocks that are never accessed. I believe that Windows NTFS can also do this.
    Last edited by Chuck(G); November 18th, 2017 at 09:24 AM.

  5. #55
    Join Date
    Feb 2006
    Location
    in the basement
    Posts
    767

    Default

    Now taking my previous post and the unique explanation given by
    chuck (not found in any other reference):

    "The EX field is actually divided into two fields--the low-order one relates to
    the overflow from the RC field; the upper-order bits relate to
    the directory ordinal (?) .


    So, for example, a directory entry describing 256 blocks would use
    the low-order bit of the EX field as overflow and the bits to the left of it
    to number directory extents.

    The EXM value in the BIOS DPB for the drive is a mask
    that indicates where the division is (?)."

    Now back to my directory story:

    1- each time a record is added to the file-> RC is incremented by 1
    until RC reaches 127 (01111111); then RC would overflow;

    Where would RC overflow into?


    Last edited by ziloo; November 18th, 2017 at 09:46 AM.

  6. #56
    Join Date
    May 2009
    Location
    Connecticut
    Posts
    3,458
    Blog Entries
    1

    Default

    If everything works the way I understand it, once RC reaches 128 blocks indicating the logical extent is full, RC would be set to 0 and EX would be increased by 1. If EX hits 32, it gets reset to 0 and S2 increments by 1. Fortunately, it is rare for a program to update a file in just 128 byte chunks meaning the program simply has to figure out the final RC, EX, and S2 values.

    Matching this to the need to add additional allocation entries and directory entries is something I would have look into. Especially what looks like a corner case with 256 kB physical extents where each allocation unit uses 32 kB or 2 logical extents. How CP/M would manage to assign a second logical extent to a single allocation unit as file size increases is something I am unsure about.

    Low byte and high byte refer to the EX/S2 combo. High byte means the number is larger than the low byte. If one referred to the two bytes in hex, 0A1C would indicate at least 320 extents in the S2 byte (value of 10 * 32) and that there are another 30 extents according to the EX byte for a total of 350 extents.
    Last edited by krebizfan; November 18th, 2017 at 10:30 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •