2019-07-11 18:34:21 +02:00
|
|
|
; 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 rax, 365
|
|
|
|
|
|
|
|
; divisible by 4?
|
|
|
|
rem rcx, ax0, 4
|
2019-07-22 14:41:50 +02:00
|
|
|
jmp.cxnz .end
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
; divisible by 100?
|
|
|
|
rem rcx, ax0, 100
|
2019-07-22 14:41:50 +02:00
|
|
|
jmp.cxnz .leap
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
; divisible by 400?
|
|
|
|
rem rcx, ax0, 400
|
2019-07-22 14:41:50 +02:00
|
|
|
jmp.cxnz .end
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
.leap:
|
2019-08-03 17:41:44 +02:00
|
|
|
inc rax, 1
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
.end:
|
|
|
|
ret
|
|
|
|
|
|
|
|
;
|
|
|
|
; TIME *GetTimeUTC(void)
|
|
|
|
;
|
|
|
|
GetTimeUTC:
|
2019-07-22 13:18:13 +02:00
|
|
|
ytime ax0, ax1, ax2
|
2019-07-11 18:34:21 +02:00
|
|
|
mov rdx, .buf
|
|
|
|
|
|
|
|
; seconds
|
2019-07-22 13:18:13 +02:00
|
|
|
rem rcx, ax0, 60
|
2019-07-11 18:34:21 +02:00
|
|
|
mov b[rdx], rcx
|
|
|
|
|
|
|
|
; minutes
|
2019-07-22 13:18:13 +02:00
|
|
|
div rcx, ax0, 60
|
2019-07-17 20:26:03 +02:00
|
|
|
rem rcx, rcx, 60
|
2019-07-11 18:34:21 +02:00
|
|
|
mov b[rdx+1], rcx
|
|
|
|
|
|
|
|
; hours
|
2019-07-22 13:18:13 +02:00
|
|
|
div rcx, ax0, 3600
|
2019-07-17 20:26:03 +02:00
|
|
|
rem rcx, rcx, 24
|
2019-07-11 18:34:21 +02:00
|
|
|
mov b[rdx+2], rcx
|
|
|
|
|
|
|
|
; month days
|
2019-07-22 13:18:13 +02:00
|
|
|
div rcx, ax0, 3600*24
|
2019-07-11 18:34:21 +02:00
|
|
|
mov b[rdx+3], rcx
|
|
|
|
|
|
|
|
; month
|
2019-07-22 13:18:13 +02:00
|
|
|
mov b[rdx+4], ax1
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
; years
|
2019-07-22 13:18:13 +02:00
|
|
|
mov w[rdx+6], ax2
|
2019-07-11 18:34:21 +02:00
|
|
|
|
|
|
|
;
|
|
|
|
; ydays (TODO)
|
|
|
|
;
|
|
|
|
|
|
|
|
mov rax, .buf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.buf = [24]
|
|
|
|
|