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

  1.         PAGE ,132
  2.  
  3. ;  Figure 5
  4. ;  Install an 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.         .DATA?
  12.  
  13.         PUBLIC cedevdvr, cetype, ceerror, cereturn
  14. _origvec        dd      ?
  15. _newvec         dd      ?
  16. cedevdvr        dd      ?
  17. cetype          dw      ?
  18. ceerror         dw      ?
  19. cereturn        db      ?
  20.  
  21.         .CODE
  22.  
  23. ;
  24. ;  This is our actual ISR
  25. ;
  26. myint24:
  27.         push    ds                      ;save registers which may be
  28.         push    es                      ;required in case "Retry" is
  29.         push    bx                      ;selected
  30.         push    cx
  31.         push    dx
  32.         push    si
  33.         push    di
  34.         push    bp
  35.         mov     word PTR cedevdvr,si    ;save device driver header address
  36.         mov     word PTR cedevdvr+2,bp
  37.         mov     cetype,ax               ;save error type information
  38.         mov     ceerror,di              ;save error code information
  39.         call    far PTR _newvec         ;call our handler
  40.         mov     al,cereturn             ;set up return code (abort, retry...)
  41.         pop     bp                      ;restore necessary registers
  42.         pop     di
  43.         pop     si
  44.         pop     dx
  45.         pop     cx
  46.         pop     bx
  47.         pop     es
  48.         pop     ds
  49.         iret
  50.  
  51. ;
  52. ;  Call this to install  our ISR
  53. ;
  54. ins24   PROC    USES AX BX DS ES, segm:WORD, offs:WORD
  55.         mov     ax,3524h                ;get old vector...
  56.         int     21h
  57.         mov     word PTR _origvec,bx
  58.         mov     word PTR _origvec+2,es  ;...and save it
  59.         mov     ax,offs                 ;load handler offset...
  60.         mov     word PTR _newvec,ax
  61.         mov     ax,segm                 ; & segment into _newvec
  62.         mov     word PTR _newvec+2,ax
  63.         push    cs                      ;get myint24 segment in DS
  64.         pop     ds
  65.         mov     dx, OFFSET myint24      ;install myint24 in int 24h
  66.         mov     ax,2524h                ;  into Interrupt 24h
  67.         int     21h
  68. ins24   ENDP
  69.  
  70. ;
  71. ;  Call this to uninstall our ISR
  72. ;
  73. redo24  PROC    USES AX BX DS
  74.         mov     dx, word PTR _origvec   ;restore original vector
  75.         mov     ds, word PTR _origvec+2
  76.         mov     ax,2524h
  77.         int     21h
  78.         ret
  79. redo24  ENDP
  80.  
  81.         end
  82.