Intel HEX

1

Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary information in ASCII text form, making it possible to store on non-binary media such as paper tape, punch cards, etc., to display on text terminals or be printed on line-oriented printers. The format is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devices and hardware emulators. In a typical application, a compiler or assembler converts a program's source code (such as in C or assembly language) to machine code and outputs it into a object or executable file in hexadecimal (or binary) format. In some applications, the Intel hex format is also used as a container format holding packets of stream data. Common file extensions used for the resulting files are .HEX or .H86. The HEX file is then read by a programmer to write the machine code into a PROM or is transferred to the target system for loading and execution. There are various tools to convert files between hexadecimal and binary format (i.e. HEX2BIN), and vice versa (i.e. OBJHEX, OH, OHX, BIN2HEX).

History

The Intel hex format was originally designed for Intel's Intellec Microcomputer Development Systems (MDS) in 1973 in order to load and execute programs from paper tape. It was also used to specify memory contents to Intel for ROM production, which previously had to be encoded in the much less efficient BNPF (Begin-Negative-Positive-Finish) format. In 1973, Intel's "software group" consisted only of Bill Byerly and Kenneth Burgett, and Gary Kildall as an external consultant doing business as Microcomputer Applications Associates (MAA) and founding Digital Research in 1974. Beginning in 1975, the format was utilized by Intellec Series II ISIS-II systems supporting diskette drives, with files using the file extension HEX. Many PROM and EPROM programming devices accept this format.

Format

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:

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 + + + + + + = , which has LSB value. The two's complement of 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: + + + + + + + = , which has LSB value.

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 ) character to terminate lines, whereas Windows programs use a CR (carriage return, hex value ) 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:

File example

This example shows a file that has four data records followed by an end-of-file record:

Variants

Besides Intel's own extension, several third-parties have also defined variants and extensions of the Intel hex format, including Digital Research (as in the so-called "Digital Research hex format" ), Zilog, Mostek, TDL, Texas Instruments, Microchip, c't, Wayne and Layne, and BBC/Micro:bit Educational Foundation (with its "Universal Hex Format" ). These can have information on program entry points and register contents, a swapped byte order in the data fields, fill values for unused areas, fuse bits, and other differences. The Digital Research hex format for 8086 processors supports segment information by adding record types to distinguish between code, data, stack, and extra segments. Most assemblers for CP/M-80 (and also XASM09 for the Motorola 6809) don't use record type 01h to indicate the end of a file, but use a zero-length data type 00h entry instead. This eases the concatenation of multiple hex files. Texas Instruments defines a variant where addresses are based on the bit-width of a processor's registers, not bytes. Microchip defines variants INTHX8S (INHX8L, INHX8H ), INHX8M, INHX16 (INHX16M ) and INHX32 for their PIC microcontrollers. Alfred Arnold's cross-macro-assembler AS, Werner Hennig-Roleff's 8051-emulator SIM51, and Matthias R. Paul's cross-converter BINTEL are also known to define extensions to the Intel hex format.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

View original