home *** CD-ROM | disk | FTP | other *** search
- include compiler.inc
-
- ttl TIMER, 1.00, 11-03-86, jwk
-
-
- dseg
- cseg
-
- ; long timer(oldtime) - long oldtime; returns number of ticks
- ; elapsed since OLDTIME. If OLDTIME == 0L, this is number
- ; of ticks since midnight. Hi word of return is hours.
-
- procdef timer,<<timlo,word>,<timhi,word>>
-
- xor ax,ax
- int 1ah
- mov ax,dx
- mov dx,cx
- sub ax,timlo
- sbb dx,timhi
- jns noday
- not ax
- not dx
- add ax,1
- adc dx,24
- noday: pret
- pend timer
-
- ; int cnvtks(ticks) unsigned ticks; Converts tick count in range 0-65535
- ; to min/sec. Returns number of minutes in AH and seconds (rounded
- ; up in case of fractional time) in AL.
-
- procdef cnvtks,<<ticks,word>>
-
- pushreg
- mov ax,ticks ; convert to seconds ( * (5/91) )
- mov si,5
- xor dx,dx
- mul si
- mov si,91
- div si
- cmp dx,46 ; remainder >= 46/91 second?
- jb nothalf
- inc ax ; yes, round up
- nothalf:
- or ax,ax
- jz nosec
- mov dx,60 ; scale to SSMM
- div dl
- xchg ah,al ; convert to MMSS
- nosec: pret
- pend cnvtks
-
- finish
-