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

  1.         PAGE ,132
  2.  
  3. ;  Figure 2
  4. ;  Install a custom Interrupt 1b (Ctrl-Break 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.  
  14.         .DATA
  15.  
  16.         public  cbrcvd
  17.  
  18. cbrcvd  dw      0
  19.  
  20.         .CODE
  21.  
  22. ;
  23. ;  This is our actual ISR
  24. ;
  25. myint1b:
  26.         mov     ax,-1
  27.         mov     cbrcvd,ax
  28.         iret
  29.  
  30. ;
  31. ;  Call this to install  our ISR
  32. ;
  33. ins1b   PROC    USES AX BX DS ES
  34.         mov     ax,351bh                ;get old vector...
  35.         int     21h
  36.         mov     word PTR _origvec,bx
  37.         mov     word PTR _origvec+2,es  ;...and save it
  38.  
  39.         push    cs                      ;get myint1b segment in DS
  40.         pop     ds
  41.         mov     dx, OFFSET myint1b      ;install myint1b in int 1bh
  42.         mov     ax,251bh
  43.         int     21h
  44.         ret
  45. ins1b   ENDP
  46.  
  47. ;
  48. ;  Call this to uninstall our ISR
  49. ;
  50. redo1b  PROC    USES AX BX DS
  51.         mov     dx, word PTR _origvec   ;restore original vector
  52.         mov     ds, word PTR _origvec+2
  53.         mov     ax,251bh
  54.         int     21h
  55.         ret
  56. redo1b  ENDP
  57.  
  58.         end
  59.