home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / tnylib.lzh / TIMER.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-11-03  |  1012 b   |  55 lines

  1. include compiler.inc
  2.  
  3.     ttl    TIMER, 1.00, 11-03-86, jwk
  4.  
  5.  
  6.     dseg
  7.     cseg
  8.  
  9. ; long timer(oldtime) - long oldtime; returns number of ticks
  10. ;    elapsed since OLDTIME. If OLDTIME == 0L, this is number
  11. ;    of ticks since midnight. Hi word of return is hours.
  12.  
  13.     procdef    timer,<<timlo,word>,<timhi,word>>
  14.  
  15.     xor    ax,ax
  16.     int    1ah
  17.     mov    ax,dx
  18.     mov    dx,cx
  19.     sub    ax,timlo
  20.     sbb    dx,timhi
  21.     jns    noday
  22.     not    ax
  23.     not    dx
  24.     add    ax,1
  25.     adc    dx,24
  26. noday:    pret
  27.     pend    timer
  28.  
  29. ; int cnvtks(ticks) unsigned ticks; Converts tick count in range 0-65535
  30. ;    to min/sec. Returns number of minutes in AH and seconds (rounded
  31. ;    up in case of fractional time) in AL.
  32.  
  33.     procdef    cnvtks,<<ticks,word>>
  34.  
  35.     pushreg
  36.     mov    ax,ticks    ; convert to seconds ( * (5/91) )
  37.     mov    si,5
  38.     xor    dx,dx
  39.     mul    si
  40.     mov    si,91
  41.     div    si
  42.     cmp    dx,46        ; remainder >= 46/91 second?
  43.     jb    nothalf
  44.     inc    ax        ; yes, round up
  45. nothalf:
  46.     or    ax,ax
  47.     jz    nosec
  48.     mov    dx,60        ; scale to SSMM
  49.     div    dl
  50.     xchg    ah,al        ; convert to MMSS
  51. nosec:    pret
  52.     pend    cnvtks
  53.  
  54.     finish
  55.