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