]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/blob - src/util/btoccs/ccs2b.c
Make updates for big endian
[keystone-rtos/ibl.git] / src / util / btoccs / ccs2b.c
1 #include <stdio.h>
3 /* Program to convert a ccs file to a b format file. */
6 int main (int argc, char *argv[])
7 {
8   FILE *strin;
9   FILE *strout;
10   int a, b, c, d, i;
11   int nwords;
12   char iline[132];
14   if (argc != 3)  {
15     fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
16         return (-1);
17   }
19   strin = fopen (argv[1], "r");
20   if (strin == NULL)  {
21     fprintf (stderr, "%s: could not open input file %s\n", argv[0], argv[1]);
22     return (-1);
23   }
25   strout = fopen (argv[2], "w");
26   if (strout == NULL)  {
27     fprintf (stderr, "%s: could not open output file %s\n", argv[0], argv[2]);
28     fclose (strin);
29     return (-1);
30   }
32   fgets (iline, 132, strin);
33   sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &nwords);
36   fprintf (strout, "%c\n$A0000,\n",2);
38   for (i = 0; i < nwords; i++)  {
40     fgets (iline, 132, strin);
41     iline[1] = '0';
42     sscanf (iline, "%x", &a);
43     fprintf (strout, "%02X %02X %02X %02X", (a>>24) & 0x00ff, (a>>16) & 0xff, (a>>8) & 0xff,
44                                             a & 0xff);
46     if ( ((i+1) % 6) )
47       fprintf (strout, " ");
48     else
49       fprintf (strout, "\n");
51   }
53   fprintf (strout, "\n%c",3);
55   fclose (strin);
56   fclose (strout);
58   return (0);
60 }
61   
65