Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
GetDiskSize
◄Example► ◄Back► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
;* GetDiskSize - Gets size information from specified disk.
;*
;* Shows: DOS Function - 36h (Get Drive Allocation Information)
;*
;* Params: drive - Drive code (0 = default, 1 = A, 2 = B, etc.)
;* disk - Pointer to a structure with 4 short integer members:
;* Member 1 - Total clusters on disk
;* Member 2 - Number of available clusters
;* Member 3 - Sectors/cluster (-1 if invalid drive)
;* Member 4 - Bytes/sector
;*
;* Return: None
GetDiskSize PROC \
USES di, \
drive:WORD, disk:PTR WORD
mov dx, drive ; DL = drive code
mov ah, 36h ; DOS Function 36h
int 21h ; Get Drive Allocation Information
LoadPtr es, di, disk ; ES:DI = disk structure
mov es:[di].total, dx ; DX = total clusters
mov es:[di].avail, bx ; BX = number of free clusters
mov es:[di].sects, ax ; AX = sectors/cluster
mov es:[di].bytes, cx ; CX = bytes/sector
ret
GetDiskSize ENDP
-♦-