home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / STOPWATC.ASM < prev    next >
Assembly Source File  |  1993-09-16  |  968b  |  53 lines

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