Back Home

Navigation

Home
Knowledge Base

Binary format
HEX format
Intel HEX format
Motorola Sxx rec
FPC format
MOS Technology
Signetics format
Tektronix format
EMON52 format


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) or CRLF pair (ASCII values $0D,$0A). 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 is indicated by the EOF character (ASCII value $1A).

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.

Example

576F77212044696420796F7520726561<cr><lf>
6C6C7920676F207468726F7567682061<cr><lf>
6C6C20746869732074726F75626C6520<cr><lf>
746F2072656164207468697320737472<cr><lf>
7696E673<cr><lf>
<eof>

In this example there are 16 bytes (32 nibbles) on each line. Each line is terminated by a CRLF pair. In reality <cr><lf> is translated to ASCII codes $0D and $0A. At the end of the file you see the code <eof>, which is in fact ASCII code $1A.

 

© 2001, San Bergmans, Oisterwijk, The Netherlands
http://www.sbprojects.com