Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Interrupt 24h
 Summary Example                         Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
     Before issuing Int 24h, MS-DOS does the following:
     Sets the AX, DI, BP, and SI registers with information about the
     error (location of the error, error value, type of device, and type
     of operation, respectively)
 
     Sets the program's stack to be the current stack. Upon entry, the
     stack is set up as follows:
 
     ┌─────────┐
     │  Flags  │ ┐
     ├─────────┤ │
     │   CS    │ ├──Flags and CS:IP pushed on stack
     ├─────────┤ │  by original Int 21h call
     │   IP    │ ┘
     ├─────────┤
     │   ES    │ ┐
     ├─────────┤ │
     │   DS    │ │
     ├─────────┤ │
     │   BP    │ │
     ├─────────┤ │
     │   DI    │ │
     ├─────────┤ │
     │   SI    │ ├──Registers at point of
     ├─────────┤ │  original Int 21h call
     │   DX    │ │
     ├─────────┤ │
     │   CX    │ │
     ├─────────┤ │
     │   BX    │ │
     ├─────────┤ │
     │   AX    │ ┘
     ├─────────┤
     │  Flags  │ ┐
     ├─────────┤ │
     │   CS    │ ├──Return address for Int 24h handler
     ├─────────┤ │
     │   IP    │ ┘
     └─────────┘  ←SS:SP on entry to Int 24h handler
 
 
     Sets internal system variables, such as InDOS and ErrorMode
     (also called Critical Error Flag). InDOS is set to zero to permit
     the handler to call system functions. ErrorMode is set to 1 to
     prevent the system from issuing Int 24h again before the handler
     returns. (MS-DOS issues only one Int 24h at a time)
 
     MS-DOS passes information about the error to the handler by using
     the following registers:
 
AH     Specifies information about when and where the error occurred,
       as well as how the critical-error handler can respond to the error.
       The bits in this register can have the following values:
 
     0    Specifies the operation that caused the error. If this bit is 0,
          the error occurred during a read. Otherwise, the error occurred
          during a write.
 
     1,2  Specifiy the location of the error, but only if the error occurred
          on a block device. These bits can have the following values:
 
          00 = error in reserved (MS-DOS area) sector
 
          01 = error in FAT
          10 = error in directory
          11 = error in data area
 
     3    Specifies whether the handler can terminate the
          function. If 1, it can. Otherwise, it must not.
 
     4    Specifies whether the handler can retry the function.
          If 1, it can. Otherwise, it must not.
 
     5    Specifies whether the handler can ignore the error. If 1, it
          can. Otherwise, it must not.
 
     6    Reserved
 
     7    Specifies the type of device on which the error occurred.
 
          If 0, the error was a block device.
 
          If 1, character device or memory image of the FAT; the handler
          must check bit 15 in the dhAttributes field (offset 04h) of the
          DEVICEHEADER structure to determine the exact location. If
          bit 15 is set, the error occurred on a character device. Otherwise,
          in the memory image of the FAT.
 
AL     Specifies the drive number (0=A, 1=B, 2=C, etc) if the error
         occurred on a block device. Not used for errors that
         occur on character devices.
 
DI     Specifies the error value, in the lower byte can be:
 
     Byte   Description
 
     00h    Write-protect error
     01h    Unknown unit
     02h    Drive not ready
     03h    Unknown command
     04h    Data error (CRC)
     05h    Bad request structure length
     06h    Seek error
     07h    Unknown media type
     08h    Sector not found
     09h    Printer out of paper
     0Ah    Write fault
     0Bh    Read fault
     0Ch    General failure
     0Dh    Reserved
     0Eh    Reserved
     0Fh    Invalid disk change (MS-DOS 3.0 and later)
 
     Note that these are the same error codes returned by the device
     driver in the request header. The upper byte of DI is undefined.
 
BP:SI     Points to the DEVICEHEADER structure that contains
              information about the device on which the error occurred.
             The structure has the following form:
 
      DEVICEHEADER STRUC
          dhLink          dd ?       ; link to next driver
          dhAttributes     dw ?       ; device attribute
          dhStrategy       dw ?       ; strat-routine offset
          dhInterrupt      dw ?       ; intrpt-routine offset
          dhNameOrUnits    db '????????'
          ; dhNameOrUnits = logical-device name (char device only)
          ;                 or number of units (block device only)
      DEVICEHEADER ENDS
 
          The handler must not change the contents of the
          DEVICEHEADER structure.
 
     Int 24h handlers must preserve the SS, SP, DS, ES, BX, CX, and DX
     registers and restore the preserved values before returning to the
     system.
 
     The critical-error handler must determine what action to take in res-
     ponse to the error. For example, the default handler displays informa-
     tion about the error and prompts the user for input on how to proceed.
 
     The Int 24h handler can call the following 21h functions:
 
          01h through 0Ch, 3300h, 3301h, 3305h, 3306h, 50h, 51h,
          62h, and 59h.
 
     Other function calls will destroy the MS-DOS stack and its
     ability to retry or ignore an error.
 
     The Int 24h handler returns to the system using the IRET instruction.
     When the Int 24h handler issues an IRET, it should return an
     action code in AL that will be interpreted by DOS as follows:
 
     Code   Description
 
     0      Ignore the error
     1      Retry the operation
     2      Terminate the program
     3      [Version 3.0+] Fail the function call in progress
                                    -♦-