Intel hex format

Source: Internet
Author: User
Original article address
Http://bbs.netpu.net/viewthread.php? Tid = 1690

Note:
A previous article translated during format conversion. At that time, I didn't know much about these things, so it was not good at translation. I have not been exposed to this information for about 3 or 4 years, so even if there is an error, it cannot be corrected now. I hope I will not be laughed at when I figure out my computer. Thank you for your criticism.

Problem:
What is the intel HEX file format?

Answer:

An Intel HEX file is an ASCII text file consisting of a line of text that conforms to the intel HEX file format. In the Intel HEX file, each row contains a hex record. These records consist of hexadecimal encoded numbers corresponding to the machine language code and/or constant data. Intel hex files are generally used to transmit programs and data that will be stored in ROM or EPROM. Most EPROM programmers or simulators use intel hex files.

Record format
Intel hex consists of any number of hexadecimal records. Each record contains five fields in the following format:
: Llaaaatt [DD...] CC
Each group of letters corresponds to a different domain, and each letter corresponds to a hexadecimal number. Each domain consists of at least two hexadecimal numbers, which constitute a byte, as described below:
: Each intel hex record starts with a colon.
Ll is the data length field, which indicates the number of data bytes (dd) in the record.
Aaaa is the address field, which indicates the starting address of the data in the record.
TT is a domain that represents the hex record type. It may be one of the following data:
00-data records
01-end records
02-extended segment address record
04-Extended Linear address records
Dd is a data field that represents a byte of data. A record can contain many data bytes. The number of data bytes in the record must be consistent with the number specified in the Data Length Field (ll.
Cc is the verification and domain, which indicates the record's checksum. The calculation of the checksum is to add the values of all hexadecimal encoded numeric pairs in the record, and supplement the following with 256 as the model.

Data Records
An Intel HEX file consists of any number of data records ending with the carriage return linefeed. The data record appearance is as follows:
: 10246200464C5549442050524F46494C4500464C33
Where:
10 is the number of data bytes in the record.
2462 is the address where the data will be downloaded to the memory.
00 is the record type (data record)
464C... 464C is data.
33 is the checksum of the record.

Extended Linear Address Record (HEX386)
Extended Linear address records are also known as 32-bit address records or HEX386 records. These records contain 16-bit high data addresses. Extended Linear address records always have two data bytes. The appearance is as follows:
: 02000004 FFFFFC
Where:
02 is the number of data bytes in this record.
0000 is the address field. For Extended Linear address records, this field is always 0000.
04 is record type 04 (Extended Linear Address Record)
FFFF is the 16-bit high address.
FC is the checksum of the record. The calculation method is as follows:
01 h + NOT (02 h + 00 h + 00 h + 04 h + FFh ).
When an Extended Linear address record is read, the Extended Linear address stored in the data domain is saved and applied to subsequent records read from the Intel HEX file. the linear address remains valid until it is changed by another extended address record.
The Absolute Memory Address of the data record is obtained by adding the address field in the record to the address data of the shifted Extended Linear address record.
The following example demonstrates the process ..
Address 2462 from the address field of the data record
Extended Linear address record data domains + FFFF
------------
Absolute storage address FFFF2462

Extended segment address record (HEX86)
The extended segment address record is also known as the HEX86 record, which contains 4-19 BITs. The extended segment address record always contains two data bytes. The appearance is as follows:
: 020000021200EA
Where:
02 indicates the number of data bytes in the record.
0000 is the address field. For extended segment address records, this field is always 0000.
02 is record type 02 (Extended segment address record)
1200 is the address segment.
EA is the checksum of the record. The calculation method is as follows:
01 H + not (02 H + 00 H + 00 H + 02 H + 12 h + 00 H ).
When an extended segment address record is read, the extended segment address stored in the data domain is saved and applied to subsequent records read from the Intel HEX file. the segment address remains valid until it is changed by another extended address record.
The Absolute Memory Address of the data record is obtained by adding the address field in the record to the address data of the shifted address records from the extended segment.
The following example demonstrates the process ..
Address 2462 from the address field of the data record
Extended segment address record data domain + 1200
---------
Absolute Memory Address 00014462

End of file (EOF) Record
The Intel HEX file must end with an EOF record. The value of this record type field must be 01. EOF record appearance is always as follows:
: 00000001FF
Where:
00 indicates the number of data bytes in the record.
0000 is the address where the data is downloaded to the storage. In the end of the file, the address is meaningless and ignored. 127h is a typical address.
01 is the record type 01 (file end record)
FF is the checksum of the record. The calculation method is as follows:
01 h + NOT (00 h + 00 h + 00 h + 01 h ).

Intel HEX file example:
The following is an example of a complete Intel HEX file:
: 10001300ac12ad13ae10af113692f8e0e8f0f2244
: 2017300e50b250df509e50a350cf5081200132259
: 03000000020023D8
: 0C002300787FE4F6D8FD7581130200031D
: 10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016
: 04003F00A42EFE22CB
: 00000001FF

Summary
If you have any questions, Contact tech [AT] netpu.net. {Replace [AT] @}

Http://www.netpu.net/
Wangpu technology is copyrighted. for reprinting, please indicate the author and source and keep the original appearance of the article.
(Chinop technology's high-quality and cheap U.S. host and U.S. LINUX Virtual Host Service)

Appendix: Original ENGLISH
QUESTION
What is the Intel HEX file format?
ANSWER
The Intel HEX file is an ASCII text file with lines of text that follow
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 wocould 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:
: Llaaaatt [dd...] cc
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:
: Is the colon that starts every intel hex record.
Ll is the record-length field that represents the number of data bytes (dd) in
The record.
Aaaa is the address field that represents the starting address for subsequent
Data in the record.
TT is the field that represents the hex record type, which may be one of
Following:
00-data record
01-end-of-file record
02-extended segment address record
04-Extended Linear Address Record
Dd is a data field that represents one byte of data. A record may have multiple
Data bytes. The number of data bytes in the record must match the number
Specified by the ll field.
Cc is the checksum field that represents the checksum of the record.
Checksum is calculated by summing the values of all hexadecimal digit pairs in
The record modulo 256 and taking the two's complement.
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:
: 10246200464C5549442050524F46494C4500464C33
Where:
10 is the number of data bytes in the record.
2462 is the address where the data are to be located in memory.
00 is the record type 00 (a data record ).
464C... 464C is the data.
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
Data address. The extended linear address record always has two data bytes and
Appears as follows:
: 02000004 FFFFFC
Where:
02 is the number of data bytes in the record.
0000 is the address field. For the extended linear address record, this field
Is alway 0000.
04 is the record type 04 (an extended linear address record ).
FFFF is the upper 16 bits of the address.
FC is the checksum of the record and is calculated
01 h + NOT (02 h + 00 h + 00 h + 04 h + 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 failed tive until changed
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 extends strates 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:
: 020000021200ea
Where:
02 is the number of data bytes in the record.
0000 is the address field. For the extended segment address record, this field
Is alway 0000.
02 is the record type 02 (an extended segment address record ).
1200 is the segment of the address.
EA is the checksum of the record and is calculated
01 H + not (02 H + 00 H + 00 H + 02 H + 12 h + 00 H ).
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 failed tive until changed
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 extends strates 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
Follows:
: 00000001FF
Where:
00 is the number of data bytes in the record.
0000 is the address where the data are to be located in memory. The address in
End-of-file records is meaningless and is ignored. An address of 0000 h is
Typical.
01 is the record type 01 (an end-of-file record ).
FF is the checksum of the record and is calculated
01 h + NOT (00 h + 00 h + 00 h + 01 h ).
Example Intel HEX File
Following is an example of a complete intel HEX file:
: 10001300ac12ad13ae10af113692f8e0e8f0f2244
: 2017300e50b250df509e50a350cf5081200132259
: 03000000020023d8
: 0c002300787fe4f6d8fd7581130200031d
: 10002f00eff88df0a4ffedc5f0cea42efeec88f016
: 04003f00a42efe22cb
: 00000001ff

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.