Given a handle that was obtained by a previous successful open or create operation, flushes all internal buffers associated with the file to disk, closes the file, and releases the handle for reuse. If the file was modified, the time and date stamp and file size are updated in the file's directory entry.
Call with:
AH = 3EH
BX = handle
Returns:
If function successful
Carry flag = clear
If function unsuccessful
Carry flag = set
AX = error code
Note:
If you accidentally call this function with a zero handle, the standard input device is closed, and the keyboard appears to go dead. Make sure you always call the close function with a valid, nonzero handle.
Example:
Close the file whose handle is saved in the variable fhandle.
fhandle dw 0
.
.
.
mov ah,3eh ; function number
mov bx,fhandle ; file handle
int 21h ; transfer to MS-DOS
jc error ; jump if close failed
.
.
.