David2010
October 1st, 2010, 05:09 PM
This is a strange one.
The functions print "something" without error however the results are wrong. Generally speaking, with me the whole function don't work. xD
These two functions get the time and date from the BIOS and print it to the screen.
Date:
date:
%define RTCaddress 0x70
%define RTCdata 0x71
loop3: mov al,10 ;Get RTC register A
out RTCaddress,al
in al,RTCdata
test al,0x80 ;Is update in progress?
jne loop3 ; yes, wait
mov al,0x07 ;Get day
out RTCaddress,al
in al,RTCdata
mov [RTCtimeDay],al
mov al,0x08 ;Get month
out RTCaddress,al
in al,RTCdata
mov [RTCtimeMonth],al
mov al,0x09 ;Get year
out RTCaddress,al
in al,RTCdata
mov [RTCtimeYear],al
mov si, msg3
call print
mov si, [RTCtimeMonth]
call printints
mov si, msg1
call print
mov si, [RTCtimeDay]
call printints
mov si, msg1
call print
mov si, [RTCtimeYear]
call printints
mov si, msg2
call print
ret
msg1 db ' ', 0
msg2 db ' ', 0x0D, 0x0A, 0
msg3 db 'Month Day Year', 0x0D, 0x0A, 0
RTCtimeDay db 0, 0
RTCtimeMonth db 0, 0
RTCtimeYear db 0, 0
Time:
time:
%define RTCaddress 0x70
%define RTCdata 0x71
loop1: mov al,10 ;Get RTC register A
out RTCaddress,al
in al,RTCdata
test al,0x80 ;Is update in progress?
jne loop1 ; yes, wait
mov al,0x04 ;Get hours
out RTCaddress,al
in al,RTCdata
mov [RTCtimeHour],al
mov al,0x02 ;Get minutes
out RTCaddress,al
in al,RTCdata
mov [RTCtimeMinute],al
mov si, [RTCtimeHour]
call printints
mov si, msg_hours
call print
mov si, [RTCtimeMinute]
call printints
mov si, msg_minutes
call print
ret
msg_minutes db ' Minutes', 0x0D, 0x0A, 0
msg_hours db ' Hours ', 0
RTCtimeHour db 0, 0
RTCtimeMinute db 0, 0
The problem is, the data printed by these two functions are wrong.
I already checked the BIOS and made sure the date and time values were correct there.
--------------------------------------------
Register values after each function:
---------------------------------------------
Time function:
ax = 31704
cx = 64
dx = 1
bx = 40
si = 40
di = 0
Date function:
ax = 31704
cx = 64
dx = 1
bx = 44
si = 44
di = 0
The functions print "something" without error however the results are wrong. Generally speaking, with me the whole function don't work. xD
These two functions get the time and date from the BIOS and print it to the screen.
Date:
date:
%define RTCaddress 0x70
%define RTCdata 0x71
loop3: mov al,10 ;Get RTC register A
out RTCaddress,al
in al,RTCdata
test al,0x80 ;Is update in progress?
jne loop3 ; yes, wait
mov al,0x07 ;Get day
out RTCaddress,al
in al,RTCdata
mov [RTCtimeDay],al
mov al,0x08 ;Get month
out RTCaddress,al
in al,RTCdata
mov [RTCtimeMonth],al
mov al,0x09 ;Get year
out RTCaddress,al
in al,RTCdata
mov [RTCtimeYear],al
mov si, msg3
call print
mov si, [RTCtimeMonth]
call printints
mov si, msg1
call print
mov si, [RTCtimeDay]
call printints
mov si, msg1
call print
mov si, [RTCtimeYear]
call printints
mov si, msg2
call print
ret
msg1 db ' ', 0
msg2 db ' ', 0x0D, 0x0A, 0
msg3 db 'Month Day Year', 0x0D, 0x0A, 0
RTCtimeDay db 0, 0
RTCtimeMonth db 0, 0
RTCtimeYear db 0, 0
Time:
time:
%define RTCaddress 0x70
%define RTCdata 0x71
loop1: mov al,10 ;Get RTC register A
out RTCaddress,al
in al,RTCdata
test al,0x80 ;Is update in progress?
jne loop1 ; yes, wait
mov al,0x04 ;Get hours
out RTCaddress,al
in al,RTCdata
mov [RTCtimeHour],al
mov al,0x02 ;Get minutes
out RTCaddress,al
in al,RTCdata
mov [RTCtimeMinute],al
mov si, [RTCtimeHour]
call printints
mov si, msg_hours
call print
mov si, [RTCtimeMinute]
call printints
mov si, msg_minutes
call print
ret
msg_minutes db ' Minutes', 0x0D, 0x0A, 0
msg_hours db ' Hours ', 0
RTCtimeHour db 0, 0
RTCtimeMinute db 0, 0
The problem is, the data printed by these two functions are wrong.
I already checked the BIOS and made sure the date and time values were correct there.
--------------------------------------------
Register values after each function:
---------------------------------------------
Time function:
ax = 31704
cx = 64
dx = 1
bx = 40
si = 40
di = 0
Date function:
ax = 31704
cx = 64
dx = 1
bx = 44
si = 44
di = 0