home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l196 / 3.ddi / TIMERA.AS$ / TIMERA.bin
Encoding:
Text File  |  1990-06-24  |  2.7 KB  |  62 lines

  1. ;*************************  TIMERA.ASM  ******************************
  2. ; This program, along with TIMER.BAS, makes use of the BASIC SetUEvent
  3. ; routine to print a message on the screen every 4.5 seconds.
  4. ; This file has three procedures.  SetInt sets up the new DOS interrupt
  5. ; vector.  EventHandler increments a counter 18 times a second and
  6. ; notifies BASIC when 4.5 seconds have elapsed.  RestInt restores the
  7. ; old interrupt vector.
  8.  
  9.         .model  medium, basic        ;Stay compatible with BASIC.
  10.         extrn   SETUEVENT: far
  11.             .code
  12. SETINT        proc    uses ds            ;Get old interrupt vector
  13.             mov     ax, 351CH               ;and save it.
  14.             int    21h
  15.             mov     word ptr cs:OldVector, bx
  16.             mov     word ptr cs:OldVector + 2, es
  17.  
  18.             push    cs                      ;Set the new
  19.             pop ds                          ;interrupt vector
  20.             lea dx, EventHandler            ;to the address
  21.             mov ax, 251CH                   ;of our service
  22.             int 21H                         ;routine.
  23.             ret    
  24. SETINT        endp
  25.  
  26. public  EVENTHANDLER                        ;Make this routine
  27.                                             ;public for debugging--
  28. EVENTHANDLER    proc                ;it will check to see if
  29.                         ;4.5 seconds have passed.
  30.         push    bx
  31.             lea     bx, TimerTicks
  32.             inc     byte ptr cs:[bx]        ;Have 4.5 seconds elapsed?
  33.             cmp     byte ptr cs:[bx], 82
  34.             jnz     Continue
  35.             mov     byte ptr cs:[bx], 0     ;If true, reset counter,
  36.             push    ax                      ;save registers, and
  37.             push    cx                      ;have BASIC set the
  38.             push    dx                      ;user event flag.
  39.             push    es
  40.         call    SETUEVENT
  41.             pop     es
  42.             pop     dx                      ;Restore registers.
  43.             pop     cx
  44.             pop     ax
  45. Continue:
  46.             pop     bx
  47.             jmp     cs:OldVector            ;Continue on with the
  48.                                             ;old service routine.
  49.  
  50. TimerTicks  db      0                       ;Keep data in code segment
  51. OldVector   dd      0                       ;where it can be found no
  52.                                             ;matter where in memory the
  53. EVENTHANDLER    endp                ;interrupt occurs.
  54.  
  55. RESTINT     proc    uses ds            ;Restore the old
  56.             lds     dx, cs:OldVector        ;interrupt vector
  57.             mov     ax, 251CH               ;so things will
  58.             int     21h                     ;keep working when
  59.             ret                             ;this BASIC program is
  60. RESTINT     endp                ;finished.
  61.             end
  62.