home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / asm / 80x0393 / isrcap.txt < prev    next >
Encoding:
Text File  |  1993-07-31  |  2.8 KB  |  93 lines

  1. (7219)  Thu 29 Jul 93  6:07a
  2. By: Paul White
  3. To: Sunil Puri
  4. Re: RE: Interrupt Handling
  5. St:
  6. ---------------------------------------------------------------------------
  7. In a message to everyone written on Tuesday, July 27, 1993 at 8:02:38 PM,
  8. Sunil Puri writes:
  9.  
  10. SP> Does anyone have general suggestions about writing int handlers? I have
  11. SP> written a TSR that displays the time in the corner of the screen. It
  12. SP> hooks int 1Ch (the timer-tick int). It displays the time once and is
  13. SP> correct, however, my system hangs. Could it be that is executes too
  14. SP> slowly (since it chains the
  15.  
  16. Here is an example of a little routine I use in the 18.2 Hz DOS timer
  17. tick interrupt chain, to keep track of time-outs, etc.  You could
  18. easily modify this for your on-screen clock program.  The InsertWedge
  19. routine installs the new interrupt handler, and the RemoveWedge routine
  20. is used to remove the handler.
  21.  
  22. ; Include file WEDGE.INC
  23. ; Interrupt chain insert and delete routines
  24.  
  25. TimeLimit    dw    ?
  26. oldIRQ       dd    ?        ; save address of normal IRQ 8
  27.  
  28. ;---------------------------------------;
  29. InsertWedge    proc    near
  30. ;---------------------------------------;
  31. ; Insert process in DOS timer tick interrupt (8) chain
  32. ;
  33.     push   es
  34.  
  35.     mov    ax,3508h        ; Get interrupt vector (#8)
  36.     int    21h            ; returns es:bx pointing to IRQ
  37.                     ; routine
  38.     mov    word ptr [OldIRQ],bx
  39.     mov    word ptr [OldIRQ+2],es    ; save original address
  40.  
  41.     mov    dx,offset IntWedge    ; ds:dx = new vector
  42.     mov    ax,2508h        ; Set interrupt vector (#8)
  43.     int    21h
  44.  
  45.     pop    es
  46.     ret
  47.  
  48. InsertWedge    endp
  49.  
  50. ;---------------------------------------;
  51. RemoveWedge    proc    near
  52. ;---------------------------------------;
  53.  
  54.     push   ds
  55.     mov    dx,word ptr [OldIRQ]    ; get offset in DX
  56.     mov    ax,word ptr [OldIRQ+2]    ; get segment in DS
  57.     mov    ds,ax            ; ds:dx = new vector
  58.     mov    ax,2508h        ; Set interrupt vector (#8)
  59.     int    21h
  60.  
  61.     pop    ds
  62.     ret
  63.  
  64. RemoveWedge    endp
  65.  
  66. ;---------------------------------------;
  67. IntWedge    proc    near
  68. ;---------------------------------------;
  69. ; This is the routine inserted in the DOS timer tick interrupt chain
  70. ;
  71.     pushf                ; save flags and register(s)
  72.     push    ax
  73.  
  74.     mov    ax,cs:TimeLimit        ; If TimeLimit <> 0, decrement it
  75.     or     ax,ax
  76.     jz     no_update        ; (jump if already 0)
  77.  
  78.     sub    ax,1
  79.     mov    cs:TimeLimit,ax        ; Update counter
  80.  
  81. no_update:
  82.     pop    ax            ; restore register and flags
  83.     popf
  84.  
  85.     jmp    dword ptr cs:[OldIRQ]   ; go on to the next event in chain
  86.  
  87. IntWedge   endp
  88.  
  89. --- Tabby 3.0
  90.  * Origin: The Mountain Air BBS, Cedar Glen, CA  909/336-6080 (1:207/226)
  91.  
  92. @PATH: 207/226 8/8 13/13 260/1
  93.