2002-11-12 19:54:30 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 12.11.2002
|
|
|
|
;
|
2002-11-12 22:36:02 +00:00
|
|
|
; time_t __fastcall__ time (time_t* timep);
|
2002-11-12 19:54:30 +00:00
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _time
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2018-08-19 12:35:30 +00:00
|
|
|
.import decsp1, ldeaxi
|
2018-08-15 13:59:11 +00:00
|
|
|
.importzp ptr1, sreg, tmp1, tmp2
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
.include "time.inc"
|
2002-11-12 19:54:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
.proc _time
|
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
pha
|
|
|
|
txa
|
|
|
|
pha ; Save timep
|
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
; Get the time (machine dependent)
|
|
|
|
|
|
|
|
jsr decsp1
|
|
|
|
lda #<time
|
|
|
|
ldx #>time
|
|
|
|
jsr _clock_gettime
|
|
|
|
sta tmp2
|
2018-08-19 12:35:30 +00:00
|
|
|
lda #<time
|
|
|
|
ldx #>time
|
|
|
|
.assert timespec::tv_sec = 0, error
|
|
|
|
jsr ldeaxi
|
2002-11-12 22:36:02 +00:00
|
|
|
sta tmp1 ; Save low byte of result
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
; Restore timep and check if it is NULL
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
pla
|
2013-10-02 19:55:01 +00:00
|
|
|
sta ptr1+1
|
2002-11-12 22:36:02 +00:00
|
|
|
pla
|
2013-10-02 19:55:01 +00:00
|
|
|
sta ptr1 ; Restore timep
|
|
|
|
ora ptr1+1 ; timep == 0?
|
2002-11-12 19:54:30 +00:00
|
|
|
beq @L1
|
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
; timep is not NULL, store the result there
|
|
|
|
|
|
|
|
ldy #3
|
|
|
|
lda sreg+1
|
|
|
|
sta (ptr1),y
|
|
|
|
dey
|
|
|
|
lda sreg
|
|
|
|
sta (ptr1),y
|
|
|
|
dey
|
2002-11-12 19:54:30 +00:00
|
|
|
txa
|
2002-11-12 22:36:02 +00:00
|
|
|
sta (ptr1),y
|
2002-11-12 19:54:30 +00:00
|
|
|
dey
|
2002-11-12 22:36:02 +00:00
|
|
|
lda tmp1
|
|
|
|
sta (ptr1),y
|
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
; If the result is != 0, return -1
|
|
|
|
|
|
|
|
@L1: lda tmp2
|
|
|
|
beq @L2
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
tax
|
|
|
|
sta sreg
|
|
|
|
sta sreg+1
|
|
|
|
rts
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
; Reload the low byte of the result and return
|
|
|
|
|
|
|
|
@L2: lda tmp1
|
2002-11-12 19:54:30 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
.endproc
|
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Data
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2018-08-15 13:59:11 +00:00
|
|
|
.bss
|
|
|
|
time: .tag timespec
|