mov bx, Drive ;0 = default, 1 = A, 2 = B, etc.
mov ch, 08h ;device category (must be 08h)
mov cl, 41h ;Write Track on Logical Drive
mov dx, seg WriteBlock
mov ds, dx
mov dx, offset WriteBlock ;ds:dx points to RWBLOCK structure
mov ax, 440Dh ;IOCTL for Block Device
int 21h
jc error_handler ;carry set means error
Write Track on Logical Drive (Function 440Dh Minor Code 41h) writes data from a buffer to a track on the specified device.
Drive
Specifies the drive information is to be written to (0 = default drive, 1 = A, 2 = B, etc.).
WriteBlock
Points to an RWBLOCK structure that contains information that specifies the sectors to be written to. The rwBuffer field must contain the address of the buffer that contains the data to write to the disk. 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 |
Write Track on Logical Drive returns 0002h (ERROR_FILE_NOT_FOUND) if the specified drive number is invalid.
Function 440Dh Minor Code 61h Read Track on Logical Drive