1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 02:55:20 +00:00

Call _systime instead of always returning -1

git-svn-id: svn://svn.cc65.org/cc65/trunk@1509 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-11-12 22:36:02 +00:00
parent 2cd37d74e4
commit de7bb15dee

View File

@ -1,13 +1,14 @@
;
; Ullrich von Bassewitz, 12.11.2002
;
; time_t __fastcall__ time (time_t* t);
; time_t __fastcall__ time (time_t* timep);
;
.export _time
.import __systime
.import __errno
.importzp ptr1, sreg
.importzp ptr1, sreg, tmp1
.include "errno.inc"
@ -16,28 +17,51 @@
.proc _time
pha
txa
pha ; Save timep
jsr __systime ; Get the time (machine dependent)
sta tmp1 ; Save low byte of result
; Restore timep and check if it is NULL
pla
sta ptr1
stx ptr1+1 ; t
ldx #$FF
stx sreg
stx sreg+1
ora ptr1+1 ; t == 0?
pla
sta ptr1+1 ; Restore timep
ora ptr1 ; timep == 0?
beq @L1
ldy #$03
txa
@L0: sta (ptr1),y ; *t = -1
dey
bpl @L0
lda #$00
; timep is not NULL, store the result there
@L1: sta __errno+1
ldy #3
lda sreg+1
sta (ptr1),y
dey
lda sreg
sta (ptr1),y
dey
txa
sta (ptr1),y
dey
lda tmp1
sta (ptr1),y
; If the result is less than zero, set ERRNO
@L1: ldy sreg+1
bpl @L2
lda #$00
sta __errno+1
lda #ENOSYS ; Function not implemented
sta __errno
txa ; A = $FF
; Reload the low byte of the result and return
@L2: lda tmp1
rts
.endproc