H-17 Disk System


Programming Table of Contents

Main Table of Contents

Page Index H-17 Disk Format
Label
Group Reservation Table (GRT)
Directory
  Low-Level Driver Calls
Register Usage
Read
Write
Read Regardless
Abort
Mount
Ready
  Sample Program
 

H-17 Disk Format


Low-Level Driver Calls


Sample Program

    The following very short program uses several of the low-level driver functions in order to read a disk's label and it's first directory block. A set of notes keyed to the source code follows the code.

    *      Using low-level disk driver calls, mount a disk
    *      and read the first directory block.
    *
    AIO.UNI EQU     41061A      Disk unit number (0, 1, 2)
    D.SYDD  EQU     40130A      Addr of jump to driver
    LAB.SER EQU     0           Label offset of volume serial number
    LAB.DIS EQU     3           Label offset of first directory sector
    *
    DC.REA  EQU      000Q        Read driver command
    DC.ABT  EQU      007Q        Abort the driver
    DC.MOU  EQU      010Q        Mount driver command
    DC.RDY  EQU      012Q        Check for disk ready
    .EXIT   EQU     0           Exit HDOS scall command
    .PRINT  EQU     3           Print HDOS scall command
    *
            ORG     100000A     Above dbug
    *
    START   EQU     *
    *
    *       See note 1
    *
            MVI     A,1
            STA     AIO.UNI     Set unit number
    *
    *       See note 2
    *
            MVI     A,DC.ABT
            CALL    D.SYDD      Clean up the driver
    *
            LXI     H,MNT.MSG
            SCALL   .PRINT
    *
    READY   EQU     *
    *
    *       See note 3
    *
            MVI     A, DC.RDY
            CALL    D.SYDD
            JC      READY       Wait for ready
    *
    *       See note 4
    *
            MVI     L,0         (L) = Volume number
            MVI     A, DC.MOU
            CALL    D.SYDD      Mount as volume zero
    *
            LXI     H,9         Sector ndx of label
            LXI     D,LABEL
            LXI     B,256       1 sector long
            MVI     A, DC.REA
            CALL    D.SYDD      Read the label
    *
    *       See note 5
    *
            LDA      LABEL+LAB.SER
            MOV     L,A         (L) = Volume number
            MVI     A, DC.MOU
            CALL    D.SYDD      Remount with correct volume serial
    *
    *       See note 6
    *
            LHLD     LABEL+LAB.DIS  (HL) = First directory sector
            LXI     D,DIRECT
            LXI     B,512       Two sectors this time
            MVI     A, DC.REA
            CALL    D.SYDD      Read first directory block
    *
    *       See note 7
    *
            XRA     A           Set breakpoint here and inspect buffers
            SCALL   .EXIT
    *
    MNT.MSG DB      'Insert a disk into drive SY1:',212Q
    LABEL   DS      256
    DIRECT  DS      512
            END     START

    Notes:

    1. Always ensure that AIO.UNI has the correct device number in it before making a low-level driver call. In this case, we're expecting the disk to be inserted into physical device #1.

    2. Aborting the driver cleans up from short reads, errors, and other bad conditions, and ensures that the driver is ready for business.

    3. We've asked for a disk to be inserted into device #1. We'll stay in this loop until device #1 is ready; i.e., there is a disk inserted. If there is already a disk in the drive, it will be ready immediately.

    4. We could use the Read Regardless call here, but I chose to mount the disk with volume serial number zero and then use Read to get the label. We need the label so we can get the correct serial number, and for the first directory block index.

    5. Having read the label, we can remount the disk with the correct volume serial number in preparation for reading the directory block. If we subsequently had to reread the label, we could use Read Regardless to get it without remounting the disk.

    6. The first directory block sector index is at offset LAB.DIS from the beginning of the label. Note that we're reading two sectors in one call with this read.

    7. This disk can be removed from the drive without notifying HDOS. In fact, it hasn't been mounted to HDOS at all - it's only had its volume serial number recorded for low-level driver access - so it's inaccessible to HDOS proper.

    go to top


Programming Table of Contents

Main Table of Contents