Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!phri!dasys1!manes From: manes@dasys1.UUCP (Steve Manes) Newsgroups: comp.sys.ibm.pc Subject: Re: Standard date bug Message-ID: <2049@dasys1.UUCP> Date: Mon, 23-Nov-87 03:04:06 EST Article-I.D.: dasys1.2049 Posted: Mon Nov 23 03:04:06 1987 Date-Received: Thu, 26-Nov-87 22:23:26 EST References: <7457@eddie.MIT.EDU> Organization: The Big Electric Cat, NYC, NY Lines: 57 Summary: The BIOS Timer Bug In article <7457@eddie.MIT.EDU>, nathan@eddie.MIT.EDU (Nathan Glasser) writes: > > This is a question about the standard bug that many people know > about regarding the date maintained in memory on standard > pc's and many clones. If your computer is on when midnight comes > around, the date will not be changed. I don't know whether this > always happens or only sometimes. > Does anybody have any simple solution that they've been using? Yes, although I believe that DOS 3.2 fixed this problem (I could be wrong; I still use 3.1). The problem lies in a "sticky flag" maintained by the BIOS timer in the ROM_BIOS_DATA segment. The structure of this segment is: ROM_BIOS_DATA SEGMENT @40h org 6Ch timer_low dw ? ; count up to 65535...(18.2x/sec) timer_hi dw ? ; then increment this (every hour) until... timer_ofl db ? ; we hit midnight and we inc' this. ROM_BIOS_DATA ENDS Whenever DOS calls BIOS to read the current real-time clock, it runs Interrupt 1Ah (see Tech Ref) and a single line of code that is executed during any TIME_OF-DAY "read time" call: mov timer_ofl,0 ; get overflow and reset flag In other words, every time Int 1Ah is called to read the time, whether from the DOS TIME/DATE routines or from your own homebrew to count the number of timer ticks, 'timer_ofl' is reset to zero and its previous contents returned in AL by Int 1Ah. The sticky widget: DOS needs this flag so it knows that the date has rolled over. If your application calls Int 1Ah before DOS gets it (and remember that this flag is set only ONCE every 24 hours and read only ONCE and then reset) DOS will simply roll the clock over but not the day. There are a few fixes that come to mind but the easiest by far is to write your own Int 1Ah replacement that DOESN'T reset 'timer_ofl'. Fortunately, this is an easy task since Int 1Ah doesn't do very much. What I do is use this routine whenever I need to read the timer block: push es mov ax,40h mov es,ax mov ax,word ptr es:[6Ch] mov my_timerlo,ax mov ax,word ptr es:[6Eh] mov my_timerhi,ax pop es That eliminates the problem. -- +----------------------------------------------------------------------- + Steve Manes Roxy Recorders, Inc. NYC + decvax!philabs!cmcl2!hombre!magpie!manes Magpie BBS: 212-420-0527 + uunet!iuvax!bsu-cs!zoo-hq!magpie!manes 300/1200/2400