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
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
.import __systime
|
|
|
|
.importzp ptr1, sreg, tmp1
|
2002-11-12 19:54:30 +00:00
|
|
|
|
|
|
|
.include "errno.inc"
|
|
|
|
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
.proc _time
|
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
pha
|
|
|
|
txa
|
|
|
|
pha ; Save timep
|
|
|
|
|
|
|
|
jsr __systime ; Get the time (machine dependent)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
; If the result is less than zero, set ERRNO
|
2002-11-12 19:54:30 +00:00
|
|
|
|
2002-11-12 22:36:02 +00:00
|
|
|
@L1: ldy sreg+1
|
|
|
|
bpl @L2
|
2004-05-13 21:09:08 +00:00
|
|
|
|
2002-11-12 19:54:30 +00:00
|
|
|
lda #ENOSYS ; Function not implemented
|
2004-05-13 21:09:08 +00:00
|
|
|
jsr __seterrno ; Set __errno
|
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
|
|
|
|
|
|
|
|
|