Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting time 1

Status
Not open for further replies.

ippe

Programmer
Apr 16, 2000
1
0
0
FI
Hi. I have a little very simple problem with assemler programing. I have to make a program that sets a time to my computer. It has to work like this: In DOS write &quot;set_time 13.12.2000&quot; then you check the time out with &quot;time&quot; and it has changed to &quot;13.12.2000&quot;. What kinda program should this be? I ain't so familiar with assembler 'cause I work with C/C++ and Java. Is there anyone who knows what to do?<br><br><A HREF="mailto:i_airaksinen@hotmail.com">i_airaksinen@hotmail.com</A>
 
You can use int 21h functions to get/set the time:<br>(All #'s are in Hex)<br><br>to get current time:<br>mov ax, 2c00<br>int 21<br><br>The following registers will contain;<br>ch = hour<br>cl = mins<br>dh = secs<br>dl = secs/100<br><br>to set current time:<br><br>setup the following registers:<br>ch = hour<br>cl = mins<br>dh = secs<br>dl = secs/100<br>And then do the below:<br><br>mov ax, 2d00<br>int 21<br><br>See Ralph Browns interupt list nore more info.<br> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
You can also use int 1Ah, function 02h to get the RTC time and function 03h to set it. You don't get the 1/100 sec granularity because DH sets and returns whole seconds and DL contains the daylight savings flag.<br>This is just an option. The interrupt accepts and returns the time values in BCD. zBuilder's answer is far more practical.<br>I only mention this interrupt because it addresses the CMOS directly and it's interesting to note the difference between CMOS time and BIOS time.<br> <p> <br><a href=mailto: > </a><br><a href= temporary Vorpalcom home page</a><br>Send me suggestions or comments on my current software project.
 
ippe:<br><br>As per your e-mail, here are the Date functions:<br>(All #'s are in Hex)<br><br>To get current date:<br><br>mov ax, 2a00<br>int 21<br><br>On return from above:<br><br>CX = year ( 1980 - 2099 )<br>DH = month<br>DL = day of month ( 1-31 )<br>Al = day of week ( 0 = sunday )<br><br>To set the date:<br><br>setup the following registers:<br><br>CX = year ( 1980 - 2099 )<br>DH = month<br>DL = day of month ( 1-31 )<br><br>And then do the below:<br><br>mov ax, 2b00<br>int 21<br> <p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top