Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6462 | pathoswith | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License. ;; |
||
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
8 | $Revision: 6462 $ |
||
9 | |||
10 | fsReadCMOS: |
||
11 | out 70h, al |
||
12 | in al, 71h |
||
13 | xor ah, ah |
||
14 | shl ax, 4 |
||
15 | shr al, 4 |
||
16 | aad |
||
17 | ret |
||
18 | |||
19 | fsGetTime: |
||
20 | mov al, 7 |
||
21 | call fsReadCMOS |
||
22 | ror eax, 8 |
||
23 | mov al, 8 |
||
24 | call fsReadCMOS |
||
25 | ror eax, 8 |
||
26 | mov al, 9 |
||
27 | call fsReadCMOS |
||
28 | add eax, 2000 |
||
29 | ror eax, 16 |
||
30 | push eax |
||
31 | xor eax, eax |
||
32 | call fsReadCMOS |
||
33 | ror eax, 8 |
||
34 | mov al, 2 |
||
35 | call fsReadCMOS |
||
36 | ror eax, 8 |
||
37 | mov al, 4 |
||
38 | call fsReadCMOS |
||
39 | ror eax, 16 |
||
40 | push eax |
||
41 | mov esi, esp |
||
42 | add esp, 8 |
||
43 | fsCalculateTime: |
||
44 | ; in: esi -> data block |
||
45 | ; out: eax = seconds since 01.01.2001 |
||
46 | movzx eax, word [esi+6] |
||
47 | sub eax, 2001 |
||
48 | jnc @f |
||
49 | xor eax, eax |
||
50 | @@: |
||
51 | mov edx, months |
||
52 | mov ebx, eax |
||
53 | inc eax |
||
54 | test eax, 3 |
||
55 | jnz @f |
||
56 | add edx, 12 |
||
57 | @@: |
||
58 | movzx eax, byte [esi+5] |
||
59 | dec eax |
||
60 | xor ecx, ecx |
||
61 | @@: |
||
62 | dec eax |
||
63 | js @f |
||
64 | add cl, [edx+eax] |
||
65 | adc ch, 0 |
||
66 | jmp @b |
||
67 | @@: |
||
68 | mov eax, ebx ; years |
||
69 | mov edx, 365 |
||
70 | mul edx |
||
71 | shr ebx, 2 |
||
72 | add eax, ebx |
||
73 | add eax, ecx |
||
74 | mov bl, [esi+4] |
||
75 | dec eax |
||
76 | add eax, ebx ; days |
||
77 | mov dl, 24 |
||
78 | mul edx |
||
79 | mov bl, [esi+2] |
||
80 | add eax, ebx ; hours |
||
81 | mov ecx, 60 |
||
82 | mul ecx |
||
83 | mov bl, [esi+1] |
||
84 | add eax, ebx ; minutes |
||
85 | mul ecx |
||
86 | mov bl, [esi] |
||
87 | add eax, ebx |
||
88 | ret |
||
89 | |||
90 | iglobal |
||
91 | months db 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
||
92 | months2 db 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 |
||
93 | endg |
||
94 | |||
95 | fsTime2bdfe: |
||
96 | ; in: eax = seconds since 01.01.2001 |
||
97 | ; edi -> data block |
||
98 | ; out: edi = edi+8 |
||
99 | xor edx, edx |
||
100 | mov ecx, 60 |
||
101 | div ecx |
||
102 | mov [edi], dl |
||
103 | xor edx, edx |
||
104 | div ecx |
||
105 | mov [edi+1], dl |
||
106 | xor edx, edx |
||
107 | mov cl, 24 |
||
108 | div ecx |
||
109 | mov [edi+2], dx |
||
110 | xor edx, edx |
||
111 | mov cx, 365 |
||
112 | div ecx |
||
113 | mov ebx, eax |
||
114 | add ebx, 2001 |
||
115 | shr eax, 2 |
||
116 | sub edx, eax |
||
117 | jns @f |
||
118 | dec ebx |
||
119 | add edx, 365 |
||
120 | test ebx, 3 |
||
121 | jnz @f |
||
122 | inc edx |
||
123 | @@: |
||
124 | xor eax, eax |
||
125 | mov ecx, months-1 |
||
126 | test ebx, 3 |
||
127 | jnz @f |
||
128 | add ecx, 12 |
||
129 | @@: |
||
130 | inc ecx |
||
131 | inc eax |
||
132 | sub dl, [ecx] |
||
133 | jnc @b |
||
134 | dec dh |
||
135 | jns @b |
||
136 | add dl, [ecx] |
||
137 | inc edx |
||
138 | mov [edi+4], dl |
||
139 | mov [edi+5], al |
||
140 | mov [edi+6], bx |
||
141 | add edi, 8 |
||
142 | ret |