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