Professional Documents
Culture Documents
Get and Set Time N Date
Get and Set Time N Date
;program get (and set) current time and date (int 1ah)
.model tiny
.code
call input ;
cmp cl,0ffh ; if error
jz endtime ; stop enter time
endinput:
mov cl,0ffh ; if error while input
ret ; close program
;---display curr time (got from CMOS)
show_time:
mov ah,2
int 1ah ; get curr time from CMOS
xor ah,ah
mov bl,10h
mov al,ch
mov [hour],ch ;
div bl ; div by 10h
add ax,'00' ;
mov word ptr [hourp],ax ;
xor ah,ah ;
mov al,cl
mov [min],cl ;
div bl ; div by 10h
add ax,'00' ;
mov word ptr [minp],ax ;
xor ah,ah
mov al,dh
div bl ; div by 10h
add ax,'00' ;
mov word ptr [secp],ax
mov ah,9
lea dx,msg ; show curr time msg
int 21h
ret
mov ah,9
lea dx,msg2 ; display curr date msg
int 21h
ret
.data
msg db 0dh,0ah,'Now time is '; \
hourp db '00:'; curr time msg
minp db '00:'; /
secp db '00',0dh,0ah,'$'
promt db 'Please enter new time in format HH:MM',0dh,0ah,'$' ; enter new time msg
promt2 db 'Please enter new date in format DD.MM.YYYY',0dh,0ah,'$' ; enter new date
msg
ertime db 0dh,0ah,'Error in format time or date$' ; error msg
msg2 db 0dh,0ah,'Now date is '; \
dayp db '00.';
monthp db '00.'; curr date msg
centuryp db '00';
yearp db '00',0dh,0ah,'$'; /
hour db ? ; vars to store hours, mins, century, year, month, day
min db ?
century db ?
year db ?
month db ?
day db ?
end start
share improve this question
dedoki
341●3●11●22
add a comment
1 Answer
up vote0down voteaccepted
Setting the real-time clock date will not affect the system date. This is because the real-time
clock is read once upon system startup, updating the system timer. All other references to date
use the system timer. If either the real-time clock date is changed (via this service) or the
system timer is changed (via Service 01h), the other date is not changed accordingly.
Even though the system uses the system timer for date information, both the real-time clock
and the system timer are updated continuously.
http://www.cs.ubbcluj.ro/~dadi/ac/doc/ng8f85f.html
share improve this answer
dedoki
341●3●11●22
Your Answer
Body
Add picture
Log in
OR
Name
By posting your answer, you agree to the privacy policy and terms of service.
meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app