Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  The address associated with interrupt 24H (decimal 36) points to the
  interrupt-handling routine invoked whenever DOS detects a "critical
  error"-- an emergency situation that prevents DOS from continuing with
  normal processing. Typically, the critical error is a disk error, but
  other errors are also reported, as we'll see.

  Like interrupt 23H, interrupt 24H is intended to be invoked only by DOS,
  not by an application program. However, an application can substitute its
  own interrupt 24H handler for the default DOS handler. The DOS default
  handler produces a familiar message (shown on the following page).

  Abort, Retry, Ignore?           (in DOS versions prior to 3.3)

  or

  Abort, Retry, Fail?             (in DOS versions 3.3 and later)

  If you substitute a customized interrupt 24H handler for the one DOS
  provides, you can tailor critical-error handling to the needs of your
  program.

  When DOS transfers control to a critical-error handler, it provides
  several sources of information about the error itself, and about the state
  of the system before the error occurred. These sources include the
  register pair BP:SI, the stack, the AH register, and the DI register. We
  will cover them one by one because this process is quite complicated.

  If you are operating under DOS version 2.0 or later, the register pair
  BP:SI is set to point to a device-header control block. Your
  critical-error handler can inspect the device header to learn more about
  the device (disk drive, printer, and so forth) that experienced the error.
  (See the DOS technical reference manuals for more about the device
  header.)

  When the critical-error handler gains control, the stack contains the
  complete register set of the program that issued the DOS function call
  that ended in the critical error. This information can be quite useful to
  an error handler that is intimately integrated with the active program.
  The usual method of accessing the information on the stack is to address
  the stack through register BP. You can access the stack as shown in Figure
  15-5 on the following page if the first two instructions in your
  critical-error handler are

  PUSH    BP
  MOV     BP,SP

  DOS indicates the nature of a critical error primarily through a
  combination of the high-order bit of the AH register and the low-order
  byte of the DI register (a curious choice, for sure). If the high-order
  bit of AH is 0, the error is related to a disk operation. If the same bit
  (bit 7 of AH) is 1, the error is something other than a disk error, as we
  shall discuss shortly.

  When the error is a disk-device error (high-order bit of AH is 0),
  register AL identifies the drive number (0 is drive A, 1 is drive B, and
  so on). Bits 0 through 5 of AH indicate further information about the
  error, as shown in Figure 15-6.

            +-------------+ --+
  [BP + 30] |    Flags    |   |
            |-------------|   |
  [BP + 28] |     CS      |   |-- Flags and CS:IP pushed by the
            |-------------|   |   interrupt 21H call that generated
  [BP + 26] |     IP      |   |   the error
            |-------------| --|
  [BP + 24] |     ES      |   |
            |-------------|   |
  [BP + 22] |     DS      |   |
            |-------------|   |
  [BP + 20] |     BP      |   |
            |-------------|   |
  [BP + 18] |     DI      |   |
            |-------------|   |
  [BP + 16] |     SI      |   |-- Registers at point of interrupt 21H call
            |-------------|   |
  [BP + 14] |     DX      |   |
            |-------------|   |
  [BP + 12] |     CX      |   |
            |-------------|   |
  [BP + 10] |     BX      |   |
            |-------------|   |
   [BP + 8] |     AX      |   |
            |-------------| --|
   [BP + 6] |    Flags    |   |
            |-------------|   |
   [BP + 4] |     CS      |   |-- Flags and CS:IP pushed by DOS when it
            |-------------|   |   called the critical-error handler
   [BP + 2] |     IP      |   |
            |-------------| --+
       [BP] | Previous BP |
            +-------------+

  Figure 15-5.  Information passed on the stack to an interrupt 24H
  (critical-error) handler.

          Bit
  5 4 3 2 1 0        Value             Meaning
  --------------------------------------------------------------------------
  . . . . . 0        0                 Read error
  . . . . . 1        1                 Write error
  . . . 0 0 .        0                 Error involved DOS system files
  . . . 0 1 .        1                 Error involved file allocation table
  . . . 1 0 .        2                 Error involved root directory
  . . . 1 1 .        3                 Error involved files area of disk
  . . 1 . . .        1                 Fail response allowed
  . 1 . . . .        1                 Retry response allowed
  1 . . . . .        1                 Ignore response allowed
  --------------------------------------------------------------------------

  Figure 15-6.  The bit values and associated errors indicated in bits 0
  through 5 of the AH register when DOS invokes interrupt 24H.

  DOS returns additional information about the error in the low-order byte
  of register DI (Figure 15-7). The error codes in DI cover a variety of
  input/output devices, so you must rely on a combination of the information
  in AH and in DI to determine the exact nature of the critical error.

  If bit 7 of AH is set, the error is probably not a disk error, though it
  may be disk related. One disk-related error normally reported when bit 7
  of AH is set is an error in the disk's FAT. In DOS version 1, this is
  always the case. For versions 2.0 and later, the error handler should
  inspect bit 15 of the word that is offset 4 bytes into the device header
  (BP: [SI + 4]). If this bit is clear, the device is a block device (disk)
  and the error is a FAT error. If this bit is set, the device is a
  character device, in which case the low-order byte of DI defines the exact
  problem (the high-order byte should be ignored). DI error-code values
  shown in Figure 15-7 are essentially the same as those reported in AL for
  interrupts 25H and 26H (decimal 37 and 38).

  You can use the following interrupt 21H functions in your critical-error
  handler to report what's going on to the program's user:

  .  Functions 01H through 0CH, which provide simple keyboard and display
     services

  .  Function 30H, which returns the DOS version number

  .  Function 59H, which returns extended error information in DOS versions
     3.0 and later

  Error Code
  Hex    Dec         Description
  --------------------------------------------------------------------------
  00H     0          Write-protect error; attempt to write on protected
                     diskette
  01H     1          Unknown unit (invalid drive number)
  02H     2          Drive not ready (no diskette or drive door open)
  03H     3          Unknown command requested
  04H     4          Data error (CRC)
  05H     5          Bad request structure length
  06H     6          Seek error; move to requested cylinder failed
  07H     7          Unknown disk format
  08H     8          Sector not found
  09H     9          Printer out of paper
  0AH    10          Write fault
  0BH    11          Read fault
  0CH    12          General, nonspecific error
  0FH    15          Invalid disk change (DOS version 3.0 or later)
  --------------------------------------------------------------------------

  Figure 15-7.  Errors indicated in the low-order byte of register DI when
  DOS invokes interrupt 24H.

  Don't call other DOS services within your critical-error handler, however,
  because other services may overwrite internal buffers or stacks that DOS
  will need when the error handler returns.

  Normally, an error-handler routine returns to DOS after doing whatever it
  chooses to do. DOS can then take one of four courses of action: It can
  ignore the error, try the operation again, terminate the program, or fail
  the requested operation and return to the program (DOS versions 3.1 and
  later). You tell DOS which course you want it to take by loading a value
  from Figure 15-8 into the AL register before executing an IRET to return
  to DOS.

  If you use a custom critical-error handler, it will remain in effect only
  as long as the program that installs it is running. When the program
  terminates, DOS replaces the contents of the interrupt 24H vector with the
  address of the default critical-error handler.

  AL                 Description
  --------------------------------------------------------------------------
  00H                Ignore the error and press onward.
  01H                Retry the operation.
  02H                Terminate the program.
  03H                Fail the operation (DOS versions 3.1 and later).
  --------------------------------------------------------------------------

  Figure 15-8.  Values that can be returned to DOS in register AL by an
  interrupt 24H (critical-error) handler.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson