HEX files are plain text. Every line begins with a 9-character header and ends with a 2-character hexadecimal checksum, with the actual data (in hexadecimal) in the middle.
:NNAAAATT......CC (format)
:1001F000......3E (example)
- NN represents the number of bytes in the record (not including the header & checksum)
- AAAA is the lower 16 bits of the data address
- TT is the Record Type, which I'll get to in a second.
- CC is the least-significant byte of the checksum
- ....... is NN bytes of data
The total number of characters on each line is (1 + 2*4 + 2*NN + 2) = (11 + 2*NN)
TT, the Record Type, is
00 for a general record.
TT = 01 for End-Of-File. The line with this record type is always
:00000001FF and is always the last line in the file.
TT = 04 for Extended Address. This line sets the upper 16 bits of the data address for all following records. As such, the first line in the file is usually
:020000040000FA to zero the high word of the address.
The checksum is the two's complement, of the lowest byte, of the sum of all preceding bytes in the line (including the 4 header bytes). In other words, taking an 8-bit sum of every byte on the line (including the checksum) should always give you
0.
I think that's everything... Let me know if this helps.