Function 40h (64)        Write to File or Device, Using a Handle

Write bytes from a buffer to a file or device.

On entry:      AH         40h
BX         File handle
CX         Number of bytes to write
DS:DX      Address of buffer

Returns:       AX         Number of bytes written, or
Error code, if CF is set

Error codes:   5          Access denied
6          Invalid handle

Call function 59h for extended error code information
(DOS 3.0 and above).

Network:       Requires Write access rights

                                                                          

This function writes data to the file or device whose handle is in BX.
Data is written starting at the current file pointer. The file pointer
is then incremented by the number of bytes written.

Notes:         If a disk full condition is encountered, no error
code will be returned (i.e., CF will not be set);
however, fewer bytes than requested will have been
written. You should check for this condition by
testing for AX less than CX after returning from the
function.

A file can be truncated my moving the file pointer
to the new end of file (with function 42h) and
calling this function with CX = 0.

You can write bytes to anywhere in the file by
calling function 42h to move to file poniter before
writing data.

Writing to a file marked "read-only" will generate
an error code of 5, "access denied."

See also: 15h
See also: 22h
See also: 28h
See also: 42h
See also: 59h

40h (64) Write to File or Device, Using a Handle