1 /PDP-8A OPTION 1 (100 HZ) CLOCK ROUTINE................CLK8A
15 /DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
19 /THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY ON A
20 /SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH THE INCLU-
21 /SION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE,OR ANY OTHER
22 /COPIES THEREOF, MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE
23 /TO ANY OTHER PERSON EXCEPT FOR USE ON SUCH A SYSTEM AND TO ONE WHO
24 /AGREES TO THESE LICENSE TERMS. TITLE TO AND OWNERSHIP OF THE
25 /SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
28 /THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
29 /NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL
30 /EQUIPMENT CORPORATION.
33 /DEC ASSUMES NO RESPONSIBILITY FOR THE USEOR RELIABILITY OF ITS
34 /SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
53 / VERSION 5A 4/26/77 MH
63 EXTERN #DISP /SYSTEM PAGE 0,NEEDED TO
64 /PUT CLOCK STATUS ON PG0
65 /(CSTAT) FOR USE BY GEN
66 /USER CLOCK SERVICE ROUTS
67 EXTERN #T812 /RTS CPTYP
68 EXTERN ONQI /INTERRUPT QUEUER
69 CLLE= 6135 /AC11=1 INTRRUPTS ON.
70 CLCL= 6136 /CLEAR CLOCK FLAG
71 CLSK= 6137 /SKIP ON CLOCK FLAG.
72 CSTAT=157 /IDOCLK PUTS CLSA BITS
77 JSA SETUP /HERE TO READ A STRIG
79 TRAP4 DOSYNC /FCNWD (XR) HOLDS STRIG
82 FSTA% FTMP1 /GIVE ANS TO CALLER
84 FTMP0, F 0.0 /BASE PAGE
86 RPTR, 27;ADDR RTBL /PTR TO RATE TBL, ALSO
87 /USED TO FLT OVRCNT (NOTE
88 /THAT THE EXPONENT=27)
89 MINRAT, F .02 /MIN ALLOWABLE RATE
97 RTBL, F 16.0 /CONSTANT USED TO CHK FOR
99 /THIS CONST MUST BE NE 0
101 F4096, F 4096.0 /USED TO GET OVRFLO COUNT
102 F 100000.0 /FASTEST RATE IN HERTZ
103 F 10000.0 /NEXT FASTEST RATE
105 F 100.0 /SLOWEST RATE
106 F 1.0 /USED BY TIME FOR EXT CLK
109 SETUP, 0;0 /HERE TO INIT ALL FPP SUBS
111 FLDA 30 /PICK UP RTN TO CALLER
113 FLDA 0 /GET PTR TO CALLERS ARGS
114 SETX FCNWD /CLOCK XR AND BASE
119 FSTA FTMP0 /PTR TO 1ST ARG
121 FSTA FTMP1 /PTR TO 2ND ARG
122 FLDA #T812 /TELLS PDP8,PDP12
123 ATX CPTYP /0=8=DK8ES,1=12=KW12A
125 FLDA% FTMP0 /=1ST ARG
126 ATX FCNWD /ALWAYS IN FCNWD
129 CLOCK, JSA SETUP /HERE FOR CLOCK START
131 FSUB RTBL /FCNWD IS IN FAC,IF GE 16
132 JGE ITSEXT /(RTBL=16.0) THEN USER IS
133 /REQUESTING AN EXTERNAL
134 /CLOCK I.E. B8 OF FCNWD
136 FLDA% FTMP1 /=REQUESTED RATE IN HERTZ
137 FSUB MINRAT /.LE. MINUMUM RATE
138 JLE GOTR-2 /MEANS STOP CLOCK.
140 FSUB MAXRAT /CHK FOR TOO FAST
142 LDX -4,OVRFLO /THERE ARE 4 BASIC RATES
143 LDX 1,RATE /=INDEX INTO RTBL; UPON
144 /TRAP(CLOCK) RATE=(0,
147 /2-5=PROGRAMMABLE RATES
148 LOP0, FLDA% RPTR,RATE+
149 /GET NEXT SLOWEST RATE
150 FDIV% FTMP1 /=REQUESTED RATE IN HZ.
152 FSUB F4096 /MUST BE MODULO 12 BITS.
155 LDX 0,RATE /RATE IS TOO SLOW, STOP
157 GOTR, FADD F4096 /RESTORE
159 ATX OVRFLO /OVER FLOW COUNT
160 TRAP4 SETCLK /GO START CLOCK
161 JA GOBAK /RTN TO CALLER
162 ITSEXT, LDX 6,RATE /=RATE FOR EXT CLK
163 FLDA% FTMP1 /REQUESTED RATE IS
164 /INTERPRETED AS OVRFLO
165 JA GOTR+1 /WHEN RATE IS EXTERNAL
166 \f/MAGIC TABLE USED BY SETCLK TO SET CLOCK ENABLE
167 /BITS. EVEN NUMBERED ENTRIES ARE FOR THE DK8ES;
168 /ODD NUMBERED ONES ARE FOR THE KW12A.
170 CLKTBL, 0675 /"STANDARD" DK BITS
178 40 /DK ADC ON OVR BIT
179 400 /KW ADC ON OVR BIT
181 /IF NOT NEXT PAGE DO ORG
182 IFNEG .-200 < ORG .-SYNC&7600+200+SYNC >
183 \fSETCLK, 0 /TRAP HERE TO START CLK
184 /THIS ROUT HANDLES BOTH
186 CLCL /TRY AND CLEAR IT HERE????
187 / CLLR /STOP KW AND SET MODE 0;
189 / CLEN /CLR KW12 ENABLE OR
192 / TAD P7540 /TOGGLE KW MODE 0 TO 1 TO
193 / CLLR /CLR CLK COUNTER, OR SET
194 /DK ENABLE BITS, RATE FOR
195 / CLA CMA /BOTH NOW=7=STOP.
196 / CLZE /CLR ALL DK ENABLE BITS,
197 / CLSA /CLR STATUS OF BOTH, ALL
199 TAD FCNTBL+1 /SET PTR TO CLKTBL FOR
200 /SETTING OF ENABLE REGS.
201 TAD CPTYP /=0 IF PDP8 =1 IF PDP12
202 DCA FCNPTR /TBL ENTRIES ALTERNATE
203 /FOR 8 AND 12. CPTYP SETS
204 /PTR TO 1ST 8 OR 1ST 12
206 TAD IDOCLK /(AC=JMP AROUND). THE
207 /FOLLOWING IS ONCE ONLY
208 /CODE. THESE LOCS ARE
209 /SUBSEQUENTLY USED AS
212 /THE TAG "ISVBIT" MUST BE
213 /IN FRONT OF THE STRIG
214 /FLAGS (STFLG) TO COVER
216 /STRIG 0 IN A FORT CALL
218 ISVBIT, TAD CPTYP /(AC=0,1) MAKE THE INST
219 /RAR CLL (FOR DK) OR THE
220 /INST RTR CLL FOR IDOCLK;
221 STFLG, RAL CLL /BECAUSE STATUS BITS FOR
222 TAD RARCLL /STRIGS DIFFER ON DK,KW.
223 DCA LOP2+1 /SEE SUB IDOCLK.
224 /THE ABOVE 3 LOCS ARE
225 /SCHMITT TRIGGER FLAGS.
226 /THE ORDER IS S1,S2,S3
227 /FOR PDP8 AND S3,S2,S1
228 /FOR PDP12. (CHK THE STATUS
229 /BITS FOR DK AND KW).
230 JMS% KONQI+1 /PUT CLOCK ON THE
231 ITMP0, CLSK /INTERRUPT QUE
233 CLENAB, ADDR IDOCLK /THIS LOC WILL HOLD THE
234 /ENABLE BITS FOR DK,KW
235 AROUND, TAD RATE /(AC=0,2,3,4,5,6) RATE IS
237 RTR CLL /START TO POSITION RATE
238 RAR /BITS. B3-B5 FOR DK
240 TAD CPTYP /(THIS IS TRICKY) NEED
241 RAR /CPTYP IN LNK BECAUSE
242 /POSITION OF RATE BITS
244 TAD% FCNPTR /AC="STANDARD"
245 /ENABLE BITS FOR DK,KW.
246 SZL /IF ITS A KW THE RATE AND
247 /AND STND BITS ARE ALREADY
248 /POSITIONED AS FOLLOWS:
250 /B0-B3 AND B5 WILL GO TO
251 /KW CONTROL. B4,B5 WILL
252 /GO TO ENABLE. B3 IS ADC
253 /ON OVRFLO AND MAY BE SET
254 /BELOW. B5 ON CONTROL IS
255 /MODE 1. B4 AND B5 ON
256 /ENABLE ARE BUFF PRESET TO
257 /CLOCK COUNTER AND INTRUPT
258 /ON OVRFLO RESPECTIVELY.
259 JMP NOBIT-1 /ITS KW GO PUT IN CLENAB.
260 RTR /ITS DK; POSITION RATE TO
261 RAR /B3-B5. NOTE THAT THE LNK
262 /(CPTYP=0) IS BEING USED.
263 CMA /NOTE ALSO THAT THE RATE
264 /AND STND BITS ARE THE 1S
265 /COMP. OF WHAT THEY SHOULD
269 /PRESET TO CLK CNTR ON
270 /OVERFLO. LOOK AT THE RATE
271 /BITS IN THE HANDBOOK FOR
273 /FOR DK IS 100HZ, 100KHZ
274 /RESPECTIVELY. R2,R5 FOR
278 /THE FINAL VALUE OF THE
279 /STND DK ENABLE BITS (1ST
280 /ENTRY IN CLKTBL) IS LEFT
281 /AS AN EXERCISE FOR THE
283 JMP NOBIT-1 /GO PUT IN CLENAB
284 LOP1, RAR CLL /ROT 1 FCN BIT INTO LNK.
286 /IGNORED HERE. B8=ADC ON
287 /OVRFLO, B9-B11 ARE STRIG3
288 /-STRIG1 RESP. BX=1=ENABLE
290 DCA FCNWD /PUT IT BACK (FCNWD IS
294 TAD% FCNPTR /GET BITS FROM THE MAGIC
296 DCA CLENAB /UPDATE ENABLE WORD.
297 NOBIT, ISZ FCNPTR /ADV TO NEXT
298 ISZ FCNPTR /TBL ENTRY.
299 TAD FCNWD /WHEN FCNWD GOES TO 0
300 AND P17 /WE ARE ALL DONE.
301 /THE "AND" IS DONE TO
302 /PROTECT AGAINST A BAD
303 /ARG FROM THE FORT CALL.
304 P7540, SMA SZA /SMA IS SUPERFLOUS TO
306 /CREATES A NICE CONST.
308 DCA STFLG /CLR THE SCHMITT
309 \f DCA STFLG+1 /TRIGGER FLAGS.
311 TAD OVRFLO /SET BUFF PRESET
312 CIA /(FPP SET THIS ARG)
315 TAD CLENAB /THIS IS FOR KW ONLY.
316 AND P377 /AC=3XX. 3= OR BUFF PRE
317 /INTO CLK CNTR AND ENAB
320 / CLEN /SET KW ENABLE OR
322 DCA OVRCNT+1 /CLR NUM OF CLK OVRFLOS
323 DCA OVRCNT /SINCE TIME 0.
324 TAD CPTYP /NEED TYPE IN ORDER TO
325 RARCLL, RAR CLL /ISOLATE CONTROL
328 AND P7540 /YES, B0-B2 IS RATE,
329 /B3 IS ADC, B5 IS BUFF
331 /OVRFLO, B6 IS MOX NIX.
332 /IF DK ALL BITS MAY HAVE
335 CLLE /ENABLE THE CLOCK INTERRUPTS
336 / CLLR /START THE CLOCK
339 JMP% SETCLK /RTN TO RTS
340 \fDOSYNC, 0 /HERE TO DISPOSITION A
342 TAD CPTYP /DK AND KW FLAGS ARE IN
343 RAR CLL /REVERSE ORDER. IF DK
344 /ARG IS OK; IF KW THEN
345 /MUST SET 1=3, 2=2, 3=1
348 TAD FCNWD /=REQUESTED STRIG=1,2,3
352 AND P3 /IE 1 GOES TO -1 GOES
353 /TO 3 ETC. "AND" ALSO
354 /INSURES RANGE IS 0-3.
355 /IF ARG IS 0 RESULT IS
357 TAD KSTFLG+1 /GET PTR TO FLAG
359 TAD% SETCLK /FLAG=0 IF TRIG HAS NOT
360 /TRIPPED SINCE THE LAST
362 /OTHERWISE IE RTN 0=FALSE
363 DCA FCNWD /,1=TRUE (FPP WILL PICK
365 DCA% SETCLK /CLR FLAG ANYWAY
367 JMP% DOSYNC /RTN TO RTS
368 \fIDOCLK, JMP AROUND /HERE ON CLOCK INTERRUPT
369 /(JMP AROUND IS A ONCE
371 CLCL /JUST TO MAKE SURE!
372 TAD KSTFLG+1 /SET PTR TO STRIG FLAGS.
374 / CLSA /GET CLOCK BITS.
375 CLA CLL CML RAR /SIMULATE TICK
376 DCAZ CSTAT /SAVE THEM FOR SOME
377 TADZ CSTAT /BODY ELSE.
379 ISZ OVRCNT+1 /YES BUMP LO ORD CNTR
381 ISZ OVRCNT /BUMP HI ORD
382 JMP DOTRIG /(HI ORD ISZ SKP IS
384 LOP2, ISZ ITMP0 /ADV STRIG FLAG PTR.
385 RAR CLL /(OR RTR CLL IF KW)
386 /IE PUT STRIG BIT IN LNK.
388 /INTERROGATION IS S1,S2,S3
389 /IF KW THE ORDER IS S3,
390 /S2,S1. THE STATUS BITS
391 /FOR DK ARE ADJACENT IE
392 / B9(S3),B10(S2),B11(S1)
393 /FOR KW ITS EVERY OTHER,
394 /B6(S1),B8(S2),B10(S3).
395 DCA ISVBIT /SAVE WHATS LEFT.
396 RAL /COPY LNK INTO FLAG IF=1
397 SZA /IE DONT CLR FLAG WHEN
400 DOTRIG, AND P377 /THE "AND" INSURES THAT
402 /CLRED SO THAT ISVBIT
406 /CLR OVRFLO BIT FOR DK,KW
407 /AND CLR PRE-EVENT BIT
411 TAD #CLINT /CALL USER EXTENDED
412 SZA CLA /CLOCK ROUT ?
414 JMP% IDOCLK /RTN TO IHANDL
430 ENTRY TIME /FIGURE WHAT TIME IT IS
432 FLDA RPTR /=27;X;X IS USED TO FLOAT
434 FLDA# OVRCNT /NUM OF CLK OVRFLOS SINCE
437 FMUL TOVR /=NUM OF BASIC TICKS PER
439 /FAC=NUM OF TICKS SINCE
441 FDIV% RPTR,RATE /DIV BY BASIC RATE IN HZ
442 /OR 1 IF EXTERNAL CLK.
443 FSTA% FTMP0 /GIVE ANS TO CALLER, ALSO
446 /CALL. ANS=ELAPSED TIME IN
447 /SECONDS SINCE TIME 0 OR
448 /NUM OF EXTERNAL UNIT