b2a.c 792 Bytes
/*
 *  Converts binary file into ASCII in form:
 *     address: <64-bit word>
 *     address: <64-bit word>
 *         .        .
 *         .        .
 *         .        .
 *     address: <64-bit word>
 *
 *  More useful than od -x which gives to many columns.
 */

#include <stdio.h>

main(int argc, char **argv)
{
  FILE *fp;
  unsigned int dbl_word[2];
  int ret, cnt;

  if(argc != 2)
  {
    printf("Usage: %s <filename>\n", argv[0]);
    exit(0);
  }

  if((fp = fopen(argv[1],"rb")) == NULL)
  {
    printf("Error opening %s\n", argv[1]);
    exit(1);
  }

  cnt = 0;

  do
  {
    ret = fread(dbl_word, sizeof(unsigned int), 2, fp);
    if(ret == 2)
      printf("%05d: 0x%08x%08x\n", cnt, dbl_word[0], dbl_word[1]);
    ++cnt;
  } while ( ret == 2 );
  
  fclose(fp);
  exit(0);
}