mov bx, Handle ;handle of file or device
mov ax, 4407h ;Check Device Output Status
int 21h
jc error_handler ;carry set means error
cmp al, 0FFh ;0FFh means file or device is ready
jne not_ready
Check Device Output Status (Function 4407h) determines whether a file or device is ready for output.
Handle
Identifies the file or device to check.
If the function is successful, the carry flag is clear and the AL register contains the output-status value. 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 |
0005h | ERROR_ACCESS_DENIED |
0006h | ERROR_INVALID_HANDLE |
The meaning of the output-status value depends on whether the handle specifies a file or a device, as shown in the following table:
Status | Device | File |
00h | Not ready | Ready |
0FFh | Ready | Ready |
For an output file, Check Device Output Status always returns Ready, even if the disk is full or there is no disk in the drive.
Function 4406h Check Device Input Status