Intel Hex
   HOME

TheInfoList



OR:

Intel hexadecimal object file format, Intel hex format or Intellec Hex is a
file format A file format is a standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary or free. Some file formats ...
that conveys
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two digits (0 and 1) * Binary function, a function that takes two arguments * Binary operation, a mathematical operation that t ...
information in
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
text Text may refer to: Written word * Text (literary theory), any object that can be read, including: **Religious text, a writing that a religious tradition considers to be sacred **Text, a verse or passage from scripture used in expository preachin ...
form. It is commonly used for programming
microcontroller A microcontroller (MCU for ''microcontroller unit'', often also MC, UC, or μC) is a small computer on a single VLSI integrated circuit (IC) chip. A microcontroller contains one or more CPUs (processor cores) along with memory and programmable i ...
s,
EPROM An EPROM (rarely EROM), or erasable programmable read-only memory, is a type of programmable read-only memory (PROM) chip that retains its data when its power supply is switched off. Computer memory that can retrieve stored data after a power s ...
s, and other types of programmable logic devices and hardware emulators. In a typical application, a
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
or
assembler Assembler may refer to: Arts and media * Nobukazu Takemura, avant-garde electronic musician, stage name Assembler * Assemblers, a fictional race in the ''Star Wars'' universe * Assemblers, an alternative name of the superhero group Champions of ...
converts a
program Program, programme, programmer, or programming may refer to: Business and management * Program management, the process of managing several related projects * Time management * Program, a part of planning Arts and entertainment Audio * Progra ...
's
source code In computing, source code, or simply code, is any collection of code, with or without comments, written using a human-readable programming language, usually as plain text. The source code of a program is specially designed to facilitate the wo ...
(such as in C or
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
) to
machine code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very ...
and outputs it into a HEX file. Some also use it as a container format holding
packet Packet may refer to: * A small container or pouch ** Packet (container), a small single use container ** Cigarette packet ** Sugar packet * Network packet, a formatted unit of data carried by a packet-mode computer network * Packet radio, a form ...
s of stream data. Common file extensions used for the resulting files are .HEX or .H86. The HEX file is then read by a
programmer A computer programmer, sometimes referred to as a software developer, a software engineer, a programmer or a coder, is a person who creates computer programs — often for larger computer software. A programmer is someone who writes/creates ...
to write the machine code into a
PROM A promenade dance, commonly called a prom, is a dance party for high school students. It may be offered in semi-formal black tie or informal suit for boys, and evening gowns for girls. This event is typically held near the end of the school yea ...
or is transferred to the target system for loading and execution.


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 Five- and eight-hole punched paper tape Paper tape reader on the Harwell computer with a small piece of five-hole tape connected in a circle – creating a physical program loop Punched tape or perforated paper tape is a form of data storage ...
. It was also used to specify memory contents to Intel for ROM production. In 1973, Intel's "software group" consisted only of Bill Byerly and Ken Burget, and
Gary Kildall Gary Arlen Kildall (; May 19, 1942 â€“ July 11, 1994) was an American computer scientist and microcomputer entrepreneur. During the 1970s, Kildall created the CP/M operating system among other operating systems and programming tools, a ...
as an external consultant. Beginning in 1975, the format was utilized by MCS Series II ISIS-II systems, using the file extension HEX. Many
PROM A promenade dance, commonly called a prom, is a dance party for high school students. It may be offered in semi-formal black tie or informal suit for boys, and evening gowns for girls. This event is typically held near the end of the school yea ...
and
EPROM An EPROM (rarely EROM), or erasable programmable read-only memory, is a type of programmable read-only memory (PROM) chip that retains its data when its power supply is switched off. Computer memory that can retrieve stored data after a power s ...
programming devices accepted this format.


Format

