Rev 593 | Rev 2455 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
1279 | Lrz | 3 | ;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;; |
431 | serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
593 | mikedld | 8 | $Revision: 1279 $ |
9 | |||
10 | |||
1 | ha | 11 | ;setting date,time,clock and alarm-clock |
12 | ;add sys_settime at servetable as for ex. 22 fcn: |
||
13 | ; 22 - SETTING DATE TIME, CLOCK AND ALARM-CLOCK |
||
14 | ; ebx =0 - set time ecx - 00SSMMHH |
||
15 | ; ebx =1 - set date ecx=00DDMMYY |
||
16 | ; ebx =2 - set day of week ecx- 1-7 |
||
17 | ; ebx =3 - set alarm-clock ecx - 00SSMMHH |
||
18 | ; out: 0 -Ok 1 -wrong format 2 -battery low |
||
19 | sys_settime: |
||
1279 | Lrz | 20 | |
1 | ha | 21 | cli |
22 | mov al,0x0d |
||
23 | out 0x70,al |
||
24 | in al,0x71 |
||
25 | bt ax,7 |
||
26 | jnc bat_low |
||
1279 | Lrz | 27 | cmp ebx,2 ;day of week |
1 | ha | 28 | jne nosetweek |
1279 | Lrz | 29 | test ecx,ecx ;test day of week |
1 | ha | 30 | je wrongtime |
1279 | Lrz | 31 | cmp ecx,7 |
1 | ha | 32 | ja wrongtime |
1279 | Lrz | 33 | mov edx,0x70 |
1 | ha | 34 | call startstopclk |
35 | dec edx |
||
36 | mov al,6 |
||
37 | out dx,al |
||
38 | inc edx |
||
1279 | Lrz | 39 | mov al,cl |
1 | ha | 40 | out dx,al |
41 | jmp endsettime |
||
42 | nosetweek: ;set date |
||
1279 | Lrz | 43 | cmp ebx,1 |
1 | ha | 44 | jne nosetdate |
1279 | Lrz | 45 | cmp cl,0x99 ;test year |
1 | ha | 46 | ja wrongtime |
1279 | Lrz | 47 | shl ecx,4 |
48 | cmp cl,0x90 |
||
1 | ha | 49 | ja wrongtime |
1279 | Lrz | 50 | cmp ch,0x99 ;test month |
1 | ha | 51 | ja wrongtime |
1279 | Lrz | 52 | shr ecx,4 |
53 | test ch,ch |
||
1 | ha | 54 | je wrongtime |
1279 | Lrz | 55 | cmp ch,0x12 |
1 | ha | 56 | ja wrongtime |
1279 | Lrz | 57 | shl ecx,8 |
58 | bswap ecx ;ebx=00YYMMDD |
||
59 | test cl,cl ;test day |
||
1 | ha | 60 | je wrongtime |
1279 | Lrz | 61 | shl ecx,4 |
62 | cmp cl,0x90 |
||
1 | ha | 63 | ja wrongtime |
1279 | Lrz | 64 | shr ecx,4 |
65 | cmp ch,2 ;February |
||
1 | ha | 66 | jne testday |
1279 | Lrz | 67 | cmp cl,0x29 |
1 | ha | 68 | ja wrongtime |
69 | jmp setdate |
||
70 | testday: |
||
1279 | Lrz | 71 | cmp ch,8 |
1 | ha | 72 | jb testday1 ;Aug-Dec |
1279 | Lrz | 73 | bt cx,8 |
1 | ha | 74 | jnc days31 |
75 | jmp days30 |
||
76 | testday1: |
||
1279 | Lrz | 77 | bt cx,8 ;Jan-Jul ex.Feb |
1 | ha | 78 | jnc days30 |
79 | days31: |
||
1279 | Lrz | 80 | cmp cl,0x31 |
1 | ha | 81 | ja wrongtime |
82 | jmp setdate |
||
83 | days30: |
||
1279 | Lrz | 84 | cmp cl,0x30 |
1 | ha | 85 | ja wrongtime |
86 | setdate: |
||
1279 | Lrz | 87 | mov edx,0x70 |
1 | ha | 88 | call startstopclk |
89 | dec edx |
||
90 | mov al,7 ;set days |
||
91 | out dx,al |
||
92 | inc edx |
||
1279 | Lrz | 93 | mov al,cl |
1 | ha | 94 | out dx,al |
95 | dec edx |
||
96 | mov al,8 ;set months |
||
97 | out dx,al |
||
98 | inc edx |
||
1279 | Lrz | 99 | mov al,ch |
1 | ha | 100 | out dx,al |
101 | dec edx |
||
102 | mov al,9 ;set years |
||
103 | out dx,al |
||
104 | inc edx |
||
1279 | Lrz | 105 | shr ecx,8 |
106 | mov al,ch |
||
1 | ha | 107 | out dx,al |
108 | jmp endsettime |
||
109 | nosetdate: ;set time or alarm-clock |
||
1279 | Lrz | 110 | cmp ebx,3 |
1 | ha | 111 | ja wrongtime |
1279 | Lrz | 112 | cmp cl,0x23 |
1 | ha | 113 | ja wrongtime |
1279 | Lrz | 114 | cmp ch,0x59 |
1 | ha | 115 | ja wrongtime |
1279 | Lrz | 116 | shl ecx,4 |
117 | cmp cl,0x90 |
||
1 | ha | 118 | ja wrongtime |
1279 | Lrz | 119 | cmp ch,0x92 |
1 | ha | 120 | ja wrongtime |
1279 | Lrz | 121 | shl ecx,4 |
122 | bswap ecx ;00HHMMSS |
||
123 | cmp cl,0x59 |
||
1 | ha | 124 | ja wrongtime |
1279 | Lrz | 125 | shl ecx,4 |
126 | cmp cl,0x90 |
||
1 | ha | 127 | ja wrongtime |
1279 | Lrz | 128 | shr ecx,4 |
129 | |||
130 | mov edx,0x70 |
||
1 | ha | 131 | call startstopclk |
132 | dec edx |
||
1279 | Lrz | 133 | cmp ebx,3 |
134 | |||
135 | je setalarm |
||
1 | ha | 136 | xor eax,eax ;al=0-set seconds |
137 | out dx,al |
||
138 | inc edx |
||
1279 | Lrz | 139 | mov al,cl |
1 | ha | 140 | out dx,al |
141 | dec edx |
||
142 | mov al,2 ;set minutes |
||
143 | out dx,al |
||
144 | inc edx |
||
1279 | Lrz | 145 | mov al,ch |
1 | ha | 146 | out dx,al |
147 | dec edx |
||
148 | mov al,4 ;set hours |
||
149 | out dx,al |
||
150 | inc edx |
||
1279 | Lrz | 151 | shr ecx,8 |
152 | mov al,ch |
||
1 | ha | 153 | out dx,al |
154 | jmp endsettime |
||
155 | setalarm: |
||
156 | mov al,1 ;set seconds for al. |
||
157 | out dx,al |
||
158 | inc edx |
||
1279 | Lrz | 159 | mov al,cl |
1 | ha | 160 | out dx,al |
161 | dec edx |
||
162 | mov al,3 ;set minutes for al. |
||
163 | out dx,al |
||
164 | inc edx |
||
1279 | Lrz | 165 | mov al,ch |
1 | ha | 166 | out dx,al |
167 | dec edx |
||
168 | mov al,5 ;set hours for al. |
||
169 | out dx,al |
||
170 | inc edx |
||
1279 | Lrz | 171 | shr ecx,8 |
172 | mov al,ch |
||
1 | ha | 173 | out dx,al |
174 | dec edx |
||
175 | mov al,0x0b ;enable irq's |
||
176 | out dx,al |
||
177 | inc dx |
||
178 | in al,dx |
||
179 | bts ax,5 ;set bit 5 |
||
180 | out dx,al |
||
181 | endsettime: |
||
182 | dec edx |
||
183 | call startstopclk |
||
184 | sti |
||
1279 | Lrz | 185 | and [esp+36-4],dword 0 |
1 | ha | 186 | ret |
187 | bat_low: |
||
188 | sti |
||
1279 | Lrz | 189 | mov [esp+36-4],dword 2 |
1 | ha | 190 | ret |
191 | wrongtime: |
||
192 | sti |
||
1279 | Lrz | 193 | mov [esp+36-4],dword 1 |
1 | ha | 194 | ret |
431 | serge | 195 | |
1 | ha | 196 | startstopclk: |
197 | mov al,0x0b |
||
198 | out dx,al |
||
199 | inc dx |
||
200 | in al,dx |
||
201 | btc ax,7 |
||
202 | out dx,al |
||
203 | ret |