1 /*
2 *
3 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
38 #include <stdio.h>
40 /* Program to convert a ccs file to a b format file. */
43 int main (int argc, char *argv[])
44 {
45 FILE *strin;
46 FILE *strout;
47 int a, b, c, d, i;
48 int nwords;
49 char iline[132];
51 if (argc != 3) {
52 fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
53 return (-1);
54 }
56 strin = fopen (argv[1], "r");
57 if (strin == NULL) {
58 fprintf (stderr, "%s: could not open input file %s\n", argv[0], argv[1]);
59 return (-1);
60 }
62 strout = fopen (argv[2], "w");
63 if (strout == NULL) {
64 fprintf (stderr, "%s: could not open output file %s\n", argv[0], argv[2]);
65 fclose (strin);
66 return (-1);
67 }
69 fgets (iline, 132, strin);
70 sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &nwords);
73 fprintf (strout, "%c\n$A0000,\n",2);
75 for (i = 0; i < nwords; i++) {
77 fgets (iline, 132, strin);
78 iline[1] = '0';
79 sscanf (iline, "%x", &a);
80 fprintf (strout, "%02X %02X %02X %02X", (a>>24) & 0x00ff, (a>>16) & 0xff, (a>>8) & 0xff,
81 a & 0xff);
83 if ( ((i+1) % 6) )
84 fprintf (strout, " ");
85 else
86 fprintf (strout, "\n");
88 }
90 fprintf (strout, "\n%c",3);
92 fclose (strin);
93 fclose (strout);
95 return (0);
97 }