home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c010 / 1.ddi / FLILIB3.ZIP / FLISRC3.ZIP / CLOCK.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-08-29  |  1.3 KB  |  49 lines

  1. ;clock.asm - contains aa_goclock(), aa_getclock.
  2.  
  3.     dosseg
  4.     .model    large
  5.     .code
  6.  
  7. CMODE    equ    043h
  8. CDATA    equ 040h
  9.  
  10.     public _aa_goclock
  11. ;Set up clock registers for aa_getclock.  Should be called before aa_getclock.
  12. _aa_goclock proc far
  13.     mov al,00110100b    ;put it into linear count instead of divide by 2
  14.     out CMODE,al
  15.     xor al,al
  16.     out CDATA,al
  17.     out CDATA,al
  18.     ret
  19. _aa_goclock endp
  20.  
  21.     public _aa_getclock
  22. ;this routine returns a clock with occassional spikes where time
  23. ;will look like its running backwards 1/18th of a second.  The resolution
  24. ;of the clock is 1/(18*256) = 1/4608 second.  66 ticks of this clock
  25. ;are supposed to be equal to a monitor 1/70 second tick.
  26.  
  27. _aa_getclock proc far
  28.     push cx
  29.  
  30.     mov ah,0    ;get tick count from dos and use for hi 3 bytes
  31.     int 01ah    ;lo order count in dx, hi order in cx
  32.     mov ah,dl    
  33.     mov dl,dh
  34.     mov dh,cl
  35.  
  36.     mov al,0        ;read lo byte straight from timer chip
  37.     out CMODE,al    ;latch count
  38.     mov al,1
  39.     out CMODE,al    ;set up to read count
  40.     in al,CDATA    ;read in lo byte (and discard)
  41.     in al,CDATA    ;hi byte into al
  42.     neg al        ;make it so counting up instead of down
  43.  
  44.     pop cx
  45.     ret
  46. _aa_getclock endp
  47.  
  48. END
  49.