Function 32h Get DPB

mov dl, DriveNum ;drive (0 = default, 1 = A, etc.)

mov ah, 32h ;Get DPB

int 21h

cmp al, 0FFh ;0FFh means error

jz error_handler

mov word ptr [defaultDPB], bx

mov word ptr [defaultDPB+2], ds ;ds:bx points to default DPB

Get DPB (Function 32h) retrieves drive parameters for the specified drive.

Parameter

DriveNum

Specifies the number of the drive to return information for (0 = default, 1 = A, 2 = B, and so on).

Return Value

If the function is successful, the AL register contains zero and the DS:BX registers point to a DPB structure that contains the drive parameters. The DS register contains the segment address, and the BX register contains the offset. Otherwise, if the specified drive was invalid or a disk error occurred, the AL register contains 0FFh.

Comments

If Get DPB is successful, the DS:BX registers point to a DPB structure, which has the following form:

DPB STRUC

dpbDrive db ? ;drive number (0 = A, 1 = B, etc.)

dpbUnit db ? ;unit number for driver

dpbSectorSize dw ? ;sector size, in bytes

dpbClusterMask db ? ;sectors per cluster - 1

dpbClusterShift db ? ;sectors per cluster, as power of 2

dpbFirstFAT dw ? ;first sector containing FAT

dpbFATCount db ? ;number of FATs

dpbRootEntries dw ? ;number of root-directory entries

dpbFirstSector dw ? ;first sector of first cluster

dpbMaxCluster dw ? ;number of clusters on drive + 1

dpbFATSize dw ? ;number of sectors occupied by FAT

dpbDirSector dw ? ;first sector containing directory

dpbDriverAddr dd ? ;address of device driver

dpbMedia db ? ;media descriptor

dpbFirstAccess db ? ;indicates access to drive

dpbNextDPB dd ? ;address of next drive parameter block

dpbNextFree dw ? ;last allocated cluster

dpbFreeCnt dw ? ;number of free clusters

DPB ENDS

For more information about the DPB structure, see Chapter 3, “File System.”

See Also

Function 1Fh Get Default DPB