0
|
1 ********************************************************************
|
|
2 * Clock2 - Software clock driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * This clock driver is not only Y2K compliant, but also will handle
|
|
7 * leap year calculations correctly for all years from 1900 A.D. to
|
|
8 * 2155 A.D. Note that this driver is ONLY valid from 1900-2155 and
|
|
9 * will not handle years outside of this range.
|
|
10 *
|
|
11 * Ed. Comments Who YY/MM/DD
|
|
12 * ------------------------------------------------------------------
|
|
13 * 1 Obtained source and commented/restructured BGP 98/10/05
|
|
14 * 2 Fixed leap year assumptions about 1900 and BGP 99/05/02
|
|
15 * 2100 so that they do not have Feb. 29
|
|
16
|
|
17 nam Clock2
|
|
18 ttl Software clock driver
|
|
19
|
|
20 rev set 1
|
|
21 edition set 2
|
|
22
|
|
23 ifp1
|
|
24 use defsfile
|
|
25 endc
|
|
26
|
|
27 mod len2,name2,systm+objct,reent+rev,entry,0
|
|
28
|
|
29 name2 fcs "Clock2"
|
|
30 fcb edition
|
|
31
|
|
32 entry bra Init 0 init hardware
|
|
33 nop
|
|
34 bra GetTime 3 get time to D.Time (once a second??)
|
|
35 nop
|
|
36 bra SetTime 6 set time fm D.Time
|
|
37 nop
|
|
38
|
|
39 * Init and SetTime do nothing for the software clock
|
|
40 Init
|
|
41 SetTime clrb setime must clrb if okay
|
|
42 rts nothing for this guy
|
|
43
|
|
44 GetTime ldd <D.Min get minutes, seconds
|
|
45 * Second increment
|
|
46 incb secs+1
|
|
47 cmpb #60 minute yet?
|
|
48 blo L0080 ..no
|
|
49 * Minute increment
|
|
50 inca minute+1
|
|
51 cmpa #60 hour yet?
|
|
52 blo L007F ..no
|
|
53 ldd <D.Day get day, hour
|
|
54 * Hour increment
|
|
55 incb hour+1
|
|
56 cmpb #24 day yet?
|
|
57 blo L007C ..no
|
|
58 * Day increment
|
|
59 inca day+1
|
|
60 leax >months,pcr point to months table
|
|
61 ldb <D.Month this month
|
|
62 cmpa b,x end of month?
|
|
63 bls L007B ..no
|
|
64 * Here we are at the case where the incremented day in A is larger
|
|
65 * than the max day in the month.
|
|
66 * Now's our chance to check for leap year case.
|
|
67 cmpb #2 yes, is it Feb?
|
|
68 bne L006D ..no, ok
|
|
69 ldb <D.Year else get year
|
|
70 beq L006D 1900 has no leap year.. +BGP+ 1999/05/02
|
|
71 cmpb #200 is year 2100? +BGP+ 1999/05/02
|
|
72 beq L006D yep, has no leap year.. +BGP+ 1999/05/02
|
|
73 andb #$03 check for leap year
|
|
74 cmpd #$1D00 29th on leap year?
|
|
75 beq L007B ..yes, skip it
|
|
76 L006D ldd <D.Year else month+1
|
|
77 * Month increment
|
|
78 incb
|
|
79 cmpb #13 end of year?
|
|
80 blo L0077 ..no
|
|
81 * Year increment
|
|
82 * Note that once A rolls over to 0, it assumes year 1900.
|
|
83 inca year+1
|
|
84 ldb #$01 set month to jan
|
|
85 L0077 std <D.Year save year, month
|
|
86 lda #$01 day=1st
|
|
87 L007B clrb hour=midnite
|
|
88 L007C std <D.Day save day,hour
|
|
89 clra minute=00
|
|
90 L007F clrb seconds=00
|
|
91 L0080 std <D.Min save min,secs
|
|
92 rts
|
|
93
|
|
94 months fcb $00
|
|
95 fcb 31 jan
|
|
96 fcb 28 feb
|
|
97 fcb 31 mar
|
|
98 fcb 30 apr
|
|
99 fcb 31 may
|
|
100 fcb 30 jun
|
|
101 fcb 31 jul
|
|
102 fcb 31 aug
|
|
103 fcb 30 sep
|
|
104 fcb 31 oct
|
|
105 fcb 30 nov
|
|
106 fcb 31 dec
|
|
107
|
|
108 emod
|
|
109 len2 equ *
|
|
110 end
|
|
111
|