Commit | Line | Data |
---|---|---|
fb6c0fb7 KT |
1 | #define CHAR 01 |
2 | #define BLOCK 02 | |
3 | #define INTR 04 | |
4 | #define EVEN 010 | |
5 | #define KL 020 | |
6 | int tabp[20]; | |
7 | int tabpp; | |
8 | struct tab | |
9 | { | |
10 | char *name; | |
11 | int count; | |
12 | int address; | |
13 | int key; | |
14 | char *codea; | |
15 | char *codeb; | |
16 | char *codec; | |
17 | char *coded; | |
18 | char *codee; | |
19 | } table[] | |
20 | { | |
21 | "console", | |
22 | -1, 60, CHAR+INTR+KL, | |
23 | "\tklin; br4\n\tklou; br4\n", | |
24 | ".globl\t_klrint\nklin:\tjsr\tr0,call; _klrint\n", | |
25 | ".globl\t_klxint\nklou:\tjsr\tr0,call; _klxint\n", | |
26 | "", | |
27 | "\t&klopen, &klclose, &klread, &klwrite, &klsgtty,", | |
28 | "mem", | |
29 | -1, 300, CHAR, | |
30 | "", | |
31 | "", | |
32 | "", | |
33 | "", | |
34 | "\t&nulldev, &nulldev, &mmread, &mmwrite, &nodev,", | |
35 | ||
36 | ||
37 | "pc", | |
38 | 0, 70, CHAR+INTR, | |
39 | "\tpcin; br4\n\tpcou; br4\n", | |
40 | ".globl\t_pcrint\npcin:\tjsr\tr0,call; _pcrint\n", | |
41 | ".globl\t_pcpint\npcou:\tjsr\tr0,call; _pcpint\n", | |
42 | "", | |
43 | "\t&pcopen, &pcclose, &pcread, &pcwrite, &nodev,", | |
44 | ||
45 | "clock", | |
46 | -2, 100, INTR, | |
47 | "\tkwlp; br6\n", | |
48 | ".globl\t_clock\n", | |
49 | "kwlp:\tjsr\tr0,call; _clock\n", | |
50 | "", | |
51 | "", | |
52 | ||
53 | /* | |
54 | * 110 unused | |
55 | * 114 memory parity | |
56 | * 120 XY plotter | |
57 | * 124 DR11-B | |
58 | * 130 AD01 | |
59 | * 134 AFC11 | |
60 | * 140 AA11 | |
61 | * 144 AA11 | |
62 | * 150-174 unused | |
63 | */ | |
64 | ||
65 | "lp", | |
66 | 0, 200, CHAR+INTR, | |
67 | "\tlpou; br4\n", | |
68 | "", | |
69 | ".globl\t_lpint\nlpou:\tjsr\tr0,call; _lpint\n", | |
70 | "", | |
71 | "\t&lpopen, &lpclose, &nodev, &lpwrite, &nodev,", | |
72 | ||
73 | "rf", | |
74 | 0, 204, BLOCK+CHAR+INTR, | |
75 | "\trfio; br5\n", | |
76 | ".globl\t_rfintr\n", | |
77 | "rfio:\tjsr\tr0,call; _rfintr\n", | |
78 | "\t&nulldev,\t&nulldev,\t&rfstrategy, \t&rftab,", | |
79 | "\t&nulldev, &nulldev, &rfread, &rfwrite, &nodev,", | |
80 | ||
81 | /* | |
82 | * 210 RC | |
83 | */ | |
84 | ||
85 | "tc", | |
86 | 0, 214, BLOCK+INTR, | |
87 | "\ttcio; br6\n", | |
88 | ".globl\t_tcintr\n", | |
89 | "tcio:\tjsr\tr0,call; _tcintr\n", | |
90 | "\t&nulldev,\t&tcclose,\t&tcstrategy, \t&tctab,", | |
91 | "", | |
92 | ||
93 | "rk", | |
94 | 0, 220, BLOCK+CHAR+INTR, | |
95 | "\trkio; br5\n", | |
96 | ".globl\t_rkintr\n", | |
97 | "rkio:\tjsr\tr0,call; _rkintr\n", | |
98 | "\t&nulldev,\t&nulldev,\t&rkstrategy, \t&rktab,", | |
99 | "\t&nulldev, &nulldev, &rkread, &rkwrite, &nodev,", | |
100 | ||
101 | "tm", | |
102 | 0, 224, BLOCK+CHAR+INTR, | |
103 | "\ttmio; br5\n", | |
104 | ".globl\t_tmintr\n", | |
105 | "tmio:\tjsr\tr0,call; _tmintr\n", | |
106 | "\t&tmopen,\t&tmclose,\t&tmstrategy, \t&tmtab,", | |
107 | "\t&tmopen, &tmclose, &tmread, &tmwrite, &nodev,", | |
108 | ||
109 | "cr", | |
110 | 0, 230, CHAR+INTR, | |
111 | "\tcrin; br6\n", | |
112 | "", | |
113 | ".globl\t_crint\ncrin:\tjsr\tr0,call; _crint\n", | |
114 | "", | |
115 | "\t&cropen, &crclose, &crread, &nodev, &nodev,", | |
116 | ||
117 | /* | |
118 | * 234 UDC11 | |
119 | */ | |
120 | ||
121 | "rp", | |
122 | 0, 254, BLOCK+CHAR+INTR, | |
123 | "\trpio; br5\n", | |
124 | ".globl\t_rpintr\n", | |
125 | "rpio:\tjsr\tr0,call; _rpintr\n", | |
126 | "\t&nulldev,\t&nulldev,\t&rpstrategy, \t&rptab,", | |
127 | "\t&nulldev, &nulldev, &rpread, &rpwrite, &nodev,", | |
128 | ||
129 | /* | |
130 | * 260 TA11 | |
131 | * 264-274 unused | |
132 | */ | |
133 | ||
134 | "dc", | |
135 | 0, 308, CHAR+INTR, | |
136 | "\tdcin; br5+%d.\n\tdcou; br5+%d.\n", | |
137 | ".globl\t_dcrint\ndcin:\tjsr\tr0,call; _dcrint\n", | |
138 | ".globl\t_dcxint\ndcou:\tjsr\tr0,call; _dcxint\n", | |
139 | "", | |
140 | "\t&dcopen, &dcclose, &dcread, &dcwrite, &dcsgtty,", | |
141 | ||
142 | "kl", | |
143 | 0, 308, INTR+KL, | |
144 | "\tklin; br4+%d.\n\tklou; br4+%d.\n", | |
145 | "", | |
146 | "", | |
147 | "", | |
148 | "", | |
149 | ||
150 | "dp", | |
151 | 0, 308, CHAR+INTR, | |
152 | "\tdpin; br6+%d.\n\tdpou; br6+%d.\n", | |
153 | ".globl\t_dprint\ndpin:\tjsr\tr0,call; _dprint\n", | |
154 | ".globl\t_dpxint\ndpou:\tjsr\tr0,call; _dpxint\n", | |
155 | "", | |
156 | "\t&dpopen, &dpclose, &dpread, &dpwrite, &nodev,", | |
157 | ||
158 | /* | |
159 | * DM11-A | |
160 | */ | |
161 | ||
162 | "dn", | |
163 | 0, 304, CHAR+INTR, | |
164 | "\tdnou; br5+%d.\n", | |
165 | "", | |
166 | ".globl\t_dnint\ndnou:\tjsr\tr0,call; _dnint\n", | |
167 | "", | |
168 | "\t&dnopen, &dnclose, &nodev, &dnwrite, &nodev,", | |
169 | ||
170 | "dhdm", | |
171 | 0, 304, INTR, | |
172 | "\tdmin; br4+%d.\n", | |
173 | "", | |
174 | ".globl\t_dmint\ndmin:\tjsr\tr0,call; _dmint\n", | |
175 | "", | |
176 | "", | |
177 | ||
178 | /* | |
179 | * DR11-A+ | |
180 | * DR11-C+ | |
181 | * PA611+ | |
182 | * PA611+ | |
183 | * DT11+ | |
184 | * DX11+ | |
185 | */ | |
186 | ||
187 | "dl", | |
188 | 0, 308, INTR+KL, | |
189 | "\tklin; br4+%d.\n\tklou; br4+%d.\n", | |
190 | "", | |
191 | "", | |
192 | "", | |
193 | "", | |
194 | ||
195 | /* | |
196 | * DJ11 | |
197 | */ | |
198 | ||
199 | "dh", | |
200 | 0, 308, CHAR+INTR+EVEN, | |
201 | "\tdhin; br5+%d.\n\tdhou; br5+%d.\n", | |
202 | ".globl\t_dhrint\ndhin:\tjsr\tr0,call; _dhrint\n", | |
203 | ".globl\t_dhxint\ndhou:\tjsr\tr0,call; _dhxint\n", | |
204 | "", | |
205 | "\t&dhopen, &dhclose, &dhread, &dhwrite, &dhsgtty,", | |
206 | ||
207 | /* | |
208 | * GT40 | |
209 | * LPS+ | |
210 | * VT20 | |
211 | */ | |
212 | ||
213 | 0 | |
214 | }; | |
215 | ||
216 | char *stra[] | |
217 | { | |
218 | "/ Copyright 1974 Bell Telephone Laboratories Inc", | |
219 | "/ low core", | |
220 | "", | |
221 | "br4 = 200", | |
222 | "br5 = 240", | |
223 | "br6 = 300", | |
224 | "br7 = 340", | |
225 | "", | |
226 | ". = 0^.", | |
227 | "\tbr\t1f", | |
228 | "\t4", | |
229 | "", | |
230 | "/ trap vectors", | |
231 | "\ttrap; br7+0.\t\t/ bus error", | |
232 | "\ttrap; br7+1.\t\t/ illegal instruction", | |
233 | "\ttrap; br7+2.\t\t/ bpt-trace trap", | |
234 | "\ttrap; br7+3.\t\t/ iot trap", | |
235 | "\ttrap; br7+4.\t\t/ power fail", | |
236 | "\ttrap; br7+5.\t\t/ emulator trap", | |
237 | "\ttrap; br7+6.\t\t/ system entry", | |
238 | "", | |
239 | ". = 40^.", | |
240 | ".globl\tstart, dump", | |
241 | "1:\tjmp\tstart", | |
242 | "\tjmp\tdump", | |
243 | "", | |
244 | 0, | |
245 | }; | |
246 | ||
247 | char *strb[] | |
248 | { | |
249 | "", | |
250 | ". = 240^.", | |
251 | "\ttrap; br7+7.\t\t/ programmed interrupt", | |
252 | "\ttrap; br7+8.\t\t/ floating point", | |
253 | "\ttrap; br7+9.\t\t/ segmentation violation", | |
254 | 0 | |
255 | }; | |
256 | ||
257 | char *strc[] | |
258 | { | |
259 | "", | |
260 | "/ floating vectors", | |
261 | ". = 300^.", | |
262 | 0, | |
263 | }; | |
264 | ||
265 | char *strd[] | |
266 | { | |
267 | "", | |
268 | "//////////////////////////////////////////////////////", | |
269 | "/\t\tinterface code to C", | |
270 | "//////////////////////////////////////////////////////", | |
271 | "", | |
272 | ".globl\tcall, trap", | |
273 | 0 | |
274 | }; | |
275 | ||
276 | char *stre[] | |
277 | { | |
278 | "/*", | |
279 | " *\tCopyright 1974 Bell Telephone Laboratories Inc", | |
280 | " */", | |
281 | "", | |
282 | "int\t(*bdevsw[])()", | |
283 | "{", | |
284 | 0, | |
285 | }; | |
286 | ||
287 | char *strf[] | |
288 | { | |
289 | "\t0", | |
290 | "};", | |
291 | "", | |
292 | "int\t(*cdevsw[])()", | |
293 | "{", | |
294 | 0, | |
295 | }; | |
296 | ||
297 | char *strg[] | |
298 | { | |
299 | "\t0", | |
300 | "};", | |
301 | "", | |
302 | "int\trootdev\t{(0<<8)|0};", | |
303 | "int\tswapdev\t{(0<<8)|0};", | |
304 | "int\tswplo\t4000;", | |
305 | "int\tnswap\t872;", | |
306 | 0, | |
307 | }; | |
308 | ||
309 | int fout; | |
310 | ||
311 | main() | |
312 | { | |
313 | register struct tab *p; | |
314 | int i, n, ev, nkl; | |
315 | int flagf, flagb; | |
316 | ||
317 | tabp[tabpp++] = table; | |
318 | tabp[tabpp++] = table+1; | |
319 | while(input()); | |
320 | ||
321 | /* | |
322 | * pass1 -- create interrupt vectors | |
323 | */ | |
324 | nkl = 0; | |
325 | flagf = flagb = 1; | |
326 | fout = creat("l.s", 0666); | |
327 | puke(stra); | |
328 | for(p=table; p->name; p++) | |
329 | if(p->count != 0 && p->key & INTR) { | |
330 | if(p->address>240 && flagb) { | |
331 | flagb = 0; | |
332 | puke(strb); | |
333 | } | |
334 | if(p->address >= 300) { | |
335 | if(flagf) { | |
336 | ev = 0; | |
337 | flagf = 0; | |
338 | puke(strc); | |
339 | } | |
340 | if(p->key & EVEN && ev & 07) { | |
341 | printf("\t.=.+4\n"); | |
342 | ev =+ 4; | |
343 | } | |
344 | ev =+ p->address - 300; | |
345 | } else | |
346 | printf("\n. = %d^.\n", p->address); | |
347 | n = p->count; | |
348 | if(n < 0) | |
349 | n = -n; | |
350 | for(i=0; i<n; i++) | |
351 | if(p->key & KL) { | |
352 | printf(p->codea, nkl, nkl); | |
353 | nkl++; | |
354 | } else | |
355 | printf(p->codea, i, i); | |
356 | } | |
357 | if(flagb) | |
358 | puke(strb); | |
359 | puke(strd); | |
360 | for(p=table; p->name; p++) | |
361 | if(p->count != 0 && p->key & INTR) | |
362 | printf("\n%s%s", p->codeb, p->codec); | |
363 | flush(); | |
364 | close(fout); | |
365 | ||
366 | /* | |
367 | * pass 2 -- create configuration table | |
368 | */ | |
369 | ||
370 | fout = creat("c.c", 0666); | |
371 | puke(stre); | |
372 | for(i=0; p=tabp[i]; i++) | |
373 | if(p->key & BLOCK) | |
374 | printf("%s\n", p->coded); | |
375 | puke(strf); | |
376 | for(i=0; p=tabp[i]; i++) | |
377 | if(p->key & CHAR) | |
378 | printf("%s\n", p->codee); | |
379 | puke(strg); | |
380 | flush(); | |
381 | close(fout); | |
382 | } | |
383 | ||
384 | puke(s) | |
385 | char **s; | |
386 | { | |
387 | char *c; | |
388 | ||
389 | while(c = *s++) | |
390 | printf("%s\n", c); | |
391 | } | |
392 | ||
393 | input() | |
394 | { | |
395 | char line[100]; | |
396 | register char *p; | |
397 | register struct tab *q; | |
398 | register n; | |
399 | ||
400 | p = line; | |
401 | while((n=getchar()) != '\n') { | |
402 | if(n == 0) | |
403 | return(0); | |
404 | if(n == ' ' || n == '\t') | |
405 | continue; | |
406 | *p++ = n; | |
407 | } | |
408 | *p++ = 0; | |
409 | n = 0; | |
410 | p = line; | |
411 | while(*p>='0' && *p<='9') { | |
412 | n =* 10; | |
413 | n =+ *p++ - '0'; | |
414 | } | |
415 | if(n == 0) | |
416 | n = 1; | |
417 | if(*p == 0) | |
418 | return(1); | |
419 | for(q=table; q->name; q++) | |
420 | if(equal(q->name, p)) { | |
421 | if(q->count < 0) { | |
422 | printf("%s: no more, no less\n", p); | |
423 | return(1); | |
424 | } | |
425 | q->count =+ n; | |
426 | if(q->address < 300 && q->count > 1) { | |
427 | q->count = 1; | |
428 | printf("%s: only one\n", p); | |
429 | } | |
430 | tabp[tabpp++] = q; | |
431 | return(1); | |
432 | } | |
433 | printf("%s: cannot find\n", p); | |
434 | return(1); | |
435 | } | |
436 | ||
437 | equal(a, b) | |
438 | char *a, *b; | |
439 | { | |
440 | ||
441 | while(*a++ == *b) | |
442 | if(*b++ == 0) | |
443 | return(1); | |
444 | return(0); | |
445 | } |