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

  1.         PAGE ,132
  2.  
  3. ;  Figure 1
  4. ;  Install a custom Interrupt 23 (Ctrl-C 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. _origvec        dd      ?
  13. _newvec         dd      ?
  14.  
  15.         .CODE
  16.  
  17. ;
  18. ;  This is our actual ISR
  19. ;
  20. myint23:
  21.         call    dword PTR _newvec       ;call our handler
  22.         iret
  23.  
  24. ;
  25. ;  Call this to install  our ISR
  26. ;
  27. ins23   PROC    USES AX BX DS ES, segm:WORD, offs:WORD
  28.         mov     ax,3523h                ;get old vector...
  29.         int     21h
  30.         mov     word PTR _origvec,bx
  31.         mov     word PTR _origvec+2,es  ;...and save it
  32.         mov     ax,offs                 ;load handler offset...
  33.         mov     word PTR _newvec,ax
  34.         mov     ax,segm                 ; & segment into _newvec
  35.         mov     word PTR _newvec+2,ax
  36.         push    cs                      ;get myint23 segment in DS
  37.         pop     ds
  38.         mov     dx, OFFSET myint23      ;install myint23 in int 23h
  39.         mov     ax,2523h
  40.         int     21h
  41.         ret
  42. ins23   ENDP
  43.  
  44. ;
  45. ;  Call this to uninstall our ISR
  46. ;
  47. redo23  PROC    USES AX BX DS
  48.         mov     dx, word PTR _origvec   ;restore original vector
  49.         mov     ds, word PTR _origvec+2
  50.         mov     ax,2523h
  51.         int     21h
  52.         ret
  53. redo23  ENDP
  54.  
  55.         end
  56.