mov bx, Drive ;0 = default, 1 = A, 2 = B, etc.
mov ch, 08h ;device category (must be 08h)
mov cl, 61h ;Read Track on Logical Drive
mov dx, seg ReadBlock
mov ds, dx
mov dx, offset ReadBlock ;ds:dx points to RWBLOCK structure
mov ax, 440Dh ;IOCTL for Block Device
int 21h
jc error_handler ;carry set means error
Read Track on Logical Drive (Function 440Dh Minor Code 61h) reads data from a track on the specified device and places the data in memory.
Drive
Specifies the drive to be read from (0 = default drive, 1 = A, 2 = B, etc.).
ReadBlock
Points to an RWBLOCK structure that contains information that specifies the sectors to be read from. The RWBLOCK structure has the following form:
RWBLOCK STRUC
rwSpecFunc db 0 ;special functions (must be zero)
rwHead dw ? ;head to read/write
rwCylinder dw ? ;cylinder to read/write
rwFirstSector dw ? ;first sector to read/write
rwSectors dw ? ;number of sectors to read/write
rwBuffer dd ? ;address of buffer for read/write data
RWBLOCK ENDS
For a full description of the RWBLOCK structure, see Chapter 3, “File System.”
If the function is successful, the carry flag is clear. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following:
Value | Name |
0001h | ERROR_INVALID_FUNCTION |
0002h | ERROR_FILE_NOT_FOUND |
0005h | ERROR_ACCESS_DENIED |
Read Track on Logical Drive returns 0002h (ERROR_FILE_NOT_FOUND) if the specified drive number is invalid.
Function 440Dh Minor Code 41h Write Track on Logical Drive