HEX file format

Hex files have much the same properties as Binary files. All bytes of the file are placed one after the other. No address information or checksums are added. The only difference with the Binary file format is that each byte is converted to 2 ASCII characters in the range 0..9 and A..F, representing the 2 hex digits (nibbles). These characters are grouped on lines. The number of nibble pairs on a line can usually range from 1 to 255, where 16 or 32 pairs are the most common line lengths. Each line is terminated by a CR (ASCII value $0D), an LF (ASCII value $0A) or a CRLF pair (ASCII values $0D,$0A), depending on the OS in use.. This termination may come on any byte boundary, so there must always be an even number of nibble characters on each line. The end of file may be indicated by the EOF character (ASCII value $1A), but this not mandatory.
Unix like file systems will only use LF code to terminate each line. They also don't add an end of file character at the end of the file, and if they do it's going to be $04 (Ctrl-D).

No address information or checksums are added to the file. The receiving program, e.g. the loader, must know at what address to store the Hex data. It is not possible to skip unused portions of memory because no address information is present. Unused portions must be filled with dummy values, unless the unused portion is at the end of the file.



In this example there are 16 bytes (32 nibbles) on each line. Each line is terminated by an End Of Line indicator (may be CR, LF or both). At the end of the file you see the code <EOF>, which is OS dependent ($04 or $1A) and may even not be there at all..