Appendix E

Specification of the Intel-HEX Format

This object file format is supported by many cross assemblers, utilities, and most EPROM programmers.
An Intel-HEX file is a 7-bit ASCII text file, that contains a sequence of data records and an end record. Every record is a line of text that starts with a colon and ends with CR and LF.
Data records contain up to 16 data bytes, a 16-bit load address, a record type byte and an 8-bit checksum. All numbers are represented by upper case ASCII-hex characters.

DATA RECORD:
    Byte 1               colon (:)
         2 and 3         number of binary data bytes for this record
         4 and 5         load address for this record, high byte
         6 and 7         load address for this record,  low byte
         8 and 9         record type: 00  (data record)
        10 to  x         data bytes, two characters each
       x+1 to  x+2       checksum (two characters)
       x+3 to  x+4       CR and LF
A typical data record looks like
:10E0000002E003E4F588758910F58DF58BD28E302A

The end record is the last line of the file.
In principle it is structured like a data record, but the number of data bytes is 00, the record type is 01 and the load-address field is 0000.

END RECORD:
    Byte 1               colon (:)
         2 and 3         00   (number of data bytes)
         4 and 5         00   (load address, high byte)
         6 and 7         00   (load address, low byte)
         8 and 9         record type: 01  (end record)
        10 and 11        checksum (two characters)
        12 and 13        CR and LF
The typical END record looks like
:00000001FF

The checksum is the two's complement of the 8-bit sum, without carry, of the byte count, the two load address bytes, the record type byte and all data bytes.