home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_06 / 1n06020a < prev    next >
Text File  |  1990-08-13  |  4KB  |  105 lines

  1.         PAGE ,132
  2.  
  3. ;  Figure 6
  4. ;  A sample Interrupt 24 (DOS critical error exception) handler
  5.  
  6.  
  7. %       .MODEL  memodel,lang            ;Add model and language support via
  8.                                         ;command line macros, e.g.
  9.                                         ;MASM /Dmemodel=LARGE /Dlang=C
  10.  
  11.         EXTRN cedevdvr:dword, cetype:word, ceerror:word, cereturn:byte
  12.         EXTRN read_err:far, write_err:far, bad_FAT:far
  13.         EXTRN no_paper:far, fixup_ret:far, FAT_err:far
  14.  
  15.         ;NOTE:  All the above routines MUST set cereturn to:
  16.         ;       0 - Ignore
  17.         ;       1 - Retry
  18.         ;       2 - Abort
  19.         ;       3 - Fail (DOS 3.3 and later)
  20.  
  21.         .DATA?
  22.  
  23.         PUBLIC  osver, rmvbl, exerr, locus, class, suggest
  24. osver   db ?
  25. rmvbl   db ?
  26. exerr   dw ?
  27. locus   db ?
  28. class   db ?
  29. suggest db ?
  30.  
  31.         .CODE
  32.  
  33. ;
  34. ;  This is called by myint24
  35. ;
  36. mynew24 PROC    USES BX
  37.         mov     ah,030h                 ;get DOS version number
  38.         int     21
  39.         or      al,al                   ;zero means DOS 1.x
  40.         jnz     NotDOS1
  41.         mov     al,1
  42. NotDOS1:
  43.         mov     osver,al                ;save DOS version
  44.         mov     ax,cetype               ;get type of exception...
  45.         mov     bx,ax                   ; & save it for later
  46.         and     ax,80h                  ;disk error?
  47.         jnz     NotDiskErr              ;no, continue
  48.         cmp     al,1                    ;yes, DOS 1.x?
  49.         jz      wrong_DOS               ;yes, can't check for removable media
  50.         mov     ah,-1                   ;no, assume removable media
  51.         test    word PTR cedevdvr,0800h ;is the media removable?
  52.         jz      removable
  53.         xor     ah,ah                   ;no, flag fixed media
  54. removable:
  55.         mov     rmvbl,ah                ;save media type
  56.         cmp     al,3                    ;DOS 3.0 or greater?
  57.         jb      wrong_DOS               ;no, skip it
  58.         push    ds                      ;yes, save regs
  59.         push    es
  60.         push    dx
  61.         push    si
  62.         push    di
  63.         push    bp
  64.         mov     ah,59h                  ;get extended error info
  65.         int     21
  66.         pop     bp                      ;restore regs
  67.         pop     di
  68.         pop     si
  69.         pop     dx
  70.         pop     es
  71.         pop     ds
  72.         mov     exerr,ax                ;save extended error code...
  73.         mov     locus,ch                ; locus...
  74.         mov     class,bh                ;  class...
  75.         mov     suggest,bl              ;   & suggested action
  76. wrong_DOS:
  77.         mov     ax,bx                   ;get exception type
  78.         and     ax,06h                  ;FAT problems?
  79.         cmp     ax,02h
  80.         jnz     ok_fat                  ;no, continue
  81.         jmp     far PTR FAT_err         ;yes, handle it
  82. ok_fat:
  83.         mov     ax,bx                   ;get exception type
  84.         and     ax,01h                  ;handle read and write separately
  85.         jz      rd_err
  86.         jmp     far PTR write_err
  87. rd_err:
  88.         jmp     far PTR read_err
  89. NotDiskErr:
  90.         test    word PTR cedevdvr,8000h ;non-disk block device?
  91.         jnz     good_fat                ;no, continue
  92.         jmp     far PTR bad_FAT         ;yes, assume bad FAT
  93. good_fat:
  94.         test    ceerror,0009h           ;printer out of paper?
  95.         jnz     not_eop                 ;no, continue
  96.         jmp     far PTR no_paper        ;yes, handle it
  97. not_eop:
  98.         call    far PTR fixup_ret       ;unknown error - handle loose ends...
  99.         mov     al,2                    ; & Abort!
  100.         mov     cereturn,al
  101.         ret
  102. mynew24 ENDP
  103.  
  104.         end
  105.