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 like programming microcontrollers, EPROMs, and other kinds of chips.

Each line of a Tektronix hex file starts with a slash (/) character, whereas extended Tektronix hex files start with a percent (%) character.

Tektronix hex format
A line consists of four parts, excluding the initial '/' character:
 * 1) Address — 4 character (2 byte) field containing the address where the data is to be loaded into memory. This limits the address to a maximum value of FFFF16.
 * 2) Byte count — 2 character (1 byte) field containing the length of the data fields.
 * 3) Prefix checksum — 2 character (1 byte) field containing the checksum of the prefix. The prefix checksum is the 8-bit sum of the four-bit hexadecimal value of the six digits that make up the address and byte count.
 * 4) Data— contains the data to be transferred, followed by a 2 character (1 byte) checksum. The data checksum is the 8-bit sum, modulo 256, of the 4-bit hexadecimal values of the digits that make up the data bytes.

Extended Tektronix hex format
A line consists of five parts, excluding the initial '%' character:


 * 1) Record Length — 2 character (1 byte) field  that specifies the number of characters (not bytes) in the record, excluding the percent sign.
 * 2) Type — 1 character field, specifies whether the record is data (6) or termination (8). (6 record contains data, placed at the address specified. 8 termination record: The address field may optionally contain the address of the instruction to which control is passed; there is no data field.)
 * 3) Checksum — 2 hex digits (1 byte, represents the sum of all the nibbles on the line, excluding the checksum itself.
 * 4) Address — 2 to N character field. The first character is how many characters are to follow for this field. The remaining characters contains the address that specifies where the data is to be loaded into memory. For example, if the first character is 8, then the following 8 characters should specify the address for a total of 9 characters in this field.
 * 5) Data — contains the executable code, memory-loadable data or descriptive information to be transferred.