I am trying to make a bootloader for PIC18 so I need to understand how to process a hex file correctly. For example I understand what to do with the following hex line.
:040C0000E2EFFFF030
04
: number of bytes
0C00
: Address of hex digits
00
: Data records
E2EFFFF0
: Sequence of data
30
: Checksum
so I would know what to do with the above line, but how about the following hex line.
:020000040001F9
02
: # of bytes
0000
: Address
04
: Extended Linear Address Record
0001
: data
F9
: Checksum
But what exactly do I do with it? Am I writing those data to that address? Can you translate it to machine language?
By the way my application program starts at address 0c00
and bootloader starts at address 0020
, and above it, is the interrupt vector. Thanks!
Update
If the third line of hex file was the following, would the address FFC0
change ?
:10FFC000FF00FF00FF00FF00FF00FF000001E9EF5E
I am thinking since the second line of hex file has 04
(Extended Linear Address Record), then I should add 0001
to the address of the third line FFC0
, so the new address would be like this.
$0001 + $FFC0
will equal 1FFC0
, so the next set of data bytes from line 3 should be written to this address 1FFC0
, is this correct ?
From wikipedia Intel Hex (the obvious source for such informations)
04, Extended Linear Address Record, allowing for fully 32 bit addressing (up to 4GiB). The address field is 0000, the byte count is 02. The two data bytes (two hex digit pairs in big endian order) represent the upper 16 bits of the 32 bit address for all subsequent 00 type records until the next 04 type record comes. If there is not a 04 type record, the upper 16 bits default to 0000. To get the absolute address for subsequent 00 type records, the address specified by the data field of the most recent 04 record is added to the 00 record addresses.
So the formula is (linAddr <<16) + addr
or in your case ($0001 << 16) + $FFC0
And for the case of 02/Extended Segment Address Record, the formula changed to(segAddr << 4) + addr
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With