2007-03-26 14:18:08 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2009-11-20 19:50:43 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
|
2007-03-26 14:18:08 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2007-07-27 15:52:03 +02:00
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
;setting date,time,clock and alarm-clock
|
|
|
|
;add sys_settime at servetable as for ex. 22 fcn:
|
|
|
|
; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK
|
|
|
|
; ebx =0 - set time ecx - 00SSMMHH
|
|
|
|
; ebx =1 - set date ecx=00DDMMYY
|
|
|
|
; ebx =2 - set day of week ecx- 1-7
|
|
|
|
; ebx =3 - set alarm-clock ecx - 00SSMMHH
|
|
|
|
; out: 0 -Ok 1 -wrong format 2 -battery low
|
|
|
|
sys_settime:
|
2009-11-20 19:50:43 +01:00
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
cli
|
|
|
|
mov al,0x0d
|
|
|
|
out 0x70,al
|
|
|
|
in al,0x71
|
|
|
|
bt ax,7
|
|
|
|
jnc bat_low
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ebx,2 ;day of week
|
2005-10-06 19:56:22 +02:00
|
|
|
jne nosetweek
|
2009-11-20 19:50:43 +01:00
|
|
|
test ecx,ecx ;test day of week
|
2005-10-06 19:56:22 +02:00
|
|
|
je wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ecx,7
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
mov edx,0x70
|
2005-10-06 19:56:22 +02:00
|
|
|
call startstopclk
|
|
|
|
dec edx
|
|
|
|
mov al,6
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,cl
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
jmp endsettime
|
|
|
|
nosetweek: ;set date
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ebx,1
|
2005-10-06 19:56:22 +02:00
|
|
|
jne nosetdate
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp cl,0x99 ;test year
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,4
|
|
|
|
cmp cl,0x90
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ch,0x99 ;test month
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,4
|
|
|
|
test ch,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
je wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ch,0x12
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,8
|
|
|
|
bswap ecx ;ebx=00YYMMDD
|
|
|
|
test cl,cl ;test day
|
2005-10-06 19:56:22 +02:00
|
|
|
je wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,4
|
|
|
|
cmp cl,0x90
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,4
|
|
|
|
cmp ch,2 ;February
|
2005-10-06 19:56:22 +02:00
|
|
|
jne testday
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp cl,0x29
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
|
|
|
jmp setdate
|
|
|
|
testday:
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ch,8
|
2005-10-06 19:56:22 +02:00
|
|
|
jb testday1 ;Aug-Dec
|
2009-11-20 19:50:43 +01:00
|
|
|
bt cx,8
|
2005-10-06 19:56:22 +02:00
|
|
|
jnc days31
|
|
|
|
jmp days30
|
|
|
|
testday1:
|
2009-11-20 19:50:43 +01:00
|
|
|
bt cx,8 ;Jan-Jul ex.Feb
|
2005-10-06 19:56:22 +02:00
|
|
|
jnc days30
|
|
|
|
days31:
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp cl,0x31
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
|
|
|
jmp setdate
|
|
|
|
days30:
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp cl,0x30
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
|
|
|
setdate:
|
2009-11-20 19:50:43 +01:00
|
|
|
mov edx,0x70
|
2005-10-06 19:56:22 +02:00
|
|
|
call startstopclk
|
|
|
|
dec edx
|
|
|
|
mov al,7 ;set days
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,cl
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,8 ;set months
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,9 ;set years
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,8
|
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
jmp endsettime
|
|
|
|
nosetdate: ;set time or alarm-clock
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ebx,3
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp cl,0x23
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ch,0x59
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,4
|
|
|
|
cmp cl,0x90
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ch,0x92
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,4
|
|
|
|
bswap ecx ;00HHMMSS
|
|
|
|
cmp cl,0x59
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shl ecx,4
|
|
|
|
cmp cl,0x90
|
2005-10-06 19:56:22 +02:00
|
|
|
ja wrongtime
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,4
|
|
|
|
|
|
|
|
mov edx,0x70
|
2005-10-06 19:56:22 +02:00
|
|
|
call startstopclk
|
|
|
|
dec edx
|
2009-11-20 19:50:43 +01:00
|
|
|
cmp ebx,3
|
|
|
|
|
|
|
|
je setalarm
|
2005-10-06 19:56:22 +02:00
|
|
|
xor eax,eax ;al=0-set seconds
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,cl
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,2 ;set minutes
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,4 ;set hours
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,8
|
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
jmp endsettime
|
|
|
|
setalarm:
|
|
|
|
mov al,1 ;set seconds for al.
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,cl
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,3 ;set minutes for al.
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,5 ;set hours for al.
|
|
|
|
out dx,al
|
|
|
|
inc edx
|
2009-11-20 19:50:43 +01:00
|
|
|
shr ecx,8
|
|
|
|
mov al,ch
|
2005-10-06 19:56:22 +02:00
|
|
|
out dx,al
|
|
|
|
dec edx
|
|
|
|
mov al,0x0b ;enable irq's
|
|
|
|
out dx,al
|
|
|
|
inc dx
|
|
|
|
in al,dx
|
|
|
|
bts ax,5 ;set bit 5
|
|
|
|
out dx,al
|
|
|
|
endsettime:
|
|
|
|
dec edx
|
|
|
|
call startstopclk
|
|
|
|
sti
|
2009-11-20 19:50:43 +01:00
|
|
|
and [esp+36-4],dword 0
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
|
|
|
bat_low:
|
|
|
|
sti
|
2009-11-20 19:50:43 +01:00
|
|
|
mov [esp+36-4],dword 2
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
|
|
|
wrongtime:
|
|
|
|
sti
|
2009-11-20 19:50:43 +01:00
|
|
|
mov [esp+36-4],dword 1
|
2005-10-06 19:56:22 +02:00
|
|
|
ret
|
2007-03-26 14:18:08 +02:00
|
|
|
|
2005-10-06 19:56:22 +02:00
|
|
|
startstopclk:
|
|
|
|
mov al,0x0b
|
|
|
|
out dx,al
|
|
|
|
inc dx
|
|
|
|
in al,dx
|
|
|
|
btc ax,7
|
|
|
|
out dx,al
|
|
|
|
ret
|