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