DOS Fn 40H: Write to File via Handle

                                                         Compatibility: 2.0+ 
 Expects: AH    40H
          BX    file handle
          CX    number of bytes to write (Note: 0 means truncate the file)
          DS:DX address of a buffer containing the data to write
          ──────────────────────────────────────────────────────────────────
 Returns: AX    error code if CF is set to CY
                number of bytes actually written ◄════ use for error test
          ──────────────────────────────────────────────────────────────────
    Info: Writes CX bytes of data to the file or device with handle number
          in BX.  The data is taken starting from the caller's buffer
          pointed to by DS:DX.  The data is written to the current position
          of the file's read/write pointer.

          This updates the file's read/write pointer to set up for a
          subsequent sequential-access read or write.  To write to a
          specific part of a file, use Fn 42H (Lseek) before this call.

Versions: 3.0+ If CX is 0000H on entry, the file is truncated at the
          current file position -- or the file is padded to that position.

          6.0+ (on Doublespace compressed drive) when you seek some large
          distance past the end of the file and then write some data,
          DoubleSpace may not allocate disk space for the unwritten bytes.
          The compression ratio for such data is considered "infinite".
          See MDFAT.

   Notes: ■ You should always compare the return value of AX (number of
            bytes written) to CX (requested write size):

            • if AX = CX, the write was successful
            • if AX < CX, an error occurred (most likely a full disk).
              Note that Carry is not set for this "error".

          ■ It is handy to use this function for writing to default handles
            such as the Standard Output instead of using the various text
            output functions.

See Also: Handle-Oriented File I/O
          DOS Functions
                                    -♦-