OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ucos-ii/] [2.91/] [utils/] [bin2flimg.c] - Blame information for rev 647

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 471 julius
#include <stdio.h>
2
 
3
int main(int argc, char **argv)
4
{
5
 
6
        FILE  *fd;
7
        int c, i, j, width;
8
        unsigned long word;
9
 
10
        if(argc < 3)
11
                error("no input file specified");
12
 
13
        width = atoi(argv[1]);
14
 
15
        fd = fopen( argv[2], "r" );
16
 
17
        while (!feof(fd)) {
18
                j = 0;
19
                word = 0;
20
                while (j < width) {
21
                        c = fgetc(fd);
22
                        if (c == EOF) {
23
                                c = 0;
24
                        }
25
                        word = (word << 8) + c;
26
                        j++;
27
                }
28
                if(width == 1)
29
                        printf("%.2lx\n", word);
30
                else if(width == 2)
31
                        printf("%.4lx\n", word);
32
                else
33
                        printf("%.8lx\n", word);
34
        }
35
        return 0;
36
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.