OT-ish - converting hex output to binary on a Unix platform

From: Dwight K. Elvey <dwight.elvey_at_amd.com>
Date: Fri Jul 30 11:26:20 2004

Hi
 If I was doing this on a Intel ISIS II system, I'd
use an editor called X1.11. Although, there are languages
like Perl that specifically handle text input streams,
most any language can handle this conversion. I believe
I have written this very same function in at least 3
different languages at one time or another. I know
I've done it in BASIC, 8080 assembly and Forth.
The concept is always the same.
1. Get a line
2. parse the line into words( hex digit pairs )
3. Translate the hex into binary
4. write that to an output file.
 One just repeats this until done. Of course, one may optimize
things by buffering input and output in sizes that
are similar to the storage media. Translation can be any
of a number of methods. Even a translation table although
I think I've always done it by doing calculations on
the ascii value( some languages get in the way by requiring
casting between data types ).
Dwight

>From: "Jules Richardson" <julesrichardsonuk_at_yahoo.co.uk>
>
>
>Silly question, but maybe someone here's found a nice way of doing this
>using standard Unix tools...
>
>I have a few files in hex format (actually ROM dumps) and want to
>convert them to binary. Sort of the reverse of the hexdump utility. I'm
>not aware of a standard (and probably on-topic!) Unix util to do this,
>but maybe someone knows if there is one, or a handy way of doing this
>using some of the standard text-processing utils that Unix has...
>
>(files are in the format of 16 pairs of uppercase hex digits per line,
>with a trailing space after every pair - even the last one on a line)
>
>I'm rapidly coming to the conclusion that I need to remember some C
>again - and I've only just finished emptying my brain of it after the
>last time I needed to code in it a couple of months ago :-)
>
>cheers
>
>Jules
>
>
Received on Fri Jul 30 2004 - 11:26:20 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:36:53 BST