Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Date and time in DOS

121 views
Skip to first unread message

Ruud

unread,
Nov 12, 2011, 2:53:59 PM11/12/11
to
Hallo allemaal,


One of my hobbies is 'playing' with old PC-XT (compatible)s. As you
know the XT didn't have a RTC (Real Time Clock) chip on board. You
could get cards providing you with a RTC but you also needed a program
that read the RTC and set the date and time for you. The time is saved
at 0004:006C and 0004:006E. But I haven't any idea where the date is
stored. In fact, I thought that the date was a DOS thing and couldn't
be set by the BIOS.

The Commodore PC10-III and PC20-III are both XT compatibles (with and
without hard disk drive) and have a for me unknown RTC; it's inside
one of their custom ICs. I noticed that both time and date were set
after booting. But I only recently realised that this was done without
the need of an extra program. Which means that they were set by the
BIOS.

Has anyone an idea were the date is stored? Or is there more then just
'storing some bytes'?

Thank you very much for any info!


Groetjes, Ruud Baltissen
http://www.Baltissen.org

R.Wieser

unread,
Nov 12, 2011, 4:39:45 PM11/12/11
to
Hello Ruud,

> The time is saved at 0004:006C and 0004:006E.

Not quite. Its just a timer-tick (18.2 times a second) which runs parallel
to the RTC (hardware) clock. In absense of an RTC DOS uses a function to
calculate the current time-of-day from those ticks.

The program you spoke of is most likely a TSR, intercepting the time-of-day
request INTs and re-routing it to read the time and date from the RTC
(instead of using the timer-ticks).

In other words: It does not need to store the date (and/or time) anywhere,
as it can read it from the RTC any time it likes (pun not intended).

Hope that helps.
Rudy Wieser


-- Origional message
Ruud <ruud.ba...@gmail.com> schreef in berichtnieuws
43c63229-a58b-48fc...@cc2g2000vbb.googlegroups.com...

Ross Ridge

unread,
Nov 12, 2011, 6:20:15 PM11/12/11
to
R.Wieser <add...@not.available> wrote:
>Not quite. Its just a timer-tick (18.2 times a second) which runs parallel
>to the RTC (hardware) clock. In absense of an RTC DOS uses a function to
>calculate the current time-of-day from those ticks.

I'm pretty sure MS-DOS always uses those system clock ticks (obtained
using INT 1Ah, AH=00) to caclulate the current time. Only during startup
does it use the RTC time (obtained using INT 1Ah, AH=02) to set the
system clock. If the RTC isn't available then it prompts the user for
the current time and date.

The Commododore PC BIOS is presumably providing the RTC time to DOS
through INT 1Ah, AH=02.

Ross Ridge

--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rri...@csclub.uwaterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //

Dr J R Stockton

unread,
Nov 13, 2011, 3:12:22 PM11/13/11
to
In comp.os.msdos.programmer message <43c63229-a58b-48fc-9e62-59941107b18
e...@cc2g2000vbb.googlegroups.com>, Sat, 12 Nov 2011 11:53:59, Ruud
<ruud.ba...@gmail.com> posted:

>One of my hobbies is 'playing' with old PC-XT (compatible)s. As you
>know the XT didn't have a RTC (Real Time Clock) chip on board. You
>could get cards providing you with a RTC but you also needed a program
>that read the RTC and set the date and time for you. The time is saved
>at 0004:006C and 0004:006E. But I haven't any idea where the date is
>stored. In fact, I thought that the date was a DOS thing and couldn't
>be set by the BIOS.
>
>The Commodore PC10-III and PC20-III are both XT compatibles (with and
>without hard disk drive) and have a for me unknown RTC; it's inside
>one of their custom ICs. I noticed that both time and date were set
>after booting. But I only recently realised that this was done without
>the need of an extra program. Which means that they were set by the
>BIOS.
>
>Has anyone an idea were the date is stored? Or is there more then just
>'storing some bytes'?


Google "pctim003" and read the document (own a copy) - perhaps from
<ftp://garbo.uwasa.fi/pc/programming/pctim003.zip> - "Timing on the PC
family under DOS" (1995).

My
<http://www.merlyn.demon.co.uk/pc-links.htm> may help, as may
<http://www.merlyn.demon.co.uk/pas-time.htm> and
<http://www.merlyn.demon.co.uk/pas-wait.htm>, etc.

Via <http://www.merlyn.demon.co.uk/programs/00index.htm>, my program
INT_TEST may be of interest; one can investigate the situation with it.


The RTC contains a 32-kHz battery-powered clock, running all the time.
At boot, DOS reads it, and initialises a 32-bit 18.2Hz time counter at
$0040:$006C. When, at "midnight", that counter reaches $1800B0, a carry
bit nearby is set and the counter is zeroed,

At boot, the date from the RTC is copied into an unknown location, as a
16-bit daycount. When DOS is asked the date, it adds the carry bit to
its daycount and zeroes the bit. Therefore, either turn the PC off
overnight or ask it the date at least once every day.

INT_TEST, in DOS, Win3, and maybe Win98, can search memory for an
appropriate 16-bit value and (IIRC) verify it by changing the date
briefly.

The daycount rolls over at counting into $1800B0, not at or after
$1800B0. I found, by setting the count above that, that the possibility
had been ignored by DOS coders!


BTW, a DOS clone has what must be the most harmless possible DOS bug -
the comment about the leapness of AD 2400 is wrong.


My program HUNT can report all 2^32 possible values of a file datestamp,
from 1980-00-00 00:00:00 to 2107:15:31 31:63:62; and another program can
set them (?). My HUNTTEST.ZIP contains zero-length files with
interesting dates.


But I have only worked with PC-AT and later.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Ruud Baltissen

unread,
Nov 20, 2011, 5:41:51 AM11/20/11
to
Hallo Rudy,


> The program you spoke of is most likely a TSR,

No, and I sure about that. I disassembled one of those RTC programs
and it read out the RTC and it used interrupts provided by DOS to set
the time and date. It only had to be started once in AUTOEXEC.BAT.
I also found a BIOS that read the RTC and set the time by manipulating
the memory I mentioned before. But it didn't set the date :
( (otherwise I wouldn't have had the need to ask this question)

Ruud Baltissen

unread,
Nov 20, 2011, 5:49:49 AM11/20/11
to
Hallo Ross,


> The Commododore PC BIOS is presumably providing the RTC time to DOS
> through INT 1Ah, AH=02.

Yes, it does! Thank you !!!
Now I can incorperate this in my own BIOS as well.

Ruud Baltissen

unread,
Nov 20, 2011, 5:58:31 AM11/20/11
to
Hallo John,
Ross already gave me the needed info. But I had a look at your site
anyway: very interesting!
0 new messages