OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [mp3/] [sw/] [utils/] [bin2flimg.c] - Blame information for rev 1781

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

Line No. Rev Author Line
1 281 simons
#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 301 lampret
        if(argc < 3) {
11
                printf("no input file specified");
12
                exit(1);
13
        }
14
 
15 281 simons
        width = atoi(argv[1]);
16
 
17
        fd = fopen( argv[2], "r" );
18
 
19
        while (!feof(fd)) {
20
                j = 0;
21
                word = 0;
22
                while (j < width) {
23
                        c = fgetc(fd);
24
                        if (c == EOF) {
25
                                c = 0;
26
                        }
27
                        word = (word << 8) + c;
28
                        j++;
29
                }
30
                if(width == 1)
31
                        printf("%.2lx\n", word);
32
                else if(width == 2)
33
                        printf("%.4lx\n", word);
34
                else
35
                        printf("%.8lx\n", word);
36
        }
37
        return 0;
38
}

powered by: WebSVN 2.1.0

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