TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: ALL
from: KEN HRYNCHUK
date: 1998-01-26 16:28:00
subject: RT Delay Bug?

Can anyone tell me why the following attempt at a real-time delay
aborts at midnight (under MS-DOS), and not at the changing of the
hour? Any fixes/explanations will be greatly appreciated.
--------------------------------------------------------------------------
;Chasm syntax
          call rtdly
          mov ax,4C00H
          int 21H
rtdly   proc near          ;real time delay 0-3599 seconds (55ms resolution)
          jmps rtgo        ;BUG! - aborts at midnight
rtinit db 0                ;init. flag
rttics dw 0                ;init. clock ticks (seconds*18.20648)
dlyval dw 0182             ;approx. 10 second delay
rtgo      push ax
          push dx
          pushf
          movb rtinit,0
rtloop    xor ax,ax
          push ds
          mov ds,ax
          mov dx,[046CH]   ;get lsw of timer ticks since midnight
          pop ds
          cmpb rtinit,0    ;first time through?
          je rtstrt
          sub dx,rttics    ;no - subtract init. ticks from current
          cmp dx,dlyval    ;elapsed ticks>=our delay?
          jae rtend        ;yep - we're outta here
          jmps rtloop
rtstrt    mov rttics,dx    ;save init. ticks
          movb rtinit,1    ;one time only
          jmps rtloop
rtend     popf
          pop dx
          pop ax
          ret
        endp
---------------------------------------------------------------------------
I've got a sneaking suspicion that I'm overlooking something quite
simple. :)
                                   Ken
 -- If only my code was as tight as my budget...
 * KenMail 1.0 * 
--- FMail 0.92
---------------
* Origin: The Programmer's Oasis on FIDONET! (1:348/203)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.