I need to take a intel hex file and create a binary image.

Hi Experts,
I need to read an intel hex file and create a binary image.
How do I do that, any ideas?
Thanks
QurbanDurraniAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jazzIIIloveCommented:
Hi there;

A command line tool:

http://www.keil.com/download/docs/113.asp

and yet another one:

http://www.programmersheaven.com/download/3179/download.aspx

Best regards...
0
jazzIIIloveCommented:
ohh...it was in Delphi...

Please specify you want a coding like below which is Pascal or some tools like above...The question is not that clear...

{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
{ Convert from Decimal to Binary, hexadecimal, Octal and vise versa...    }
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
{                           By M.A.C. Duiker                              }
{                                                                         }
{                     Email : MDuiker@GlobalXS.nl                         }
{                        or : pe1pzu@amsat.org                            }
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
{ All conversions from binary & hexadecimal return zero if a non-binary or}
{ non-hexadecimal character was found in the string. Eg. Hex2Dec('afs1')=0}
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
{   Other convertions will be added into this unit on (email-)request.    }
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
Unit MathCvt; { Version 1.00 }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
Interface
 
Function Power(X,Y:WORD):LongInt;
Function Bin2Dec(Bin:String):LongInt;
Function Bin2Hex(Bin:String):String;
Function Dec2Bin(Dec:LongInt):String;
Function Dec2Hex(Dec:LongInt):String;
Function Hex2Bin(Hex:String):String;
Function Hex2Dec(Hex:String):LongInt;
Function Oct2Dec(Oct:String):LongInt;
Function Dec2Oct(Dec:LongInt):String;
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
Implementation
 
FUNCTION Power(X,Y:Word):LongInt;
 
VAR Temp,Teller : LongInt;
 
BEGIN
  TEMP:=1;
  FOR Teller:=1 TO Y DO TEMP:=TEMP*X;
  Power:=Temp;
END; { Power }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Dec2Bin(Dec:LONGINT):String;
 
VAR B1:INTEGER;
    Bin,BinDigit:STRING;
 
BEGIN
  BinDigit:='01';
  Bin:='';
  REPEAT
  B1:=DEC MOD 2;
  DEC:=DEC DIV 2;
  Bin:=CONCAT(BinDigit[B1+1],Bin);
  UNTIL DEC<1;
  Dec2Bin:=Bin;
END; { Dec2Bin }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Hex2Dec(Hex:STRING):LongInt;
 
VAR   T1,T2,Dec   :       LongInt;
      Error       :       Boolean;
 
BEGIN
  Error:=False;
  T1:=0;T2:=0;DEC:=0;
  FOR T1:=1 TO LENGTH(Hex) DO
  BEGIN
   T2:=Length(Hex)-T1;
   CASE Hex[T1] OF
   '0'  : DEC:=DEC+0;
   '1'  : DEC:=DEC+Power(16,T2);
   '2'  : DEC:=DEC+2*Power(16,T2);
   '3'  : DEC:=DEC+3*Power(16,T2);
   '4'  : DEC:=DEC+4*Power(16,T2);
   '5'  : DEC:=DEC+5*Power(16,T2);
   '6'  : DEC:=DEC+6*Power(16,T2);
   '7'  : DEC:=DEC+7*Power(16,T2);
   '8'  : DEC:=DEC+8*Power(16,T2);
   '9'  : DEC:=DEC+9*Power(16,T2);
   'A','a' : DEC:=DEC+10*Power(16,T2);
   'B','b' : DEC:=DEC+11*Power(16,T2);
   'C','c' : DEC:=DEC+12*Power(16,T2);
   'D','d' : DEC:=DEC+13*Power(16,T2);
   'E','e' : DEC:=DEC+14*Power(16,T2);
   'F','f' : DEC:=DEC+15*Power(16,T2);
   ELSE Error:=True;
   END;
  END;
  Hex2Dec:=Dec;
  IF Error THEN Hex2Dec:=0;
END; { Hex2Dec }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Oct2Dec(Oct:STRING):LongInt;
 
VAR   T1,T2,Dec   :       LongInt;
      Error       :       Boolean;
 
BEGIN
  Error:=False;
  T1:=0;T2:=0;DEC:=0;
  FOR T1:=1 TO LENGTH(Oct) DO
  BEGIN
   T2:=Length(Oct)-T1;
   CASE Oct[T1] OF
   '0'  : DEC:=DEC+0;
   '1'  : DEC:=DEC+Power(8,T2);
   '2'  : DEC:=DEC+2*Power(8,T2);
   '3'  : DEC:=DEC+3*Power(8,T2);
   '4'  : DEC:=DEC+4*Power(8,T2);
   '5'  : DEC:=DEC+5*Power(8,T2);
   '6'  : DEC:=DEC+6*Power(8,T2);
   '7'  : DEC:=DEC+7*Power(8,T2);
   ELSE Error:=True;
   END;
  END;
  Oct2Dec:=Dec;
  IF Error THEN Oct2Dec:=0;
END; { Oct2Dec }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Bin2Dec(BIN:STRING):LongInt;
 
VAR   T1,T2,Dec   :       LongInt;
      Error       :       Boolean;
 
BEGIN
  Error:=False;
  T1:=0;T2:=0;DEC:=0;
  FOR T1:=1 TO LENGTH(BIN) DO
  BEGIN
   T2:=Length(BIN)-T1;
   CASE BIN[T1] OF
   '1'  : DEC:=DEC+Power(2,T2);
   '0'  : DEC:=DEC+0;
   ELSE Error:=True;
   END;
  END;
  Bin2Dec:=Dec;
  IF Error THEN Bin2Dec:=0;
END; { Bin2Dec }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Dec2Hex(DEC:LONGINT):STRING;
 
VAR H1:INTEGER;
    Hex,HexDigit:STRING;
 
BEGIN
  HexDigit:='0123456789ABCDEF';
  HEX:='';
  REPEAT
  H1:=DEC MOD 16;
  DEC:=DEC DIV 16;
  Hex:=CONCAT(Hexdigit[H1+1],Hex);
  UNTIL DEC<1;
  Dec2Hex:=Hex;
END; { Dec2Hex }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Dec2Oct(DEC:LONGINT):STRING;
 
VAR O1:INTEGER;
    Oct,OctDigit:STRING;
 
BEGIN
  OctDigit:='01234567';
  Oct:='';
  REPEAT
  O1:=DEC MOD 8;
  DEC:=DEC DIV 8;
  Oct:=CONCAT(Octdigit[O1+1],Oct);
  UNTIL DEC<1;
  Dec2Oct:=Oct;
END; { Dec2Oct }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Hex2Bin(Hex:String):String;
 
BEGIN
  Hex2Bin:=Dec2Bin(Hex2Dec(Hex));
END; { Hex2Bin }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
FUNCTION Bin2Hex(Bin:String):String;
 
BEGIN
  Bin2Hex:=Dec2Hex(Bin2Dec(Bin));
END; { Bin2Hex }
 
{ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
 
END.

Open in new window

0
2266180Commented:
actually, the questiona sker should clearify what he udnerstand by "intel hex file" and "binary image".
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

jazzIIIloveCommented:
ciuly:
you are right...

best regards...
0
QurbanDurraniAuthor Commented:
Thanks for your responses thus far guys.
sorry for the lack of clarity.
I need to open an intel hex format file (http://en.wikipedia.org/wiki/.hex) the format described in the wiki document. Next I need to create a binary image file, meaning that I need to create a 1 MB arrey and put the data in the type '00 record at the address specified in the address field of the type '00 record.
0
QurbanDurraniAuthor Commented:
I might add that the address specified in the type '00' record is added to the address specified in the type '02' record for the segment to come up with the real address.
0
2266180Commented:
and you really want to code this yourself? there is a tool mentioned on that wiki page: http://home.hetnet.nl/~newlife-software/Binex/binex.htm
you can alternativly use some of the code provided earlier. if jazzIIIlove is willing, I'll leave this up to him as it's not complicated at all ;)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jazzIIIloveCommented:
lol...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.