原创 INTEL HEX FILE FORMAT

2009-3-3 13:08 2718 4 4 分类: 软件与OS

TITLE: INTEL HEX FILE FORMAT<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


ARRANGED BY : Maxwell


DATE: <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />2008-11-14 P.M.


General


The INTEL HEX file is an ASCII text file with lines of text that follow the INTEL HEX file format. Each LINE in an INTEL HEX file contains one HEX record. These records are made up of hexadecimal numbers that represent machine language code and/or constant data. INTEL HEX files are often used to transfer the program and data that would be stored in a ROM or EPROM. Most EPROM programmers or emulators can use INTEL HEX files.


 


Record Format


An INTEL HEX file is composed of any number of HEX records. Each record is made


up of five fields that are arranged in the following format:




START


LENGTH


TYPE


DATA


CHECKSUM


;


00 – 1F


00010204


 


01H+not( SUM )


Each group of letters corresponds to a different field, and each letter represents a single hexadecimal digit. Each field is composed of at least two hexadecimal digits-which make up a byte-as described below:


1.       START FLAG is the colon that starts every INTEL HEX record.


2.       LENGTH explains bytes current line INTEL HEX record.


3.       TYPE represents the HEX record type, which may be one as follows :


00 data record.


01 End-Of-File (EOF) record.


02 extended segment address record.


04 externded linear address record.


4.       DATA is a data field that represents several bytes data, The NO. of byte was specified by LENGTH segment.


5.       CHECKSUM field that represents the checksum of the record.The checksum is calculated by summing the values of all hexadecimal digit pairs.


 


Data Records


The INTEL HEX file is made up of any number of data records that are terminated with a carriage return and a linefeed. Data records appear as follows:


; LENGTH  ADDR   TYPE  DATAs                             CHECKSUM


: 10         2462     00    464C5549442050524F46494C4500464C  33


 


DESCRIPTION:


1.       10 is the number of data bytes in the record.


2.       2462 is the address where the data are to be located in memory.


3.       00 is the record type 00 (a data record).


4.       464C...464C is the data.


5.       33 is the checksum of the record.


 


Extended linear address records (HEX386)


Extended linear address records are also known as 32-bit address records and HEX386 records. These records contain the upper 16 bits (bits 16-31) of the data address. The extended linear address record always has two data bytes and appears as follows:


;LENGTH  EXTERN ADDR  TYPE  DATA    CHECKSUM


:02        0000            04     FFFF    FC


 


DESCRIPTION:


1.       02 is the number of data bytes in the record.


2.       0000 is the address field. For the extended linear address record, this field is always 0000.


3.       04 is the record type 04 (an extended linear address record).


4.       FFFF is the upper 16 bits of the address.


5.       FC is the checksum of the record and is calculated as 01h + NOT (02h + 00h + 00h + 04h + FFh + FFh).


When an extended linear address record is read, the extended linear address stored in the data field is saved and is applied to subsequent records read from the INTEL HEX file. The linear address remains effective until changed by another extended address record.


 


The absolute-memory address of a data record is obtained by adding the address field in the record to the shifted address data from the extended linear address record. The following example illustrates this process.


 


Address from the data record's address field      2462


Extended linear address record data field        FFFF


                                        --------


Absolute-memory address               FFFF2462


 


Extended Segment Address Records (HEX86)


Extended segment address records-also known as HEX86 records-contain bits 4-19


of the data address segment. The extended segment address record always has two


data bytes and appears as follows:


;LENGTH  EXTERN-ADDR  TYPE  DATA   CHECKSUM


:02        0000            02     1200    EA


 


DESCRIPTION:


1.       02 is the number of data bytes in the record.


2.       0000 is the address field. For the extended segment address record, this field is always 0000.


3.       02 is the record type 02 (an extended segment address record).


4.       1200 is the segment of the address.


5.       EA is the checksum of the record and is calculated as 01h + NOT(02h + 00h + 00h + 02h + 12h + 00h).


 


When an extended segment address record is read, the extended segment address stored in the data field is saved and is applied to subsequent records read from the INTEL HEX file. The segment address remains effective until changed by another extended address record.


 


The absolute-memory address of a data record is obtained by adding the address field in the record to the shifted-address data from the extended segment address record. The following example illustrates this PROCESS.


 


Address from the data record's address field      2462


Extended segment address record data field     1200


                                        --------


Absolute MEMORY address              00014462


 


End-of-File (EOF) Records


An INTEL HEX file must end with an end-of-file (EOF) record. This record must have the VALUE 01 in the record type field. An EOF record always appears as follows:


:00 0000 01 FF


DESCRIPTION:


1.       00 is the NUMBER of data bytes in the record.


2.       0000 is the address where the data are to be located in MEMORY. The address in


3.       end-of-file records is meaningless and is ignored. An address of 0000h is typical.


4.       01 is the record type 01 (an end-of-file record).


5.       FF is the CHECKSUM of the record and is calculated as 01h + NOT(00h + 00h + 00h + 01h).


 


Example INTEL HEX File


Following is an example of a complete INTEL HEX file:


 


:10001300AC12AD13AE10AF1112002F8E0E8F0F2244


:10000300E50B250DF509E50A350CF5081200132259


:03000000020023D8


:0C002300787FE4F6D8FD7581130200031D


:10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016


:04003F00A42EFE22CB


:00000001FF

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
4
关闭 站长推荐上一条 /3 下一条