Subversion Repositories Kolibri OS

Rev

Rev 6462 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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