home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_01 / 2n01063a < prev    next >
Text File  |  1990-12-02  |  2KB  |  89 lines

  1. ;
  2. ;  Requires MASM 5.1 or later
  3. ;
  4.  
  5. %       .MODEL  memodel,lang            ;Add model and language support via
  6.                                         ;command line macros,
  7.                                         ;e.g. MASM /Dmemodel=LARGE /Dlang=C
  8.  
  9. EOI     equ     20h
  10. PIC     equ     20h
  11. T0      equ     40h
  12. TCMD    equ     43h
  13.  
  14.         .DATA
  15.  
  16.         public  I8Ctr
  17.  
  18. I8Ctr   dw      0
  19.  
  20.         .CODE
  21.  
  22. OldI8   dd      ?
  23. ChainCt dw      32
  24.  
  25. ;
  26. ; This is our actual ISR
  27. ;
  28. myint08:
  29.         push    ax                      ;Save the only register used
  30.         inc     I8Ctr                   ;Bump the counter
  31.         dec     ChainCt                 ;Time to chain?
  32.         jnz     skip                    ;No
  33.         mov     ax,32                   ;Yes, reload chain counter
  34.         mov     ChainCt,ax
  35.         pop     ax
  36.         jmp     dword PTR CS:OldI8      ;Let BIOS do its thing
  37. skip:
  38.         mov     ax,EOI                  ;Send end-of-interrupt code
  39.         out     PIC,al
  40.         pop     ax
  41.         iret                            ;All done
  42.  
  43. ;
  44. ;  Call this to install  our ISR
  45. ;
  46. ins08   PROC    USES AX BX DS ES
  47.         mov     ax,3508h                ;get old timer ISR vector...
  48.         int     21h
  49.         mov     word PTR CS:OldI8,bx
  50.         mov     word PTR CS:OldI8+2,es ;...and save it
  51.  
  52.         cli                             ;no interrupts!
  53.         push    cs                      ;get myint08 segment in DS
  54.         pop     ds
  55.         mov     dx, OFFSET myint08      ;install myint08 in int 08h
  56.         mov     ax,2508h
  57.         int     21h
  58.  
  59.         mov     al,36h                  ;reset PIT channel 0
  60.         out     TCMD,al
  61.         mov     ax,800h                 ;set 800h = 10000h/32
  62.         out     T0,al
  63.         mov     al,ah
  64.         out     T0,al
  65.         sti
  66.         ret
  67. ins08   ENDP
  68.  
  69. ;
  70. ;  Call this to uninstall our ISR
  71. ;
  72. undo08  PROC    USES DX DS AX
  73.         cli                             ;no interrupts!
  74.         mov     dx, word PTR CS:OldI8   ;restore original vector
  75.         mov     ds, word PTR CS:OldI8+2
  76.         mov     ax,2508h
  77.         int     21h
  78.  
  79.         mov     al,36h                  ;reset PIT channel 0
  80.         out     TCMD,al
  81.         mov     al,0                    ;set 0 = 10000h
  82.         out     T0,al
  83.         out     T0,al
  84.         sti
  85.         ret
  86. undo08  ENDP
  87.  
  88.         end
  89.