Intel HEX consists of lines of
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
text that are separated by
line feed Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
or
carriage return A carriage return, sometimes known as a cartridge return and often shortened to CR, or return, is a control character or mechanism used to reset a device's position to the beginning of a line of text. It is closely associated with the line feed a ...
characters or both. Each text line contains
hexadecimal In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, hexa ...
characters that
encode The Encyclopedia of DNA Elements (ENCODE) is a public research project which aims to identify functional elements in the human genome. ENCODE also supports further biomedical research by "generating community resources of genomics data, software ...
multiple binary numbers. The binary numbers may represent data,
memory address In computing, a memory address is a reference to a specific memory location used at various levels by software and hardware. Memory addresses are fixed-length sequences of digits conventionally displayed and manipulated as unsigned integers. Su ...
es, 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
field Field may refer to: Expanses of open ground * Field (agriculture), an area of land used for agricultural purposes * Airfield, an aerodrome that lacks the infrastructure of an airport * Battlefield * Lawn, an area of mowed grass * Meadow, a grass ...
s (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. 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 table In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier (or symbols), constants, procedures and functions in a program's source code is associated with info ...
s or additional comments, and third-party extensions using other characters as start code like the digit '' by Keil, '' by
Mostek Mostek was a semiconductor integrated circuit manufacturer, founded in 1969 by L. J. Sevin, Louay E. Sharif, Richard L. Petritz and other ex-employees of Texas Instruments. At its peak in the late 1970s, Mostek held an 85% market share of the d ...
, or '', '', '', '', '' and '' by
TDL TDL may refer to: Businesses and organizations * Technical Design Labs, a former microcomputer- and software company * Texas Digital Library, a consortium of institutions * TDL Group, former company name of Tim Hortons Places * Tokyo Disneylan ...
. 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). 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 In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the most sig ...
values. # ''Record type'' (see
record type Record type is a family of typefaces designed to allow medieval manuscripts (specifically those from England) to be published as near-facsimiles of the originals. The typefaces include many special characters intended to replicate the various s ...
s 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 A checksum is a small-sized block of data derived from another block of digital data for the purpose of detecting errors that may have been introduced during its transmission or storage. By themselves, checksums are often used to verify data ...
'', 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 Two's complement is a mathematical operation to reversibly convert a positive binary number into a negative binary number with equivalent (but negative) value, using the binary digit with the greatest place value (the leftmost bit in big- endian ...
of the
least significant byte In computing, bit numbering is the convention used to identify the bit positions in a binary number. Bit significance and indexing In computing, the least significant bit (LSB) is the bit position in a binary integer representing the binar ...
(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 In mathematics, the additive inverse of a number is the number that, when added to , yields zero. This number is also known as the opposite (number), sign change, and negation. For a real number, it reverses its sign: the additive inverse (opp ...
— 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 Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lati ...
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 system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
s. For example, Linux programs use a single LF (
line feed Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in character encoding specifications such as ASCII, EBCDIC, Unicode, etc. This character, or a ...
, hex value 0A) character to terminate lines, whereas Windows programs use a CR (
carriage return A carriage return, sometimes known as a cartridge return and often shortened to CR, or return, is a control character or mechanism used to reset a device's position to the beginning of a line of text. It is closely associated with the line feed a ...
, 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 by Wayne and Layne, , , , and by the
BBC #REDIRECT BBC #REDIRECT BBC Here i going to introduce about the best teacher of my life b BALAJI sir. He is the precious gift that I got befor 2yrs . How has helped and thought all the concept and made my success in the 10th board exam. ...
...
/ Micro:bit Educational Foundation, and , , , , , , and by
Digital Research Digital Research, Inc. (DR or DRI) was a company created by Gary Kildall to market and develop his CP/M operating system and related 8-bit, 16-bit and 32-bit systems like MP/M, Concurrent DOS, FlexOS, Multiuser DOS, DOS Plus, DR DOS and ...
.


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 . It could include an optional header containing a
symbol table In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier (or symbols), constants, procedures and functions in a program's source code is associated with info ...
for
symbolic debugging A debug symbol is a special kind of Symbol (programming), symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable. This information allows a symbolic debugger to gain access to i ...
, 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 The 8086 (also called iAPX 86) is a 16-bit microprocessor chip designed by Intel between early 1976 and June 8, 1978, when it was released. The Intel 8088, released July 1, 1979, is a slightly modified chip with an external 8-bit data bus (allowi ...
/
8088 The Intel 8088 ("''eighty-eighty-eight''", also called iAPX 88) microprocessor is a variant of the Intel 8086. Introduced on June 1, 1979, the 8088 has an eight-bit external data bus instead of the 16-bit bus of the 8086. The 16-bit registers and ...
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 files use only record types and * I16HEX files use only record types through * I32HEX files use only record types , , , and


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 Digital Research, Inc. (DR or DRI) was a company created by Gary Kildall to market and develop his CP/M operating system and related 8-bit, 16-bit and 32-bit systems like MP/M, Concurrent DOS, FlexOS, Multiuser DOS, DOS Plus, DR DOS and ...
(as in the so-called "Digital Research hex format"),
Zilog Zilog, Inc. is an American manufacturer of microprocessors and 8-bit and 16-bit microcontrollers. It is also a supplier of application-specific embedded system-on-chip (SoC) products. Its most famous product is the Z80 series of 8-bit microp ...
,
Mostek Mostek was a semiconductor integrated circuit manufacturer, founded in 1969 by L. J. Sevin, Louay E. Sharif, Richard L. Petritz and other ex-employees of Texas Instruments. At its peak in the late 1970s, Mostek held an 85% market share of the d ...
,
TDL TDL may refer to: Businesses and organizations * Technical Design Labs, a former microcomputer- and software company * Texas Digital Library, a consortium of institutions * TDL Group, former company name of Tim Hortons Places * Tokyo Disneylan ...
,
Texas Instruments Texas Instruments Incorporated (TI) is an American technology company headquartered in Dallas, Texas, that designs and manufactures semiconductors and various integrated circuits, which it sells to electronics designers and manufacturers globall ...
,
Microchip An integrated circuit or monolithic integrated circuit (also referred to as an IC, a chip, or a microchip) is a set of electronic circuits on one small flat piece (or "chip") of semiconductor material, usually silicon. Large numbers of tiny ...
,
c't ''c't'' – ' (''Magazine for Computer Technology'') is a German computer magazine, published by the Heinz Heise, Heinz Heise publishing house. file:Ct jubilaeum 30 turm.jpg, The 5.71 meter high tower from the 587 published c't editions up to t ...
, Wayne and Layne, and
BBC #REDIRECT BBC #REDIRECT BBC Here i going to introduce about the best teacher of my life b BALAJI sir. He is the precious gift that I got befor 2yrs . How has helped and thought all the concept and made my success in the 10th board exam. ...
...
/ 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 The Motorola 6809 ("''sixty-eight-oh-nine''") is an 8-bit microprocessor with some 16-bit features. It was designed by Motorola's Terry Ritter and Joel Boney and introduced in 1978. Although source compatible with the earlier Motorola 6800, the 6 ...
) 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 microcontroller PIC (usually pronounced as ''"pick"'') is a family of microcontrollers made by Microchip Technology, derived from the PIC1650"PICmicro Family Tree", PIC16F Seminar Presentation originally developed by General Instrument's Microelectronics ...
s. 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.


See also

*
Binary-to-text encoding A binary-to-text encoding is encoding of data in plain text. More precisely, it is an encoding of binary data in a sequence of printable characters. These encodings are necessary for transmission of data when the channel does not allow binary dat ...
, a survey and comparison of encoding algorithms *
MOS Technology file format The MOS Technology file format is a file format that conveys binary information in ASCII text form. History The KIM-1 single-board computer specified a file format for magnetic tape and a format for paper tape. The paper tape format was ada ...
*
Motorola S-record hex format Motorola S-record is a file format, created by Motorola in the mid-1970s, that conveys binary information as hex values in ASCII text form. This file format may also be known as SRECORD, SREC, S19, S28, S37. It is commonly used for programmi ...
*
Tektronix hex format Tektronix hex format (TEK HEX) and Extended Tektronix hex format (EXT TEK HEX or XTEK) / Extended Tektronix Object Format are ASCII-based hexadecimal file formats, created by Tektronix, for conveying binary information for applications li ...


References


Further reading

* * * * {{cite book , title=The Telemark Assembler (TASM) User's Manual , chapter=Intel Hex Word Address Object Format , version=3.1 , date=February 1998 , author-first=Thomas N. , author-last=Anderson , publisher=Squak Valley Software , publication-place=Issaquah, Washington, USA , pages=25–26 , url=https://www.mikrocontroller.net/attachment/339967/TASMMAN.pdf , access-date=2021-12-11 , url-status=live , archive-url=https://web.archive.org/web/20211211145506/https://www.mikrocontroller.net/attachment/339967/TASMMAN.pdf , archive-date=2021-12-11 , quote=Intel Hex Word Address Object Format €¦This format is identical to the Intel Hex Object Format except that the address for each line of object code is divided by two thus converting it to a word address (16 bit word). All other fields are identical. Here is an example: €¦:180800000102030405060708090A0B0C0D0E0F101112131415161718AC €¦:02080C00191AA3 €¦:00000001FF €¦} (32 pages)


External links


binex
- a converter between Intel HEX and binary for Windows.
SRecord
a converter between Intel HEX and binary for Linux

, C++ source code.
kk_ihex
open source C library for reading and writing Intel HEX
libgis
open source C library that converts Intel HEX, Motorola S-Record, Atmel Generic files.
bincopy
is a Python package for manipulating Intel HEX files.
SwiftIntelHex
- a Swift package to parse Intel HEX files for iOS and macOS. Binary-to-text encoding formats Embedded systems Computer file formats