home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / TKRTGL.ZIP / TKRTGL.ASM next >
Encoding:
Assembly Source File  |  1989-01-27  |  6.1 KB  |  145 lines

  1.   page  66,132
  2.   title TKRTGL.ASM  <Ticker Toggle>                      
  3. ;-----------------------------------------------------------------------------
  4. ; Program: Ticker Toggle                      (TKRTGL.ASM)
  5. ; Version: 1.0
  6. ; Author : Mike Kenny        
  7. ; Date   : 01/26/89  
  8. ;
  9. ; Remarks: This is a resident program to toggle on demand the INT 1Ch 
  10. ;          vector, between a pointer to an IRET and it's actual code.
  11. ;          This will allow the user to temporarily disable cycle hogging
  12. ;          programs that adversely effect high speed data communications.
  13. ;          
  14. ;-----------------------------------------------------------------------------
  15.  
  16. code            segment para public 'code'
  17.                 assume  cs:code
  18.  
  19.                 org     100h
  20. begin:          jmp initialize
  21.  
  22.  
  23. ON              equ  0
  24. OFF             equ  1
  25. toggle_keyscan  equ  054h                        ;keyboard scan code for F11
  26. target_int      equ  01ch                        ;timer interrupt
  27. kb_int          equ  09h
  28. int_segment     equ  0
  29.  
  30. dummy_vector:        IRET                        ;only 28 clocks to get back
  31.  
  32. int_status           db    0                     ;0 = normal, 1 = IRET
  33.  
  34. orig_kb_int          label dword                 ;segment and offset of the
  35. orig_keyboard_int    dw    2 dup (?)             ;keyboard interrupt
  36.  
  37. vector_address       dw    2 dup (?)             ;storage for active vector
  38.  
  39. main         proc    near
  40.              sti                                 ;enable software interrupts
  41.              push    ax                          ;save all registers
  42.              push    bx
  43.              push    cx
  44.              push    dx
  45.              push    si
  46.              push    di
  47.              push    ds
  48.              push    es
  49.  
  50.              pushf                               ;push flags for call to the
  51.              call    orig_kb_int                 ;original kbd interrupt
  52.              mov     ah,1                        ;check keyboard buffer to see
  53.              int     16h                         ;if something is in it
  54.              jz      exit                        ;zr set if no key
  55.              cmp     ah,toggle_keyscan           ;check scan code  
  56.              jne     exit
  57.              mov     ah,0                        ;we got it
  58.          int     16h                         ;lets clear it
  59.              push    cs                          ;set ds to cs segment
  60.              pop     ds
  61.              cmp     int_status,ON               ;see if dummy is active   
  62.              jne     int_restore                 ;put it back the way it was
  63.  
  64.              mov     ax,int_segment
  65.          push    ax
  66.          pop     es                          ;set es to int segment
  67.              mov     si,4 * target_int           ;source our target
  68.          mov     ax,es:[si]                  ;get offset
  69.          mov     bx,es:[si+2]                ;get segment
  70.          mov     vector_address,ax           ;save for later
  71.          mov     vector_address[2],bx
  72.          mov     ax,offset dummy_vector      ;get dummys address
  73.          cli                                 ;do not disturb
  74.          mov     es:[si],ax                  ;set vector to dummy
  75.          mov     es:[si+2],cs
  76.          sti                                 ;keep the clock right
  77.  
  78.              mov     int_status,OFF              ;set the status          
  79.              jmp     exit
  80.          
  81. int_restore:
  82.              mov     ax,int_segment
  83.          push    ax
  84.          pop     es                          ;set es to int segment
  85.              mov     si,4 * target_int           ;source our target
  86.          mov     ax,vector_address           ;get offset
  87.          mov     bx,vector_address[2]        ;get segment
  88.          cli                                 ;do not disturb
  89.          mov     es:[si],ax                  ;set vector the way it was
  90.          mov     es:[si+2],bx                ;mean't to be
  91.          sti                                 ;keep the clock right
  92.  
  93.              mov     int_status,ON               ;set the status          
  94.  
  95. exit:        pop     es                          ;restore callers registers
  96.              pop     ds
  97.              pop     di
  98.              pop     si
  99.              pop     dx
  100.              pop     cx
  101.              pop     bx
  102.              pop     ax
  103.              iret                                ;interrupt return
  104. main         endp
  105.  
  106.   page
  107. ;-----------------------------------------------------------------------------
  108. ; Initialization code will change the interrupt vector table and load resident
  109. ;-----------------------------------------------------------------------------
  110. initialize   proc    near
  111.              assume  ds:code, es:code
  112.  
  113.              mov     ah,9                        ;send loaded message
  114.              lea     dx,tsr_message
  115.              int     21h
  116.  
  117.              mov     int_status,0                ;intialize interrupt status
  118.  
  119.              mov     ah,035h                     ;lets get the current kbd
  120.          mov     al,kb_int                   ;interrupt vector
  121.          int     021h
  122.              mov     orig_keyboard_int[2],es     ;save the segment
  123.          mov     orig_keyboard_int,bx        ;save the offset
  124.              mov     ah,025h                     ;here we go!
  125.          mov     al,kb_int
  126.              push    cs                          ;set ds to cs segment
  127.              pop     ds
  128.              mov     dx,offset main       
  129.          int     021h                        ;dos do your magic
  130.  
  131.              mov     dx,offset initialize        ;dx = end of tsr code
  132.              int     27h                         ;terminate and stay resident
  133.  
  134. tsr_message     db  13,10                        ;tell them its loaded
  135.                 db  213,40 dup(205),184,13,10
  136.                 db  179,' Ticker Toggle      Rev. 1.0  01/26/89  ',179,13,10
  137.                 db  179,'                                        ',179,13,10
  138.                 db  179,' <F11> To Toggle              M. Kenny  ',179,13,10
  139.                 db  212,40 dup(205),190,13,10,'$'
  140.  
  141. initialize   endp
  142. code         ends                                ;end of code segment
  143.              end     begin                       ;end of program
  144. 
  145.