Intel HEX consists of lines of
ASCII text that are separated by
line feed or
carriage return characters or both. Each text line contains uppercase
hexadecimal characters that
encode multiple binary numbers. The binary numbers may represent data,
memory addresses, or other values, depending on their position in the line and the type and length of the line. Each text line is called a
record.
Record structure A
record (line of text) consists of six
fields (parts) that appear in order from left to right: •
Start code, one character, an ASCII colon ''. All characters preceding this symbol in a record should be ignored. In fact, very early versions of the specification even asked for a minimum of 25
NUL characters to precede the first record and follow the last one, owing to the format's origins as a
paper tape format which required some
tape leadin and leadout for handling. However, as this was a little known part of the specification, not all software written copes with this correctly. It allows to store other related information in the same file (and even the same line), a facility used by various software development utilities to store
symbol tables or additional comments, and third-party extensions using other characters as start code like the digits
.. by Intel and
Keil,
by Mostek, or ,
, ,
, and
by TDL. By convention, is often used for comments. Neither of these extensions may contain any ':' characters as part of the payload. •
Byte count, two hex digits (one hex digit pair), indicating the number of bytes (hex digit pairs) in the data field. The maximum byte count is 255 (0xFF). The values of 8 (0x08), 16 (0x10) and 32 (0x20) are commonly used byte counts. Not all software copes with counts larger than 16. •
Address, four hex digits, representing the 16-bit beginning memory address offset of the data. The
physical address of the data is computed by adding this offset to a previously established
base address, thus allowing memory addressing beyond the 64 kilobyte limit of 16-bit addresses. The base address, which defaults to zero, can be changed by various types of records. Base addresses and address offsets are always expressed as
big endian values. •
Record type (see
record types below), two hex digits, to , defining the meaning of the data field. •
Data, a sequence of
n bytes of data, represented by 2
n hex digits. Some records omit this field (
n equals zero). The meaning and interpretation of data bytes depends on the application. (4-bit data will either have to be stored in the lower or upper half of the bytes, that is, one byte holds only one addressable data item.) •
Checksum, two hex digits, a computed value that can be used to verify the record has no errors.
Color legend As a visual aid, the fields of Intel HEX records are colored throughout this article as follows:
Checksum calculation A record's checksum byte is the
two's complement of the
least significant byte (LSB) of the sum of all decoded byte values in the record preceding the checksum. It is computed by summing the decoded byte values and extracting the LSB of the sum (i.e., the data checksum), and then calculating the two's complement of the LSB (e.g., by
inverting its bits and adding one). For example, in the case of the record , the sum of the decoded byte values is + + + + + + = E2, which has LSB value E2. The two's complement of E2 is , which is the checksum byte appearing at the end of the record. The validity of a record can be checked by computing its checksum and verifying that the computed checksum equals the checksum appearing in the record; an error is indicated if the checksums differ. Since the record's checksum byte is the two's complement — and therefore the
additive inverse — of the data checksum, this process can be reduced to summing all decoded byte values, including the record's checksum, and verifying that the LSB of the sum is zero. When applied to the preceding example, this method produces the following result: + + + + + + + = 100, which has LSB value 00.
Text line terminators Intel HEX records are usually separated by one or more ASCII line termination characters so that each record appears alone on a text line. This enhances readability by visually
delimiting the records and it also provides padding between records that can be used to improve machine
parsing efficiency. However, the line termination characters are optional, as the '' is used to detect the start of a record. Programs that create HEX records typically use line termination characters that conform to the conventions of their
operating systems. For example, Linux programs use a single LF (
line feed, hex value 0A) character to terminate lines, whereas Windows programs use a CR (
carriage return, hex value 0D) followed by a LF.
Record types Intel HEX has six standard record types: } Other record types have been used for variants, including ('blinky' messages / transmission protocol container) by Wayne and Layne, (block start), (block end), (padded data), (custom data) and (other data) by the
BBC/
Micro:bit Educational Foundation, and (data in
code segment), (data in
data segment), (data in
stack segment), (data in
extra segment), (
paragraph address for absolute code segment), (paragraph address for absolute data segment), (paragraph address for absolute stack segment) and (paragraph address for absolute extra segment) by
Digital Research.
Named formats The original 4-bit/8-bit
Intellec Hex Paper Tape Format and
Intellec Hex Computer Punched Card Format in 1973/1974 supported only one record type . This was expanded around 1975 to also support record type . Sometimes called
symbolic hexadecimal format, it could include an optional header containing a
symbol table for
symbolic debugging, all characters in a record preceding the colon are ignored. Around 1978, Intel introduced the new record types and (to add support for the segmented address space of the then-new
8086/
8088 processors) in their
Extended Intellec Hex Format. Special names are sometimes used to denote the formats of HEX files that employ specific subsets of record types. For example: •
I8HEX (aka
HEX-80) files use only record types and •
I16HEX (aka
HEX-86) files use only record types through •
I32HEX (aka
HEX-386) files use only record types , , , and ==File example==