This article was previously published under Q37345
This article has been archived. It is offered "as is" and will no longer be updated.
The ROM BIOS Interrupt 19 decimal (13 hex), with function 2, returnsthe status of a specified disk if it is unable to read the specifiedsector. This interrupt can be used to determine if the drive door isopen, if the disk is formatted, if the disk is write-protected, andmany other conditions. The code generated for this is smaller than asimilar program using ON ERROR GOTO statements to trap disk errors.
Note that ROM BIOS and MS-DOS Interrupts are not allowed in MS OS/2protected mode.
ROM BIOS Interrupt call 19 provides a set of functions to access thedisk driver. Interrupt 19 with function 2 reads one or more sectorsfrom disk into memory. Interrupt 19 with function 0 (reset disk system)should be called after a failed floppy disk Read, Write, Verify, orFormat request before retrying the operation. For more informationabout this and other interrupts for IBM ROM BIOS and MS-DOS, see"Advanced MS-DOS Programming, Second Edition," by Ray Duncan(Microsoft Press, 1988).
Unlike other MS-DOS interrupt functions that access the disk drive usingCALL INTERRUPT or CALL INTERRUPTX in Microsoft QuickBasic for MS-DOS,versions 4.0, 4.0b, or 4.5; or Microsoft Basic Compiler for MS-DOS orMS OS/2 (real mode only), versions 6.0 or 6.0b; Interrupt 19 with function2 and 0 does NOT cause a system hang if a critical error occurs (such asif a drive door is open or a disk is not formatted).
Note: The CALL INTERRUPT or CALL INTERRUPTX statement hanging uponcritical disk errors is a known problem with the INTERRUPT andINTERRUPTX routines in Microsoft QuickBasic for MS-DOS, versions 4.0,4.0b, and 4.5; and Microsoft Basic Compiler for MS-DOS and MS OS/2(real mode only), versions 6.0 and 6.0b. This problem was corrected inMicrosoft Basic PDS for MS-DOS and MS OS/2 (real mode only),version 7.0. For information on how to modify the INTERRUPT andINTERRUPTX routines so that critical errors will not hang the machinein Microsoft QuickBasic for MS-DOS, versions 4.0, 4.0b, and 4.5; andMicrosoft Basic Compiler for MS-DOS and MS OS/2 (real mode only),versions 6.0 and 6.0b; query the Knowledge Base onthe following keyword:
Listed below is a code example for calling ROM BIOS Interrupt call 19decimal (13h) with functions 0 and 2. In order to run this program inthe QB.EXE environment for Microsoft QuickBasic (or QBX.EXE forMicrosoft Basic PDS), you must invoke QB /L QB.QLB (or QBX /L QBX.QLBfor Microsoft Basic PDS). To link this program into an .EXE program, youmust link with QB.LIB (or QBX.LIB for Basic PDS) (which is doneautomatically when you choose the Make EXE File command from the Filemenu in the environment).
' To try this example in VBDOS.EXE:' 1. From the File menu, choose New Project.' 2. Copy the code example to the Code window.' 3. Press F5 to run the program.'' To run this program in the encironment, you must invoke the' environment with ther /L switch to load the default Quick library:' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS'DECLARE SUB ResetDrive (drive%)DECLARE SUB ReadSector (drive%, sector%)' Use the following include file for Visual Basic 1.0 for MS-DOS:REM $INCLUDE: 'VBDOS.BI'' Use the following include file for QuickBasic for MS-DOS:REM $INCLUDE: 'QB.BI'' Use the following include file for Basic PDS for MS-DOS:REM $INCLUDE: 'QBX.BI'DIM reg AS RegTypeX, regS AS RegTypeDIM databuffer%(5120) ' Room for 10 sectors of data.sector% = 1 ' Sector number 1-9.drive% = 0 ' Drive A.FOR i = 1 TO 3 CALL ReadSector(drive%, sector%) CALL ResetDrive(drive%) PRINT reg.flags, (reg.flags AND 1) IF (reg.flags AND 1) = 1 THEN errornum = reg.ax AND &HFF ELSE errornum = 0 END IFNEXTPRINT errornumENDSUB ReadSector (drive%, sector%)SHARED databuffer%(), reg AS RegTypeX intnum% = 19 ' Interrupt number 19 decimal (13 hex). numsectors% = 1 ' # read 1,8, or 9. track% = 0 ' track# 0-39. head% = 0 ' side 0 or 1. reg.ds = -1 reg.es = VARSEG(databuffer%(0)) reg.bx = VARPTR(databuffer%(0)) reg.cx = 256 * track% + sector% reg.dx = 256 * head% + drive% ' AH loaded with function 2; AL loaded with number of sectors. reg.ax = 2 * 256 + numsectors% ' AX register contains AH and AL CALL interruptx(intnum%, reg, reg)END SUBSUB ResetDrive (drive%) DIM reg AS RegTypeX reg.ax = 0 ' function number 0 reg.dx = drive% CALL interruptx(&H13, reg, reg)END SUB
Microsoft Visual Basic for MS-DOS, Microsoft QuickBasic 4.0, Microsoft QuickBASIC 4.0b, Microsoft QuickBasic 4.5 for MS-DOS, Microsoft BASIC Compiler 6.0, Microsoft BASIC Compiler 6.0b, Microsoft BASIC Professional Development System 7.0, Microsoft BASIC Professional Development System 7.1