Function 08H (8): Write

The write function transfers data from the specified memory buffer to the device. If an error is encountered during the write, the write function must set the error status and, in addition, report the number of bytes or sectors successfully transferred; it is not sufficient to simply report an error.

The write function is called with

RH + 1 BYTE Unit code (block devices)

RH + 2 BYTE Command code = 8

RH + 13 BYTE Media descriptor byte

RH + 14 DWORD Transfer address

RH + 18 WORD Byte/sector count

RH + 20 WORD Starting sector number (block

devices)

For block-device write operations in MS-DOS version 4, if the logical unit is larger than 32 MB and bit 1 of the driver's attribute word is set, the following request structure is used instead:

RH + 1 BYTE Unit code

RH + 2 BYTE Command code = 8

RH + 13 BYTE Media descriptor byte

RH + 14 DWORD Transfer address

RH + 18 WORD Sector count

RH + 20 WORD Contains -1 to signal use of 32-bit

sector number

RH + 26 DWORD 32-bit starting sector number

The write function returns

RH + 3 WORD Status

RH + 18 WORD Actual bytes or sectors transferred

RH + 22 DWORD Pointer to volume label if error 0FH

returned (MS-DOS versions 3.0 and

later)

Under MS-DOS versions 3.0 and later, this routine can use the reference count of open files maintained by the open and close functions (0DH and 0EH) and the media descriptor byte to determine whether the disk has been illegally changed.