Memory resident workspaces
To process the diskettes, DOS creates various data structures in the last 310 bytes of the available RAM memory, which contain processing vectors, file management blocks and input/output buffers (Figure 1.7).
Figure 7.1 The memory areas of DOS
DOS vectors
The first 67 bytes of this DOS work area contain the DOS vectors.
The address of the start of the DOS vectors is stored by DOS during system initialization to the Z80 register ‘IY’. DOS expects that this register will not be changed by user programs, otherwise a system crash will inevitably occur and data on the diskette may also be destroyed (bitter experience of the author).
The DOS vector area is structured as follows:
DOSVTR = IY
Name |
Bytes |
Offset |
Description |
FILNO |
1 |
IY+0 |
File number. |
FNAM |
8 |
IY+1 |
Filename |
TYPE |
2 |
IY+9 |
File Type |
DK |
1 |
IY+11 |
Selected Drive. |
RQST |
1 |
IY+12 |
Access type. |
SOURCE |
1 |
IY+13 |
Starting drive (source) used by |
UBFR |
2 |
IY+14 |
Address of a user buffer area to or |
DESTIN |
1 |
IY+16 |
Target drive for the DCOPY command |
SCTR |
1 |
IY+17 |
Number of the Sector to be addressed |
TRCK |
1 |
IY+18 |
Number of the Track to be addressed |
RETRY |
1 |
IY+19 |
Retry counter for read errors |
DTRCK |
1 |
IY+20 |
Current track number over which the |
NSCT |
1 |
IY+21 |
Marker field for the next sector to be |
NTRK |
1 |
IY+22 |
Marker field for the next track to be |
FCB1 |
13 |
IY+23 |
File Control Block 1. |
FCB2 |
13 |
IY+36 |
File Control Block 2. |
DBFR |
2 |
IY+49 |
Pointer to the DOS data buffer for |
LTHCPY |
1 |
IY+51 |
Copy of the command byte sent to the |
MAPADR |
2 |
IY+52 |
Pointer to the DOS buffer in which the |
TRKCNT |
1 |
IY+54 |
Track counter for the DCOPY |
TRKPTR |
1 |
IY+55 |
Track pointer for the DCOPY |
PHASE |
1 |
IY+56 |
Step pulse raster for track adjustment. |
DCPYF |
1 |
IY+57 |
Flag for DCOPY |
RESVE |
10 |
IY+58 |
reserved for extensions. |
File Control Blocks (FCB)
Within the DOS vectors are two 13 byte file control blocks, FCB1 and FCB2.
These are required when processing data files in order to keep status and control information about the file being accessed.
A free file control block is determined by the OPEN command and provided with the necessary parameters for the file to be opened.
The IN# and PR# commands are based on the relevant file control block, e.g. which sector of the file is to be read and at which byte of this sector processing is to be continued.
The file control blocks are released again by the CLOSE command.
Since there are only two of these blocks, only two files can be open at the same time.
The File Control Block has the following structure:
FCB1 or FCB2
Name |
Bytes |
Offset |
Description |
FLAG |
1 |
0 |
Indicates the status of the FCB. |
ACCESS |
1 |
1 |
Access type for this file. |
FNAM |
8 |
2 |
Filename |
TRK# |
1 |
10 |
Track Number |
SCTR# |
1 |
11 |
Sector Number of currently processed Sector |
PTR |
1 |
12 |
Pointer to the next byte to be processed |
Input/Output Buffer
In the DOS work area there are two buffer areas, one for temporary storage of the sectors to be read or written and a second for the sector occupancy overview.
Data Buffer (DBFR)
This buffer has a size of 154 bytes and serves as a buffer for direct data exchange with the floppy disk.
When writing, the sectors are transferred from the data buffer to the diskette; when reading, the sectors are transferred from the diskette to the data buffer.
During initialization, the 10 bytes of the data mark are set in front of the data buffer, so that a complete information block (data mark + data field) is available when a sector is written.
During normal read/write operations, only the first 128 bytes of the data buffer are used to hold a sector’s data field.
The full length of 154 bytes is only required during diskette initialization to accommodate a complete sector, including all sync fields, address fields, and identifiers.
Allocation Map Sector (MAP)
At the end of the DOS work area there is an 80-byte buffer area in which the Allocation Map from sector 15 of track 0 on the diskette is buffered.
When saving a program or writing a data file, the sectors are selected and allocated exclusively in this buffer area after the current sector has been read in at the beginning. Only when the saving process for the program is complete, the Allocation Map (MAP) is written back to the diskette.