Formato de arquivo hexadecimal

Hexadecimal file format

Intel hex (ihex) generally known as hexadecimal file , is a format used to store machine language code in hexadecimal format. It is a widely used format for storing programs to be transferred to microcontrollers, ROM and EEPROM. Compilers convert programs written in assembly, C, etc. into corresponding hex files, which are dumped into controllers using recorders/programmers. This article explores the details of the hexadecimal file format .
The microcontroller understands machine language that consists of zeros and ones. It is difficult and practically impossible for humans to write code in zeros and ones. Therefore, we use some high-level languages ​​like C, C++, Java, etc. And later a compiler is used to convert these codes into machine language which are stored in a hexadecimal file format . A hexadecimal file is a text file with a .hex extension.
Imagem de um arquivo hexadecimal mostrado como texto

Figure 1: Image of a hex file shown as text

The image above shows a typical hexadecimal file when opened with Notepad or any other text editor. Each line follows a specific structure explained below.
: CC YYYY TT XXXXX……XX SS
Example:

: 10 0000 00 0C942A000C9434000C9434000C943400 AA

1. Each line in a hexadecimal file always starts with a colon ( : )
two. The first two digits CC (character count) represent the total number of bytes of data in that line. Here in this example, 10 (hexadecimal) are the first two digits, which means there are 16 bytes (in decimal) of data in the line.
3. The next four digits represent the starting memory address where the data stored in the row needs to be dumped. 4. After the address, the next two digits represent whether this is the last line of the code or not. TT=0 means the code is not complete and there are more lines after this line and TT=1 means this is the last line of the code.
5. XXXX…..XX are the bytes of data that must be dumped into memory. The number of bytes of data in a specific line is equal to the number indicated by the character count (CC) digits.
6. SS is the checksum byte for that line.
Hex file is a text file so you can easily change the content of a hex file. The corrupted line can be identified using the checksum (SS) byte.

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.