[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-04
8
Medium Priority
?
1,198 Views
Last Modified: 2012-06-21
Hi Experts,
I need to read an intel hex file and create a binary image.
How do I do that, any ideas?
Thanks
0
Comment
Question by:QurbanDurrani
  • 4
  • 2
  • 2
8 Comments
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22880501
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
 
LVL 12

Assisted Solution

by:jazzIIIlove
jazzIIIlove earned 600 total points
ID: 22880639
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
 
LVL 28

Expert Comment

by:2266180
ID: 22880712
actually, the questiona sker should clearify what he udnerstand by "intel hex file" and "binary image".
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22880794
ciuly:
you are right...

best regards...
0
 

Author Comment

by:QurbanDurrani
ID: 22881062
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
 

Author Comment

by:QurbanDurrani
ID: 22881239
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
 
LVL 28

Accepted Solution

by:
2266180 earned 1400 total points
ID: 22881308
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
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22881381
lol...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question