home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / STOPWATC.ASM < prev    next >
Assembly Source File  |  1991-01-27  |  770b  |  49 lines

  1. ; Stopwatch primitives - used in sw.c
  2. ; Copyright 1991 Phil Karn, KA9Q
  3.  
  4.     .MODEL    MEMMOD,C
  5.     LOCALS
  6.     %MACS
  7.     .LALL
  8.     public stopval,swstart
  9.     .CODE
  10. dbase    dw    @Data
  11.  
  12. ; start the interval timer
  13. swstart    proc    far
  14.     push    ax
  15. ; send the mode word to the 8254
  16.     mov    al,0b8h    ; select counter 2, write lsb,msb, mode 4, binary
  17.     out    43h,al
  18. ; initialize the counter at 0
  19.     xor    al,al
  20.     out    42h,al    ; lsb
  21.     out    42h,al    ; msb
  22. ; gate the counter on
  23.     in    al,61h
  24.     or    al,1
  25.     out    61h,al
  26.     pop    ax
  27.     ret
  28. swstart    endp
  29.  
  30. ; stop the interval timer and return its value
  31. stopval    proc    far
  32. ; gate the counter off
  33.     in    al,61h
  34.     and    al,0feh
  35.     out    61h,al
  36. ; latch counter 2
  37.     mov    al,080h
  38.     out    43h,al
  39. ; get the value
  40.     in    al,42h
  41.     mov    ah,al
  42.     in    al,42h
  43.     xchg    ah,al
  44.     ret
  45.     endp
  46.  
  47.     end
  48.  
  49.