Intel HEX

The Intel HEX format is a data format for storage and transmission of binary data. It is now mainly used to store program data for microcontrollers and microprocessors, EPROMs and similar building blocks. It can also be used for storing load modules. The HEX format data format is the oldest of its kind and since the 1970s in use. Later extensions specifically support the segmented addressing the Intel 80x86 processors.

An Intel HEX file is in ASCII format. The bytes of the encoded binary data is represented as a hexadecimal number from two ASCII characters ( 0 .. 9 and A. .. F). HEX files can be opened and modified with any text editor. HEX file is about twice as large as the binary data included. The records are assigned a checksum, so that transmission errors can be detected.

  • 2.4.1 Intel
  • 2.4.2 Other Manufacturers

History

The Intel Hex Format (Originally Intellec -Hex ) was designed by Intel in 1973 for the Intellec development system (MDS ) to load and start programs from paper tape. It should also facilitate the transmission of data to ROM production. At the same time it has been used for programming (E) PROM using paper tape or punched-card controlled EPROM programming devices. From the introduction of floppy disk drives with the MCS Series II under ISIS II ( 1975) also files were created in this format. HEX is used as the file extension since then.

Format

The format described here corresponds to the Hexadecimal Object File Format Specification from Intel.

Building a data set

The coding is (7 bit) ASCII. Each record is separated by a colon ( ":") initiated, consisting of an even number of characters and is terminated by a newline. The structure of the line end has not been defined and media dependent. Intel tools for streaming media always produce a CR / LF ( 0D0AHEX ).

Two characters each represent one data byte. The notation is hexadecimal, big-endian with the characters 0 to 9 and A.. F, ie that the high-order half-byte is first. Likewise, all figures in the Address fields big-endian. Lower case letters (a.. F) are not mentioned in the definition, but are supported by most implementations.

Record types

Survey

There are six types of records (record types):

The records can occur in any order, an end record ( type 01 ) stops processing.

Data Record ( Type 00)

The data set contains the 16-bit address load address and the user data.

N: Number of bytes in the data field Address: 16-bit address for the storage of the data set Data: data field n bytes

End of File Record ( Type 01 )

The record marks the end of file. In the original (8-bit ) definition is, for loadable formats in the address field, enter the start address of the program ( PC) listed. In the 16 /32 bit formats, it must be 0000.

Extended Segment Address Record ( Type 02 )

The record contains the base address of the memory segment. It is used when the size of a 16-bit address space (ie 64 Kbytes ) is not sufficient. The address contained in the record is multiplied by 16 and added in the following data records (type 00 ) to the 16-bit address contained there. Bit 3 .0 ( least significant digit ) must always be zero. The address field of the record type 02 is always 0000, the length is 02

Start Segment Address Record ( Type 03 )

The record specifies the starting address for load modules. For x86 processors, this is the CS: IP content. The data can appear in any position. The start address is calculated as segment * 16 offset. The address field is always 0000, the length is 04

Extended Linear Address Record ( Type 04 )

To support a 32-bit address space, the data field contains the upper 16 bits ( Ulba Upper Linear Base Address ) of a 32 -bit address (LBA Linear Base Address). The lower 16 bits are assumed to be 0000. The address calculation of the following type 00 records are as Ulba DRLO DRI modulo 2 ^ 32 ( DRLO - DATA Record Load offset ( address field of the Data Record type 0), DRI - Data Record Index ( byte position of the data record type 0) ). The address field is always 0000, the length is 02

Start Linear Address Record ( Type 05 )

The record specifies the starting address for load modules. X86 processors, this is the content of the EIP register. The address field is always 0000, the length is 04

Calculate the checksum

The checksum is calculated excluding the start-up code and the checksum itself from the entire data set. The data is in byte summed of the sum of the low byte is taken and which in turn formed the twos.

The two's complement is formed by inverting the bits of the low byte and then 1 is added. This may be e.g. achieved by the exclusive- OR operation with FFHEX and addition of 01HEX. So 00HEX remains unchanged from 01HEX is FFHEX etc

The two's complement suppressed in the binary system of a negative number. Because the checksum so that is the negative sum of the remaining bytes, the review was a record designed to errors very easily. One simply sums the individual bytes of a data set including the checksum and receives as least significant byte 00HEX, if the record is correct.

Variants

Intel

Over the processor development from 4004 until today different variants have been defined:

Other manufacturers

The HEX format was used as a quasi-standard manifold. In this case, the byte in the data field has been partially changed. that is, the order does not correspond to the address location.

In addition, manufacturers have changed the addressing ( eg Texas Instruments). Here, the address corresponds to a byte, but not the width of a register of the processor.

Example

: 020000021000EC: 10010000214601360121470136007EFE09D2190140: 100110002146017EB7C20001FF5F16002148011988: 10012000194E79234623965778239EDA3F01B2CAA7: 100130003F0156702B5E712B722B732146013421C7: 00000001FF start code byte count address type data field checksum

The checksum for the first data sample is calculated as follows:

. Related file formats

Very similar to the Motorola - S format (also short S-Record, SREC or S19). In addition, there are also other formats, such as the simple binary code or the JEDEC format for this application.

Sources, Web Links

  • Intel HEX format ( English)
  • SB -Projects: file formats: intel hex - very clear presentation (English)
  • INTELHEX Project - Python library for Intel HEX files manipulations
390524
de