]> git.sur5r.net Git - cc65/blob - libsrc/common/time.s
Removed comment about a cast that is no longer necessary
[cc65] / libsrc / common / time.s
1 ;
2 ; Ullrich von Bassewitz, 12.11.2002
3 ;
4 ; time_t __fastcall__ time (time_t* timep);
5 ;
6
7         .export         _time
8
9         .import         __systime
10         .import         __errno
11         .importzp       ptr1, sreg, tmp1
12
13         .include        "errno.inc"
14
15
16 .code
17
18 .proc   _time
19
20         pha
21         txa
22         pha                     ; Save timep
23
24         jsr     __systime       ; Get the time (machine dependent)
25
26         sta     tmp1            ; Save low byte of result
27
28 ; Restore timep and check if it is NULL
29
30         pla
31         sta     ptr1
32         pla
33         sta     ptr1+1          ; Restore timep
34         ora     ptr1            ; timep == 0?
35         beq     @L1
36
37 ; timep is not NULL, store the result there
38
39         ldy     #3
40         lda     sreg+1
41         sta     (ptr1),y
42         dey
43         lda     sreg
44         sta     (ptr1),y
45         dey
46         txa
47         sta     (ptr1),y
48         dey
49         lda     tmp1
50         sta     (ptr1),y
51
52 ; If the result is less than zero, set ERRNO
53
54 @L1:    ldy     sreg+1
55         bpl     @L2
56
57         lda     #$00
58         sta     __errno+1
59         lda     #ENOSYS         ; Function not implemented
60         sta     __errno
61
62 ; Reload the low byte of the result and return
63
64 @L2:    lda     tmp1
65         rts
66
67 .endproc
68
69