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

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [utils/] [bin2rom.c] - Blame information for rev 8

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

Line No. Rev Author Line
1 2 toni32
#include <stdio.h>
2
#include <stdlib.h>
3
#include <string.h>
4
 
5
void main(int argn, char **argc)
6
{
7
  FILE *f1, *f2;
8
  unsigned char bloque[4];
9
  int swap;
10
 
11
  if(argn < 3 || argn > 4)
12
  {
13
    printf("uso: bin2rom <fichero.bin> <fichero.rom> [-swap]\n");
14
    exit(1);
15
  }
16
  if(argn == 4 && strcmpi(argc[3], "-swap") == 1) swap = 1; else swap = 0;
17
 
18
  f1 = fopen(argc[1], "rb");
19
  f2 = fopen(argc[2], "w");
20
 
21
  while( !feof(f1) )
22
  {
23
    fread(bloque, 4, 1, f1);
24
    if(swap)
25
      fprintf(f2, "%02x%02x%02x%02x\n", ((unsigned)bloque[3]) & 0xff,
26
      ((unsigned)bloque[2])&0xff, ((unsigned)bloque[1])&0xff,
27
      ((unsigned)bloque[0])&0xff);
28
    else
29
      fprintf(f2, "%02x%02x%02x%02x\n", ((unsigned)bloque[0]) & 0xff,
30
      ((unsigned)bloque[1])&0xff, ((unsigned)bloque[2])&0xff,
31
      ((unsigned)bloque[3])&0xff);
32
  }
33
  fclose(f1);
34
  fclose(f2);
35
}
36
 
37
 

powered by: WebSVN 2.1.0

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