Function 36h Get Disk Free Space

mov dl, Drive ;drive (0 = default, 1 = A, 2 = B, etc.)

mov ah, 36h ;Get Disk Free Space

int 21h

cmp ax, 0FFFFh ;0FFFFh means drive not valid

je error_handler

mov SectorsPerCluster, ax ;sectors per cluster

mov AvailClusters, bx ;number of available clusters

mov BytesPerSector, cx ;bytes per sector

mov TotalClusters, dx ;total number of clusters on disk

Get Disk Free Space (Function 36h) returns the number of clusters available on the disk in the specified drive and the information necessary to calculate the number of bytes available on the disk.

Parameter

Drive

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

Return Values

If the function is successful, the AX, BX, CX, and DX registers contain the following information:

Register Contents

AX The number of sectors in a cluster
BX The number of clusters available on the disk
CX The number of bytes in a sector
DX The total number of clusters on the disk

Otherwise, the AX register contains 0FFFFh.

Comments

The number of free bytes on the disk can be calculated by multiplying the available clusters by the sectors per cluster by the bytes per sector (BX*AX*CX).

MS-DOS reports sectors allocated in the file allocation table (FAT) but not belonging to a file (lost clusters) as used clusters, just as if they were allocated to a file.

See Also

Function 1Bh Get Default Drive Data
Function 1Ch Get Drive Data