16.1.1 Input/Output Files
- Input: ELF formatted binary object files.
- Output: Intel hex files.
Because the Intel hex file format is byte-oriented, and the DSC program counter (PC) is not, program memory sections require special treatment. Each 24-bit program word is extended to 32 bits by inserting a so-called “phantom byte.” Each program memory address is multiplied by 2 to yield a byte address.
For example, a section that is located at 0x100 in program memory will be represented in the hex file as 0x200. Consider the following assembly language source:
; file test.s
.section foo,code,address(0x100)
.pword 0x112233
The following commands will assemble the source file and create an Intel hex file:
xc-dsc-as -o test.o test.s
xc-dsc-bin2hex test.o
The file test.hex will be produced, with the following contents:
:020000040000fa
:040200003322110096
:00000001FF
Notice that the data record (line 2) has a load address of 0200, while the source code specified address 0x100. Note also that the data is represented in “little-endian” format, meaning the least significant byte appears first. The phantom byte appears last, just before the checksum.