Mercurial > hg > Members > kono > nitros9-code
annotate level1/modules/clock.asm @ 201:668388823050
Fixed headers to be consistent
author | boisy |
---|---|
date | Mon, 15 Jul 2002 03:52:49 +0000 |
parents | 39ea0a63ce31 |
children | 4f81e616d397 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * Clock - OS-9 Level One V2 Clock module | |
3 * | |
4 * $Id$ | |
5 * | |
6 * NOTE: This clock is TOTALLY VALID for ALL DATES between 1900-2155 | |
7 * | |
8 * Ed. Comments Who YY/MM/DD | |
9 * ------------------------------------------------------------------ | |
201 | 10 * 5 From Tandy OS-9 Level One VR 02.00.00 |
11 * 6 Modified to handle leap years properly for BGP 99/05/03 | |
0 | 12 * 1900 and 2100 A.D. |
13 | |
14 nam Clock | |
15 ttl OS-9 Level One V2 Clock module | |
16 | |
17 ifp1 | |
18 use defsfile | |
19 endc | |
20 | |
21 tylg set Systm+Objct | |
22 atrv set ReEnt+rev | |
23 rev set $01 | |
201 | 24 edition set 6 |
0 | 25 |
26 mod eom,name,tylg,atrv,ClkEnt,size | |
27 | |
28 size equ . | |
29 | |
30 name fcs /Clock/ | |
31 fcb edition | |
32 | |
33 SysTbl fcb F$Time | |
34 fdb FTime-*-2 | |
87 | 35 fcb F$VIRQ |
36 fdb FVIRQ-*-2 | |
0 | 37 fcb $80 |
38 | |
39 * table of days of the month | |
40 MonthChk fcb 00 | |
41 fcb 31 January | |
42 fcb 28 February | |
43 fcb 31 March | |
44 fcb 30 April | |
45 fcb 31 May | |
46 fcb 30 June | |
47 fcb 31 July | |
48 fcb 31 August | |
49 fcb 30 September | |
50 fcb 31 October | |
51 fcb 30 November | |
52 fcb 31 December | |
53 | |
54 ClockIRQ clra | |
55 tfr a,dp set direct page to zero | |
56 lda PIA.U4+3 get hw byte | |
57 bmi L0032 branch if sync flag on | |
58 jmp [>D.SvcIRQ] | |
59 L0032 lda PIA.U4+2 clear interrupt? | |
60 dec <D.Tick decrement tick counter | |
61 bne L007F go around if not zero | |
62 ldd <D.Min get minutes/seconds | |
63 * Seconds increment | |
64 incb increment seconds | |
65 cmpb #60 full minute? | |
66 bcs L0079 nope... | |
67 * Minutes increment | |
68 inca else increment minute | |
69 cmpa #60 full hour? | |
70 bcs L0078 nope... | |
71 ldd <D.Day else increment day | |
72 * Hour increment | |
73 incb increment hour | |
74 cmpb #24 past 23rd hour? | |
75 bcs L0075 branch if not | |
76 * Day increment | |
77 inca else increment day | |
78 leax >MonthChk,pcr | |
79 ldb <D.Month | |
80 * cmpb #3 is this February? | |
81 * bne L005F | |
82 * ldb <D.Year check year | |
83 * beq L005F if century, it's a leap year | |
84 * andb #$03 leap year? (divisible by 4) | |
85 * beq L0060 nope | |
86 *L005F inca | |
87 *L0060 ldb <D.Month get month | |
88 cmpa b,x compare days to max days | |
89 bls L0074 branch if ok | |
90 cmpb #2 is this February? | |
91 bne L006X if not, go on to year/month | |
92 * Leap year cases checked here | |
93 ldb <D.Year else check for leap year cases | |
94 beq L006X branch if year 1900 | |
95 cmpb #200 is it 1900+200 (2100)? | |
96 beq L006X if so, branch | |
97 andb #$03 see if 2^4 bit set (leap year) | |
98 cmpd #$1D00 29th on leap year? | |
99 beq L0074 it's a leap year... | |
100 L006X ldd <D.Year else get year and month | |
101 * Month increment | |
102 incb increment month | |
103 cmpb #13 past December? | |
104 bcs L0070 branch if not | |
105 * Year increment | |
106 inca else in year | |
107 ldb #1 and start month in January | |
108 L0070 std <D.Year update year/month | |
109 lda #1 new month, first day | |
110 L0074 clrb hour 0 | |
111 L0075 std <D.Day update day/hour | |
112 clra 0 minutes | |
113 L0078 clrb 0 seconds | |
114 L0079 std <D.Min update min/sec | |
115 lda <D.TSec | |
116 sta <D.Tick | |
117 L007F clra | |
118 pshs a | |
119 ldy <D.CLTB | |
120 bra L009E | |
121 L0087 ldd ,x | |
122 subd #$0001 | |
123 bne L009C | |
124 lda #$01 | |
125 sta ,s | |
126 lda $04,x | |
127 beq L00B8 | |
128 L0096 ora #$01 | |
129 sta $04,x | |
130 ldd $02,x | |
131 L009C std ,x | |
132 L009E ldx ,y++ | |
133 bne L0087 | |
134 lda ,s+ | |
135 beq L00B4 | |
136 ldx <D.Proc | |
137 beq L00AE | |
138 tst P$State,x | |
139 bpl L00BC branch if sysstate not set | |
140 L00AE jsr [>D.Poll] | |
141 bcc L00AE | |
142 L00B4 jmp [>D.AltIRQ] | |
143 L00B8 bsr L00DD | |
144 bra L0096 | |
145 L00BC leay >L00C4,pcr | |
146 jmp [>D.URtoSs] | |
147 L00C4 jsr [>D.Poll] | |
148 bcc L00C4 | |
149 ldx <D.Proc | |
150 ldb P$State,x | |
151 andb #^SysState turn off sysstate bit | |
152 stb P$State,x | |
153 ldd <P$SWI2,x | |
154 std <D.SWI2 | |
155 ldd <D.UsrIRQ | |
156 std <D.SvcIRQ | |
157 bra L00B4 | |
158 L00DD pshs y,x | |
159 L00DF ldx ,y++ | |
160 stx -$04,y | |
161 bne L00DF | |
162 puls y,x | |
163 leay -2,y | |
164 rts | |
165 | |
87 | 166 FVIRQ pshs cc |
0 | 167 orcc #FIRQMask+IRQMask |
168 ldy <D.CLTB | |
169 ldx <D.Init | |
170 ldb PollCnt,x | |
171 ldx R$X,u | |
172 beq L0118 | |
173 tst ,y | |
174 beq L010C | |
175 subb #$02 | |
176 lslb | |
177 leay b,y | |
178 tst ,y | |
179 bne L0128 | |
180 L0106 tst ,--y | |
181 beq L0106 | |
182 leay $02,y | |
183 L010C ldx R$Y,u | |
184 stx ,y | |
185 ldy R$D,u | |
186 sty ,x | |
187 bra L0124 | |
188 L0118 leax R$Y,u | |
189 L011A tst ,y | |
190 beq L0124 | |
191 cmpx ,y++ | |
192 bne L011A | |
193 bsr L00DD | |
194 L0124 puls cc | |
195 clrb | |
196 rts | |
197 L0128 puls cc | |
198 comb | |
199 ldb #E$Poll | |
200 rts | |
201 | |
202 ClkEnt equ * | |
203 pshs dp,cc | |
204 clra | |
205 tfr a,dp | |
206 | |
62
0817702b8a2e
clock.asm now references TPS, defsfile references systype
boisy
parents:
0
diff
changeset
|
207 lda #TPS |
0 | 208 |
209 sta <D.TSec | |
210 sta <D.Tick | |
211 | |
62
0817702b8a2e
clock.asm now references TPS, defsfile references systype
boisy
parents:
0
diff
changeset
|
212 lda #TPS/10 |
0 | 213 |
214 sta <D.TSlice | |
215 sta <D.Slice | |
216 orcc #FIRQMask+IRQMask mask ints | |
217 leax >ClockIRQ,pcr | |
218 stx <D.IRQ | |
219 * install system calls | |
220 leay >SysTbl,pcr | |
221 os9 F$SSvc | |
222 ldx #PIA.U4 | |
223 clra | |
224 sta 1,x change PIA.U4 side A to DDR | |
225 sta ,x clear PIA.U4 side A | |
226 sta 3,x change PIA.U4 side B to DDR | |
227 coma complement A side A | |
228 sta 2,x write all 1's to PIA.U4 side B | |
229 lda #$34 | |
230 sta 1,x PIA.U4 side A to I/O reg | |
231 lda #$3F | |
232 sta 3,x PIA.U4 side B to I/O reg | |
233 lda 2,x | |
234 puls pc,dp,cc | |
235 | |
236 * F$Time system call code | |
237 FTime ldx R$X,u | |
238 ldd <D.Year | |
239 std ,x | |
240 ldd <D.Day | |
241 std 2,x | |
242 ldd <D.Min | |
243 std 4,x | |
244 clrb | |
245 rts | |
246 | |
247 emod | |
248 eom equ * | |
249 end |