Doc. # 1-0003387 | |||
---|---|---|---|
Date Updated | 10-22-2007 | Date Created | 07-27-2000 |
Document Type | Knowledge Base | Related OS | |
Related Product |
RTC programming and test | |||
---|---|---|---|
Solution:
There are three system times in a computer system ?DOS time, BIOS time and
RTC(CMOS) time. For example, under DOS environment, we can access the three
system times by using:
DOS interrupt 0x21, 0x2A/0x2C
BIOS interrupt 0x1A, 0x04/0x02
RTC(CMOS) direct port addressing
However, if you check these three system simultaneously, you will find that the
DOS time is always different from the BIOS time (slower or faster). As a
result, it is better for an application to use the BIOS time instead of using
DOS time.
Get DOS Date
Software interrupt AH = 0x2A
CX:Year
DH:Month
DL:Day
AL:
0 - Sunday
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
Set DOS Date
Software interrupt AH = 0x2B
Success: AL - 0
Fail : AL - FF
Get DOS Time
Software interrupt AH = 0x2C
CH for Hour : 0-23
CL for Minute : 0-59
DH for Second : 0-59
DL for 1/100 second : 0-00
Set DOS Time
Software interrupt AH = 0x2D
Success: AL=0
Fail: AL=FF
For BIOS Time
Software Interrupt 0x1A, 0x04/0x02
Get RTC Date (CMOS)
To read 128 Bytes CMOS data (for AWARD BIOS), you must use direct port address.
Index Port 70
Data Port 71
For Year (09H)
C:>DEBUG
-o 70 09
-i 71
98
For Centry (32H)
C:>DEBUG
-o 70 32
-i 71
19
I am sending you a small utility Viewcmos.exe. It can show the three system
time at same time.
As for the programing and register please refer to the source code time.c and
you can run the example file R-time.exe
There is an tsr program that can update DOS time continuously.
|