mirror of
https://github.com/cc65/cc65.git
synced 2024-08-19 02:29:33 +00:00
77 lines
1.2 KiB
ArmAsm
77 lines
1.2 KiB
ArmAsm
;
|
|
; Oliver Schmidt, 22.08.2006
|
|
;
|
|
; time_t _systime (void);
|
|
; /* Similar to time(), but:
|
|
; * - Is not ISO C
|
|
; * - Does not take the additional pointer
|
|
; * - Does not set errno when returning -1
|
|
; */
|
|
;
|
|
|
|
.export __systime
|
|
.import _mktime
|
|
|
|
.include "zeropage.inc"
|
|
.include "mli.inc"
|
|
|
|
.struct tm
|
|
tm_sec .word
|
|
tm_min .word
|
|
tm_hour .word
|
|
tm_mday .word
|
|
tm_mon .word
|
|
tm_year .word
|
|
tm_wday .word
|
|
tm_yday .word
|
|
tm_isdst .word
|
|
.endstruct
|
|
|
|
__systime:
|
|
; Update time
|
|
lda #GET_TIME_CALL
|
|
ldx #GET_TIME_COUNT
|
|
jsr callmli
|
|
bcs err
|
|
|
|
lda DATELO+1
|
|
lsr
|
|
php ; Save month msb
|
|
cmp #70 ; Year < 70?
|
|
bcs :+ ; No, leave alone
|
|
adc #100 ; Move 19xx to 20xx
|
|
: sta TM + tm::tm_year
|
|
lda DATELO
|
|
tax ; Save day
|
|
plp ; Restore month msb
|
|
ror
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
beq err ; [1..12] allows for validity check
|
|
tay
|
|
dey ; Move [1..12] to [0..11]
|
|
sty TM + tm::tm_mon
|
|
txa ; Restore day
|
|
and #%00011111
|
|
sta TM + tm::tm_mday
|
|
|
|
lda TIMELO+1
|
|
sta TM + tm::tm_hour
|
|
lda TIMELO
|
|
sta TM + tm::tm_min
|
|
|
|
lda #<TM
|
|
ldx #>TM
|
|
jmp _mktime
|
|
|
|
err: lda #$FF
|
|
tax
|
|
sta sreg
|
|
sta sreg+1
|
|
rts ; Return -1
|
|
|
|
.bss
|
|
|
|
TM: .tag tm |