搜索“hexformat.pdf”
RecordFormat
AnIntelHEXfileiscomposedofanynumberofHEXrecords.Eachrecordismade
upoffivefieldsthatarearrangedinthefollowingformat:
:llaaaatt[dd...]cc
Eachgroupofletterscorrespondstoadifferentfield,andeachletter
representsasinglehexadecimaldigit.Eachfieldiscomposedofatleasttwo
hexadecimaldigits-whichmakeupabyte-asdescribedbelow:
:isthecolonthatstartseveryIntelHEXrecord.
llistherecord-lengthfieldthatrepresentsthenumberofdatabytes(dd)in
therecord.
aaaaistheaddressfieldthatrepresentsthestartingaddressforsubsequent
dataintherecord.
ttisthefieldthatrepresentstheHEXrecordtype,whichmaybeoneofthe
following:
00-datarecord
01-end-of-filerecord
02-extendedsegmentaddressrecord
04-extendedlinearaddressrecord
ddisadatafieldthatrepresentsonebyteofdata.Arecordmayhavemultiple
databytes.Thenumberofdatabytesintherecordmustmatchthenumber
specifiedbythellfield.
ccisthechecksumfieldthatrepresentsthechecksumoftherecord.The
checksumiscalculatedbysummingthevaluesofallhexadecimaldigitpairsin
therecordmodulo256andtakingthetwo'scomplement.
DataRecords
TheIntelHEXfileismadeupofanynumberofdatarecordsthatareterminated
withacarriagereturnandalinefeed.Datarecordsappearasfollows:
:10246200464C5549442050524F46494C4500464C33
where:
10isthenumberofdatabytesintherecord.
2462istheaddresswherethedataaretobelocatedinmemory.
00istherecordtype00(adatarecord).
464C...464Cisthedata.
33isthechecksumoftherecord.
ExtendedLinearAddressRecords(HEX386)
Extendedlinearaddressrecordsarealsoknownas32-bitaddressrecordsand
HEX386records.Theserecordscontaintheupper16bits(bits16-31)ofthe
dataaddress.Theextendedlinearaddressrecordalwayshastwodatabytesand
appearsasfollows:
:02000004FFFFFC
where:
02isthenumberofdatabytesintherecord.
0000istheaddressfield.Fortheextendedlinearaddressrecord,thisfield
isalways0000.
04istherecordtype04(anextendedlinearaddressrecord).
FFFFistheupper16bitsoftheaddress.
FCisthechecksumoftherecordandiscalculatedas
01h+NOT(02h+00h+00h+04h+FFh+FFh).
Whenanextendedlinearaddressrecordisread,theextendedlinearaddress
storedinthedatafieldissavedandisappliedtosubsequentrecordsread
fromtheIntelHEXfile.Thelinearaddressremainseffectiveuntilchangedby
anotherextendedaddressrecord.
Theabsolute-memoryaddressofadatarecordisobtainedbyaddingtheaddress
fieldintherecordtotheshiftedaddressdatafromtheextendedlinear
addressrecord.Thefollowingexampleillustratesthisprocess..
Addressfromthedatarecord'saddressfield2462
ExtendedlinearaddressrecorddatafieldFFFF
--------
Absolute-memoryaddressFFFF2462
ExtendedSegmentAddressRecords(HEX86)
Extendedsegmentaddressrecords-alsoknownasHEX86records-containbits4-19
ofthedataaddresssegment.Theextendedsegmentaddressrecordalwayshastwo
databytesandappearsasfollows:
:020000021200EA
where:
02isthenumberofdatabytesintherecord.
0000istheaddressfield.Fortheextendedsegmentaddressrecord,thisfield
isalways0000.
02istherecordtype02(anextendedsegmentaddressrecord).
1200isthesegmentoftheaddress.
EAisthechecksumoftherecordandiscalculatedas
01h+NOT(02h+00h+00h+02h+12h+00h).
Whenanextendedsegmentaddressrecordisread,theextendedsegmentaddress
storedinthedatafieldissavedandisappliedtosubsequentrecordsread
fromtheIntelHEXfile.Thesegmentaddressremainseffectiveuntilchangedby
anotherextendedaddressrecord.
Theabsolute-memoryaddressofadatarecordisobtainedbyaddingtheaddress
fieldintherecordtotheshifted-addressdatafromtheextendedsegment
addressrecord.Thefollowingexampleillustratesthisprocess.
Addressfromthedatarecord'saddressfield2462
Extendedsegmentaddressrecorddatafield1200
--------
Absolutememoryaddress00014462
End-of-File(EOF)Records
AnIntelHEXfilemustendwithanend-of-file(EOF)record.Thisrecordmust
havethevalue01intherecordtypefield.AnEOFrecordalwaysappearsas
follows:
:00000001FF
where:
00isthenumberofdatabytesintherecord.
0000istheaddresswherethedataaretobelocatedinmemory.Theaddressin
end-of-filerecordsismeaninglessandisignored.Anaddressof0000his
typical.
01istherecordtype01(anend-of-filerecord).
FFisthechecksumoftherecordandiscalculatedas
01h+NOT(00h+00h+00h+01h).
ExampleIntelHEXFile
FollowingisanexampleofacompleteIntelHEXfile:
:10001300AC12AD13AE10AF1112002F8E0E8F0F2244
:10000300E50B250DF509E50A350CF5081200132259
:03000000020023D8
:0C002300787FE4F6D8FD7581130200031D
:10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016
:04003F00A42EFE22CB
:00000001FF
|