1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/ka/crt/lib/time.k
julianb0 2a610f2d7a
vm
2019-07-17 22:25:50 +02:00

84 lines
1.4 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 rax, 365
; divisible by 4?
rem rcx, ax0, 4
b.nz rcx, zero, .end
; divisible by 100?
rem rcx, ax0, 100
b.nz rcx, zero, .leap
; divisible by 400?
rem rcx, ax0, 400
b.nz rcx, zero, .end
.leap:
inc rax
.end:
ret
;
; TIME *GetTimeUTC(void)
;
GetTimeUTC:
ytime r11, r12, r13
mov rdx, .buf
; seconds
rem rcx, r11, 60
mov b[rdx], rcx
; minutes
div rcx, r11, 60
rem rcx, rcx, 60
mov b[rdx+1], rcx
; hours
div rcx, r11, 3600
rem rcx, rcx, 24
mov b[rdx+2], rcx
; month days
div rcx, r11, 3600*24
mov b[rdx+3], rcx
; month
mov b[rdx+4], r12
; years
mov w[rdx+6], r13
;
; ydays (TODO)
;
mov rax, .buf
ret
.buf = [24]