home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / CCTRAP.ASM < prev    next >
Assembly Source File  |  1997-07-05  |  2KB  |  67 lines

  1. ;  +++Date last modified: 05-Jul-1997
  2.  
  3.         PAGE ,132
  4.  
  5. ;  Install a custom Interrupt 23 (Ctrl-C exception) handler
  6. ;
  7. ;  Public domain by Bob Stout
  8. ;
  9. ;  Requires MASM 5.1 or later or equivalent
  10. ;
  11. ;  Assemble with:       MASM /Mx /z ...
  12. ;                       TASM /jMASM /mx /z ...
  13.  
  14.  
  15. %       .MODEL  memodel,C               ;Add model support via command
  16.                                         ;line macros, e.g.
  17.                                         ;MASM /Dmemodel=LARGE
  18.  
  19.         .DATA?
  20. _origvec        dd      ?
  21. _newvec         dd      ?
  22.  
  23.         .CODE
  24.  
  25. ;
  26. ;  This is our actual ISR
  27. ;
  28.  
  29. myint23:
  30.         call    dword PTR _newvec       ;call our handler
  31.         iret
  32.  
  33. ;
  34. ;  Call this to install  our ISR
  35. ;
  36.  
  37. ins23   PROC    USES AX BX DS ES, offs:WORD, segm:WORD
  38.         mov     ax,3523h                ;get old vector...
  39.         int     21h
  40.         mov     word PTR _origvec,bx
  41.         mov     word PTR _origvec+2,es  ;...and save it
  42.         mov     ax,offs                 ;load handler offset...
  43.         mov     word PTR _newvec,ax
  44.         mov     ax,segm                 ; & segment into _newvec
  45.         mov     word PTR _newvec+2,ax
  46.         push    cs                      ;get myint23 segment in DS
  47.         pop     ds
  48.         mov     dx, OFFSET myint23      ;install myint23 in int 23h
  49.         mov     ax,2523h
  50.         int     21h
  51.         ret
  52. ins23   ENDP
  53.  
  54. ;
  55. ;  Call this to uninstall our ISR
  56. ;
  57.  
  58. redo23  PROC    USES AX BX DS
  59.         mov     dx, word PTR _origvec   ;restore original vector
  60.         mov     ds, word PTR _origvec+2
  61.         mov     ax,2523h
  62.         int     21h
  63.         ret
  64. redo23  ENDP
  65.  
  66.         end
  67.