home *** CD-ROM | disk | FTP | other *** search
- page 58,132
- ;
- ; timer.asm
- ; contains: timer()
- ;
- ;
- ; The Greenleaf Comm Library
- ;
- ; Copyright (C) 1984-90 Greenleaf Software Inc. All Rights Reserved.
- ;
- ;
- include model.h
- include prologue.h
- name timer
- pseg timer
-
- ;==>-- void timer(n)
- ;
- ;; ARGUMENTS:
- ; (unsigned) n - Number of 1/18.2 second intervals to delay
- ;
- ;; DESCRIPTION:
- ; This function provides a timed delay of the indicated number
- ; of 1/18.2 second intervals. It calls the ROM-BIOS timer routine
- ; via interrupt 0x1a.
- ;
- ;; SIDE EFFECTS:
- ; The ROM-BIOS maintains a flag at ROMDATA:TIMER_OFL that is set
- ; when the timer rolls over to the next day. Calling interrupt
- ; 0x1A causes this flag to be cleared. Subsequent calls to the
- ; ROM-BIOS timer routine by MS-DOS will not detect that it is time
- ; for the date to be rolled over. If this timer() function detects
- ; that the day has rolled over the ROMDATA:TIMER_OFL flag is set back
- ; to 1 and the DOS get time function is called so that MS-DOS can
- ; update the date. This feature is controlled by the conditional
- ; CHKROLOVR. Setting it to 0 will disable.
- ;
- ;; AUTHOR:
- ; "" 03-FEB-1987 10:18:44.38
- ;
- ;; MODIFICATIONS:
- ; "" 25-MAR-1987 09:24:39.08
- ; Modified to fix date rollover problem (with conditional
- ; CHKROLOVR).
- ;;;
- CHKROLOVR equ 1
- if CHKROLOVR
- ROMDATA equ 40h ;ROM Bios Data Segment
- TIMER_OFL equ 70h ;Offset of timer overflow flag
- endif
- cproc timer,,,,,<NOSI,NODI>
- call _rdtime ;see what ticker says first
- mov bx,dx ;save initial low order count
- tloop: call _rdtime ;function to get timer
- cmp bx,dx ;see if low order has changed
- jz tloop ;if not get it again
- mov bx,dx ;update bx with new low order count
- dec word ptr parm1_ ;--interval
- jnz tloop ;if not down to 0
- cproce
- _rdtime proc near
- xor ah,ah
- int 1ah ;get time to cx:dx
- or al,al ;has date rolled?
- jnz fixd
- ret
- fixd:
- if CHKROLOVR
- push bx
- push dx
- push bp
- push ds
- mov ax,ROMDATA ;We set the timer overflow flag
- mov ds,ax ;then make the DOS call to get
- mov bx,TIMER_OFL
- mov byte ptr [bx],1
- pop ds
- mov ah,2ch
- int 21h
- pop bp
- pop dx
- pop bx
- endif
- ret
- _rdtime endp
- endps
- end