29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>The</strong> position of a file's hash code entry in the Hash Index Table is called the Direc<strong>to</strong>ry<br />

Entry Code (DEC) for the file. All files will have at least one DEC. A contiguous block<br />

of granules allocated <strong>to</strong> a file is termed an EXTENT. <strong>The</strong> FPDE record contains fields <strong>to</strong><br />

hold the data on four extents. Files that use more than four extents because they are<br />

either large (an extent can address a maximum of 32 contiguous granules) or fractured<br />

in<strong>to</strong> non-contiguous space require extra direc<strong>to</strong>ry records <strong>to</strong> hold the additional extents.<br />

<strong>The</strong>se additional records are termed the File's Extended Direc<strong>to</strong>ry Entries (FXDE) which<br />

also have four extent fields each. A Direc<strong>to</strong>ry Entry Code is also used <strong>to</strong> associate an<br />

FXDE with a HIT entry. Thus, a file will have DECs for each FXDE record and use up more<br />

than one filename slot in the HIT. <strong>The</strong>refore, <strong>to</strong> maximize the quantity of file slots<br />

available, you should keep your files below five extents wherever possible.<br />

<strong>The</strong> FPDE and FXDE records are contained in the remaining sec<strong>to</strong>rs of the direc<strong>to</strong>ry<br />

cylinder. <strong>The</strong> Direc<strong>to</strong>ry Entry Codes are mapped <strong>to</strong> the FPDE/FXDE records by each DEC's<br />

position in the Hash Index Table. Conceptualize the HIT as eight rows of 32-byte fields<br />

as shown in figure 5-5. Each row will be mapped <strong>to</strong> one of the direc<strong>to</strong>ry entry records in<br />

a direc<strong>to</strong>ry sec<strong>to</strong>r. <strong>The</strong> first HIT row <strong>to</strong> the first direc<strong>to</strong>ry entry record, the second HIT<br />

row <strong>to</strong> the second direc<strong>to</strong>ry entry record, and so forth. Each column of the HIT field (the<br />

0-31) is mapped <strong>to</strong> a direc<strong>to</strong>ry entry sec<strong>to</strong>r. <strong>The</strong> first column is mapped <strong>to</strong> the first<br />

direc<strong>to</strong>ry entry sec<strong>to</strong>r in the direc<strong>to</strong>ry cylinder (not including the GAT and HIT).<br />

<strong>The</strong>refore, the first column corresponds <strong>to</strong> sec<strong>to</strong>r number 2, the second column <strong>to</strong> sec<strong>to</strong>r<br />

number 3, and so forth. <strong>The</strong> maximum quantity of HIT columns actually used will be<br />

governed by the disk formatting according <strong>to</strong> the formula: N = (number of sec<strong>to</strong>rs per<br />

track times the number of sides) minus two.<br />

In the 5-1/4" double density single-sided configuration, there exist eighteen sec<strong>to</strong>rs per<br />

cylinder - of which two are reserved for the GAT and HIT. Since only sixteen direc<strong>to</strong>ry<br />

entry sec<strong>to</strong>rs are possible, only the first sixteen positions of each HIT field are used.<br />

Other formats will use more or less columns of the HIT, depending on the quantity of<br />

sec<strong>to</strong>rs per cylinder in the formatting scheme.<br />

This arrangement works nicely when dealt with in assembly language for interfacing.<br />

Consider the DEC value of X'84'. If this value is loaded in<strong>to</strong> the accumula<strong>to</strong>r, a simple:<br />

AND 1FH ;Strip off row and<br />

ADD A,2 ; calculate sec<strong>to</strong>r<br />

will extract the sec<strong>to</strong>r number of the direc<strong>to</strong>ry cylinder containing the file's direc<strong>to</strong>ry<br />

entry. If that same value of X'84' was operated on by:<br />

AND 0E0H ;Strip off sec<strong>to</strong>r and keep row<br />

the resultant value will be the low-order starting byte of the direc<strong>to</strong>ry entry record<br />

assuming that the direc<strong>to</strong>ry sec<strong>to</strong>r was read in<strong>to</strong> a buffer starting at a page boundary.<br />

This procedure makes for easy access <strong>to</strong> the direc<strong>to</strong>ry record. <strong>The</strong> system provides two<br />

routines, @DIRRD and @DIRWR, that will read/write the correct direc<strong>to</strong>ry entry sec<strong>to</strong>r<br />

corresponding <strong>to</strong> a DEC. <strong>The</strong> direc<strong>to</strong>ry I/O uses the system buffer and a pointer in the HL<br />

register pair is au<strong>to</strong>matically positioned <strong>to</strong> the proper FPDE (the buffer is on a page<br />

boundary for physical I/O). @DIRWR performs verification after write!<br />

<strong>The</strong> following figure may help <strong>to</strong> visualize the correlation of the Hash Index Table <strong>to</strong> the<br />

direc<strong>to</strong>ry entry records. Each byte value shown represents the position in the HIT and is,<br />

in fact, the Direc<strong>to</strong>ry Entry Code value. <strong>The</strong> actual contents of each byte will be either<br />

an X'00' indicating a spare DEC, or the one-byte hash code of the file occupying the<br />

corresponding direc<strong>to</strong>ry entry record.<br />

5-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!