85 lines
1.3 KiB
Plaintext
85 lines
1.3 KiB
Plaintext
; The OS/K Team licenses this file to you under the MIT license.
|
|
; See the LICENSE file in the project root for more information.
|
|
|
|
;
|
|
; struct TIME
|
|
; {
|
|
; byte sec; +0 (0-59)
|
|
; byte min; +1 (0-59)
|
|
; byte hour; +2 (0-23)
|
|
; byte mday; +3 (0-31)
|
|
; byte month; +4 (0-11)
|
|
; byte; +5 (pad)
|
|
; word year; +6 (0-65536)
|
|
; word yday; +8 (0-365)
|
|
; word; +10 (pad)
|
|
; dword; +12 (pad)
|
|
; } 16 bytes
|
|
;
|
|
|
|
;
|
|
; int DaysInYear(int year)
|
|
;
|
|
DaysInYear:
|
|
mov eax, 365
|
|
|
|
; divisible by 4?
|
|
rem ecx, ax0, 4
|
|
jrcxnz .end
|
|
|
|
; divisible by 100?
|
|
rem ecx, ax0, 100
|
|
jrcxnz .leap
|
|
|
|
; divisible by 400?
|
|
rem ecx, ax0, 400
|
|
jrcxnz .end
|
|
|
|
.leap:
|
|
inc eax
|
|
|
|
.end:
|
|
ret
|
|
|
|
;
|
|
; TIME *GetTimeUTC(void)
|
|
;
|
|
GetTimeUTC:
|
|
ytime
|
|
|
|
mov edi, .buf
|
|
|
|
; seconds
|
|
rem esi, eax, 60
|
|
mov b[edi], esi
|
|
|
|
; minutes
|
|
div esi, eax, 60
|
|
rem esi, 60
|
|
mov b[edi+1], esi
|
|
|
|
; hours
|
|
div esi, eax, 3600
|
|
rem esi, 24
|
|
mov b[edi+2], esi
|
|
|
|
; month days
|
|
div esi, eax, 3600*24
|
|
mov b[edi+3], esi
|
|
|
|
; month
|
|
mov b[edi+4], rbx
|
|
|
|
; years
|
|
mov w[edi+6], ecx
|
|
|
|
;
|
|
; ydays (TODO)
|
|
;
|
|
|
|
mov eax, .buf
|
|
ret
|
|
|
|
.buf = [24]
|
|
|