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

  1. ;  +++Date last modified: 05-Jul-1997
  2.  
  3.         PAGE ,132
  4.  
  5. ;  Install a custom Interrupt 1b (Ctrl-Break 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. %       .MODEL  memodel,C               ;Add model support via command
  15.                                         ;line macros, e.g.
  16.                                         ;MASM /Dmemodel=LARGE
  17.  
  18.         .DATA?
  19. _origvec        dd      ?
  20.  
  21.         .DATA
  22.  
  23.         public  cbrcvd
  24.  
  25. cbrcvd  dw      0
  26.  
  27.         .CODE
  28.  
  29. ;
  30. ;  This is our actual ISR
  31. ;
  32. myint1b:
  33.         mov     ax,-1
  34.         mov     cbrcvd,ax
  35.         iret
  36.  
  37. ;
  38. ;  Call this to install  our ISR
  39. ;
  40. ins1b   PROC    USES AX BX DS ES
  41.         mov     ax,351bh                ;get old vector...
  42.         int     21h
  43.         mov     word PTR _origvec,bx
  44.         mov     word PTR _origvec+2,es  ;...and save it
  45.  
  46.         push    cs                      ;get myint1b segment in DS
  47.         pop     ds
  48.         mov     dx, OFFSET myint1b      ;install myint1b in int 1bh
  49.         mov     ax,251bh
  50.         int     21h
  51.         ret
  52. ins1b   ENDP
  53.  
  54. ;
  55. ;  Call this to uninstall our ISR
  56. ;
  57. redo1b  PROC    USES AX BX DS
  58.         mov     dx, word PTR _origvec   ;restore original vector
  59.         mov     ds, word PTR _origvec+2
  60.         mov     ax,251bh
  61.         int     21h
  62.         ret
  63. redo1b  ENDP
  64.  
  65.         end
  66.