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?
 
2266180Connect With a Mentor Commented:
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
 
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
 
jazzIIIloveConnect With a Mentor Commented:
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
2266180Commented:
actually, the questiona sker should clearify what he udnerstand by "intel hex file" and "binary image".
0
 
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
 
jazzIIIloveCommented:
lol...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.