source: buchla-68k/orig/BUCHLA/FPUPROMS.C@ 6888aa2

Last change on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 3.8 KB
Line 
1/*
2 =============================================================================
3 fpuproms.c -- Buchla 700 FPU Microcode PROM Utility
4 Version (see VER below) -- D.N. Lynx Crowe
5
6 This program takes an ASCII file giving the microcode addresses
7 and data values, and creates 5 PROM files in Motorola S-Record format.
8
9 The FPU700.DAT input file consists of 9 input fields, as follows:
10
11 adr p1 p2 p2b p3 p3b p4 p4b p5
12
13 where:
14
15 adr is the address in decimal for the data
16 p1..p5 is the hex data for each prom
17
18 PROM 2, PROM 3, and PROM 4 have separate data for each half, while the
19 data from the first half is duplicated in the second half for
20 PROM 1 and PROM 5.
21 =============================================================================
22*/
23
24#define VER "4 - 1987-09-11" /* version ID */
25
26#include "stdio.h"
27#include "stddefs.h"
28
29extern short msrec();
30extern char *memset();
31
32#define NFIELDS 9 /* number of input data fields */
33
34#define FN_IN "FPU700.DAT" /* input file name (stripped Wordstar file) */
35
36#define FN_P1 "FPU700P1.MOT" /* output file name - PROM 1 */
37#define FN_P2 "FPU700P2.MOT" /* output file name - PROM 2 */
38#define FN_P3 "FPU700P3.MOT" /* output file name - PROM 3 */
39#define FN_P4 "FPU700P4.MOT" /* output file name - PROM 4 */
40#define FN_P5 "FPU700P5.MOT" /* output file name - PROM 5 */
41
42FILE *fp; /* stream pointer */
43
44char prom[5][1024]; /* PROM images */
45
46short padr, p1, p2, p2b, p3, p3b, p4, p4b, p5; /* input variables */
47
48/*
49
50*/
51
52/*
53 =============================================================================
54 putfile(fn, n) -- output PROM file 'n' to file 'fn'
55 =============================================================================
56*/
57
58putfile(fn, n)
59FILE *fn;
60short n;
61{
62 if (NULL EQ (fp = fopen(fn, "w"))) {
63
64 printf("\nfpuproms: ERROR - unable to open output file [%s]\n",
65 fn);
66
67 exit(1);
68 }
69
70 msrec(fp, 0L, 1024L, prom[n]);
71 fclose(fp);
72 printf("fpuproms: PROM %d file [%s] written\n", n + 1, fn);
73}
74
75/*
76
77*/
78
79/*
80 =============================================================================
81 main function -- Buchla 700 FPU Microcode PROM Utility
82 =============================================================================
83*/
84
85main()
86{
87 register short i, rc;
88
89 printf("Buchla 700 FPU Microcode PROM Utility -- Version %s\n\n", VER);
90
91 if (NULL EQ (fp = fopen(FN_IN, "r"))) {
92
93 printf("fpuproms: ERROR - Unable to open [%s] for input\n",
94 FN_IN);
95
96 exit(1);
97 }
98
99 padr = -1;
100 memset(prom, 0xFF, sizeof prom);
101
102/*
103
104*/
105 /* read the PROM data */
106
107 printf("fpuproms: Reading PROM data from [%s]\n", FN_IN);
108
109 for (;;) {
110
111 rc = fscanf(fp, "%d %x %x %x %x %x %x %x %x",
112 &padr, &p1, &p2, &p2b, &p3, &p3b, &p4, &p4b, &p5);
113
114 if (rc EQ EOF)
115 break;
116
117 if (rc NE NFIELDS) {
118
119 printf("\nfpuproms: ERROR - Invalid data near address %d\n",
120 padr);
121
122 exit(1);
123 }
124
125 if (padr LT 0 OR padr GT 511) {
126
127 printf("\nfpuproms: ERROR - Address [%d] not in range 0..511\n",
128 padr);
129
130 exit(1);
131 }
132
133 prom[0][padr] = p1; /* PROM 1 */
134 prom[0][padr+512] = p1;
135
136 prom[1][padr] = p2; /* PROM 2 */
137 prom[1][padr+512] = p2b;
138
139 prom[2][padr] = p3; /* PROM 3 */
140 prom[2][padr+512] = p3b;
141
142 prom[3][padr] = p4; /* PROM 4 */
143 prom[3][padr+512] = p4b;
144
145 prom[4][padr] = p5; /* PROM 5 */
146 prom[4][padr+512] = p5;
147 }
148
149/*
150
151*/
152
153 fclose(fp);
154
155 printf("fpuproms: End of input file reached\n");
156
157 /* write out the Motorola S-Record PROM data files */
158
159 printf("\nfpuproms: Writing Motorola S-Record PROM data files\n");
160
161 putfile(FN_P1, 0);
162 putfile(FN_P2, 1);
163 putfile(FN_P3, 2);
164 putfile(FN_P4, 3);
165 putfile(FN_P5, 4);
166
167 printf("\nfpuproms: PROM file conversion complete\n");
168 exit(0);
169}
170
Note: See TracBrowser for help on using the repository browser.