A large commit.
[pdp8.git] / sw / dumprest / hachti_std / RESTR0.PA
1 / RK05 RESTORE Program
2 / This program will receive a RK05 image and write it to the disk. The
3 / entire disk it written, with each sector having a reread check.
4 /
5 / This program should be started before the program (PC) sending the data
6 /
7 / See dump for the format of the serial data.
8 / To run start at 0200.
9 / SR 9-11 should be drive
10 / Should halt at HLT at label GDHLT (140) with AC = 0 if it worked.
11 / Hit cont to display in AC number of recoverable errors
12 / At normal exit hitting cont again will restart the program
13 /
14 / The current location being written to will be displayed in the AC
15 / while running. It is (cylinder * 16 + sector) / 2
16
17 DSKP=6741
18 DCLR=6742
19 DLAG=6743
20 DLCA=6744
21 DRST=6745
22 DLDC=6746
23
24 INAD=400 / Address of serial input, 30 for console
25 KCF2=6000 INAD
26 KSF2=6001 INAD
27 KCC2=6002 INAD
28 KRS2=6004 INAD
29 KIE2=6005 INAD
30 KRB2=6006 INAD
31
32 OUTAD=410 / Address of serial output, 40 for console
33 TFL2=6000 OUTAD
34 TSF2=6001 OUTAD
35 TCF2=6002 OUTAD
36 TPC2=6004 OUTAD
37 TSK2=6005 OUTAD
38 TLS2=6006 OUTAD
39
40 *20
41 ERRCNT, 7760 / Stop when err count = 0, init at startup
42 DRIVE, 0 / Drive # * 2
43 K0200, 0200
44 K4000, 4000
45 FLD, 10 / Use field 1 for data buffer
46 TRACK, 0
47 MAXTRK, 4537
48 EXBIT, 0
49 WRTDAT, 4000
50 REDDAT, 0000
51 WRTLOC, 0000 / Address to write data to disk
52 BUFLOC, 0000 / Address to store next word received
53 NUMSEC, 0 / Number of sectors received but not written
54 RDBUF, 1000 / Buffer for reread check
55 DSPTRK, 0
56 LOC, 0
57 LEN, 0
58 K6, 6
59 K17, 17
60 K377, 377
61 K7400, 7400
62 KN1, 7777
63 CHKSUM, 0
64 TEMP, 0
65 LAST, 0
66 DONEFG, 0 / 1 when end of data flag received
67 STATE, 0 / Where in serial data we are 0 = Need ff sector head,
68 / -1 = byte1, ... -3 = byte 3
69 BUFCNT, 0 / Count of words received in sector
70 ISRAC, 0
71 ISRFLG, 0
72 RISR, ISR
73 DECIMAL
74 NBLKSZ, -256
75 OCTAL
76 WRITEF, WRITE
77 RECALF, RECAL
78 STARTF, START
79
80 *1000
81 1234
82 4321
83
84 *1
85 JMP I RISR / Interrupt handler
86
87 *140
88 GDHLT, / HLT / Stop with sum of all words (including -checksum)
89 FINISH,
90 JMP I XFINI
91 XFINI, FINI
92
93 / HLT / Normal good halt
94 / JMP START / And restart if requested
95
96 / REBOOT FROM RK05
97 BO1, 6743
98 BO2, JMP 31
99 / Should be 0
100 / CLA
101 / TAD K17
102 / TAD ERRCNT
103 / HLT / # of errors
104 JMP I STARTF
105
106 *200
107 START, CDF 0 / Init all our variables
108 CAF
109 / CLA CLL OSR / Init variables changed during run
110 / RAL
111 / AND K6 / Clear out high bits such as 0200 start address
112 / DCA DRIVE
113 CLA / PHPH
114 DCA TRACK
115 DCA EXBIT
116 DCA CHKSUM
117 DCA STATE
118 DCA WRTLOC
119 DCA BUFLOC
120 DCA NUMSEC
121 DCA DONEFG
122 TAD K17
123 CIA
124 DCA ERRCNT
125 ION / Turn on serial interrupt handler
126 CLA CLL IAC / Set bit 11 to enable interrupts
127 KIE2
128 KRB2
129 / RPE / PTR Testing, use paper tape with emulator
130 / RFC
131 RECAL, CLA CLL IAC / Recal drive, clear errors and set to cyl 0
132 DCLR / From manual
133 TAD DRIVE
134 DLDC
135 CLA CLL CML RTL
136 DCLR
137 DSKP
138 JMP .-1
139 TAD K0200
140 TAD DRIVE
141 DLDC
142 DSKP
143 JMP .-1
144 DRST
145 CIA
146 TAD K4000
147 SZA CLA
148 JMP BADSTA
149 JMP I WRITEF
150 BADSTA, HLT
151
152 PAGE
153 WRITE, CLA CLL
154 TAD EXBIT
155 RAR
156 TAD TRACK
157 RAR
158 DCA DSPTRK / Save track for display
159 CDAT, CLA
160 TAD DSPTRK / Display write location
161 AND DSPTRK / Kill time to make brighter
162 AND DSPTRK
163 AND DSPTRK
164 IOF / Turn off interrupts so we can safely update
165 CLA / # of sectors in buffer
166 TAD NUMSEC
167 SNA
168 JMP NODAT
169 TAD KN1
170 DCA NUMSEC
171 IAC / 1 flags sector to write
172 NODAT, ION
173 SZA
174 JMP DOWRT / Got data write it
175 TAD DONEFG / No more data flag?
176 SNA
177 JMP CDAT / No, try again
178 JMP DONE / yes
179 DOWRT, CLA CLL IAC / We have one waiting, write it
180 DCLR
181 TAD WRTLOC
182 DLCA
183 TAD DRIVE
184 TAD WRTDAT
185 TAD FLD
186 TAD EXBIT
187 DLDC
188 TAD TRACK
189 DLAG
190 CLL
191 TAD DSPTRK
192 DSKP
193 JMP .-1
194 DRST
195 CIA
196 TAD K4000
197 SZA CLA
198 JMP ERROR
199 RDCHK, CLA CLL IAC / And now reread sector
200 DCLR
201 TAD RDBUF
202 DLCA
203 TAD DRIVE
204 TAD REDDAT
205 TAD EXBIT
206 DLDC
207 TAD TRACK
208 DLAG
209 CLA CLL
210 TAD DSPTRK
211 DSKP
212 JMP .-1
213 DRST
214 CIA
215 TAD K4000
216 SZA CLA
217 JMP ERROR
218 TAD RDBUF
219 DCA LOC
220 TAD NBLKSZ
221 DCA LEN
222 CHKDAT, CDF 10 / And now compare
223 TAD I WRTLOC
224 CIA
225 CDF 0
226 TAD I LOC
227 SZA
228 HLT / Big trouble, sector is bad without CRC error
229 ISZ WRTLOC
230 ISZ LOC
231 ISZ LEN
232 JMP CHKDAT
233 CLA CLL
234 INCTRK, ISZ TRACK / Increment track and exbit value for next sector
235 JMP WRITE
236 ISZ EXBIT
237 JMP WRITE
238 HLT
239 DONE, CLA CLL CMA / Done, wait for one more word
240 TAD BUFLOC
241 AND K17
242 SZA
243 JMP DONE
244 TAD CHKSUM / Get final checksum, receive has added checksum
245 SZA / word to running sum, Halt here if checksum
246 HLT / is not zero.
247 JMP GDHLT
248
249 ERROR, ISZ ERRCNT / To many errors?
250 JMP I RECALF / No, recal drive and try again
251 DRST / Yes, leave error in AC and halt
252 HLT
253
254 PAGE
255 ISR,
256 DCA ISRAC / Save AC
257 GTF
258 DCA ISRFLG / And flags
259 CDF 10 / Buffer in field 1
260 / RSF / PTR
261 KSF2 / Have character waiting
262 HLT / Stop, not our interrupt
263 / JMP IRET / No, not our interrupt
264 CLA
265 / RRB RFC / PTR
266 KRB2 / Get character
267 DCA TEMP
268 TAD STATE / Find out where in sequence we are
269 SNA
270 JMP SBLK / Start of block
271 IAC
272 SNA
273 JMP BYTE1
274 IAC
275 SNA
276 JMP BYTE2
277 CLA / Byte 3
278 TAD TEMP
279 CLL
280 RTL
281 RTL
282 TAD LAST
283 DCA I BUFLOC
284 TAD CHKSUM
285 TAD I BUFLOC
286 DCA CHKSUM
287 TAD BUFLOC
288 IAC
289 DCA BUFLOC
290 STA / -1 for byte 1
291 DCA STATE
292 ISZ BUFCNT
293 JMP IRET
294 DCA STATE / End of sector, set to 0 to check header byte
295 ISZ NUMSEC / Inc number of sectors buffered
296 TAD K17
297 CIA
298 TAD NUMSEC
299 SNA
300 HLT / To many buffered, halt. Must of had to many
301 / retries in a row
302 IRET, CLA
303 TAD ISRFLG
304 RTF
305 CLA
306 TAD ISRAC
307 JMP I 0
308 BYTE2, CLA
309 TAD TEMP
310 RTL
311 RTL
312 RTL
313 RTL
314 AND K7400
315 TAD LAST
316 DCA I BUFLOC
317 TAD CHKSUM
318 TAD I BUFLOC
319 DCA CHKSUM
320 ISZ BUFLOC
321 ISZ BUFCNT
322 TAD TEMP
323 RTR
324 RTR
325 AND K17
326 DCA LAST
327 CMA
328 TAD STATE
329 DCA STATE
330 JMP IRET
331 BYTE1, CLA
332 TAD TEMP
333 DCA LAST
334 CMA
335 TAD STATE
336 DCA STATE
337 JMP IRET
338 SBLK, TAD K377
339 CIA
340 TAD TEMP / Is is a ff?
341 SNA
342 JMP FLAGOK / Yes
343 IAC / Is it a fe?
344 SZA
345 HLT / No, halt
346 IAC
347 DCA DONEFG
348 FLAGOK, STA / -1 for byte 1
349 DCA STATE
350 TAD NBLKSZ / And setup to look for 256 words
351 DCA BUFCNT
352 JMP IRET
353
354 / OLD ROUTINE, COLD RK05 REBOOT
355 OFINI, CLA
356 TAD BO1
357 DCA 30
358 TAD BO2
359 DCA 31
360 CAF
361 JMP 30
362
363 *7600
364 FINI,
365 HLT
366 JMP I K200
367 K200, 200
368
369
370 $