<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          很多人都不清楚HEX文件格式

          共 8503字,需瀏覽 18分鐘

           ·

          2020-10-26 00:45


          Intel HEX文件是由一行行符合Intel HEX文件格式的文本所構(gòu)成的ASCII文本文件。在Intel HEX文件中,每一行包含一個HEX記錄。這些記錄由對應(yīng)機(jī)器語言碼和/或常量數(shù)據(jù)的十六進(jìn)制編碼數(shù)字組成。Intel HEX文件通常用于傳輸將被存于ROM或者EPROM中的程序和數(shù)據(jù)。大多數(shù)EPROM編程器或模擬器使用Intel HEX文件。

          #HEX記錄格式

          Intel HEX由任意數(shù)量的十六進(jìn)制記錄組成。每個記錄包含5個域, 它們按以下格式排列[:LLAAAATT[DD…]CC]。每一組字母對應(yīng)一個不同的域, 每一個字母對應(yīng)一個十六進(jìn)制編碼的數(shù)字。每一個域由至少兩個十六進(jìn)制編碼數(shù)字組成, 它們構(gòu)成一個字節(jié)。

          詳細(xì)解釋如下:

          每個Intel HEX記錄都由冒號開頭。

          LL是數(shù)據(jù)長度域,它代表記錄當(dāng)中數(shù)據(jù)字節(jié)(dd)的數(shù)量。

          AAAA是地址域,它代表記錄當(dāng)中數(shù)據(jù)的起始地址。

          TT是代表HEX記錄類型的域,它可能是以下數(shù)據(jù)當(dāng)中的一個:

          00 – 數(shù)據(jù)記錄

          01 – 文件結(jié)束記錄

          02 – 擴(kuò)展段地址記錄

          04 – 擴(kuò)展線性地址記錄

          DD 是數(shù)據(jù)域,它代表一個字節(jié)的數(shù)據(jù)。一個記錄可以有許多數(shù)據(jù)字節(jié),記錄當(dāng)中數(shù)據(jù)字節(jié)的數(shù)量必須和數(shù)據(jù)長度域LL中指定的數(shù)字相符。

          CC是校驗(yàn)和域,它表示這個記錄的校驗(yàn)和。校驗(yàn)和的計算是通過將記錄當(dāng)中所有十六進(jìn)制編碼數(shù)字對的值相加,以256為模進(jìn)行以下補(bǔ)足。也就是說LLAAAATT[DD…]CC一共的校驗(yàn)和永遠(yuǎn)為0。

          #數(shù)據(jù)記錄格式

          Intel HEX文件由任意數(shù)量以回車換行符結(jié)束的數(shù)據(jù)記錄組成.

          數(shù)據(jù)記錄外觀如下:

          [:10246200464C5549442050524F46494C4500464C33]

          其中:

          10是這個記錄當(dāng)中數(shù)據(jù)字節(jié)的數(shù)量。

          2462 是數(shù)據(jù)將被下載到存儲器當(dāng)中的地址。

          00是記錄類型(數(shù)據(jù)記錄)。

          464C…464C是數(shù)據(jù)。

          33 是這個記錄的校驗(yàn)和的補(bǔ)足碼。

          #擴(kuò)展線性地址記錄(HEX386)格式

          擴(kuò)展線性地址記錄也叫作32位地址記錄或HEX386記錄。這些記錄包含數(shù)據(jù)地址的高16位。擴(kuò)展線性地址記錄總是有兩個數(shù)據(jù)字節(jié)。

          外觀如下:

          [:02000004FFFFFC]

          其中:

          02是這個記錄當(dāng)中數(shù)據(jù)字節(jié)的數(shù)量。

          0000是地址域,對于擴(kuò)展線性地址記錄,這個域總是0000。

          04是記錄類型 04(擴(kuò)展線性地址記錄)。

          FFFF是地址的高16位。

          FC是這個記錄的校驗(yàn)和的補(bǔ)足碼。

          當(dāng)一個擴(kuò)展線性地址記錄被讀取,存儲于數(shù)據(jù)域的擴(kuò)展線性地址被保存,它被應(yīng)用于從Intel HEX文件讀取來的隨后的記錄。線性地址保持有效,直到它被另外一個擴(kuò)展地址記錄所改變。

          通過把記錄當(dāng)中的地址域與被移位(16位)的來自擴(kuò)展線性地址記錄的地址數(shù)據(jù)相加獲得數(shù)據(jù)記錄的絕對存儲器地址。以下的例子演示了這個過程:

          來自數(shù)據(jù)記錄地址域的地址 ? ? ? ? ? ? ? ?2462 擴(kuò)展線性地址記錄的數(shù)據(jù)域*10000H ?+ ?FFFF0000 --------------------- 絕對存儲器地址 ? ? ? ? ? ? ? ? ? ? ?FFFF2462

          #擴(kuò)展段地址記錄(HEX86)

          擴(kuò)展段地址記錄也叫HEX86記錄,它包括4-19位數(shù)據(jù)地址段。擴(kuò)展段地址記錄總是有兩個數(shù)據(jù)字節(jié)。

          外觀如下:

          [:020000021200EA]

          其中:

          02 是記錄當(dāng)中數(shù)據(jù)字節(jié)的數(shù)量。

          0000是地址域,對于擴(kuò)展段地址記錄,這個域總是0000。

          02是記錄類型 02(擴(kuò)展段地址記錄)

          1200是地址段。

          EA是這個記錄的校驗(yàn)和的補(bǔ)足碼。

          當(dāng)一個擴(kuò)展段地址記錄被讀取,存儲于數(shù)據(jù)域的擴(kuò)展段地址被保存,它被應(yīng)用于從Intel HEX文件讀取來的隨后的記錄。段地址保持有效,直到它被另外一個擴(kuò)展地址記錄所改變。

          通過把記錄當(dāng)中的地址域與被移位(4位)的來自擴(kuò)展段地址記錄的地址數(shù)據(jù)相加獲得數(shù)據(jù)記錄的絕對存儲器地址。以下的例子演示了這個過程:來自數(shù)據(jù)記錄地址域的地址 ? ? ? ? 2462

          擴(kuò)展段地址記錄數(shù)據(jù)域*10H ? ?+ ? 12000 ----------------- 絕對存儲器地址 ? ? ? ? ? ? ? 00014462

          #文件結(jié)束(EOF)記錄。

          Intel HEX文件必須以文件結(jié)束(EOF)記錄結(jié)束。這個記錄的記錄類型域的值必須是01。EOF記錄外觀總是如下

          [:00000001FF]

          其中:

          00是記錄當(dāng)中數(shù)據(jù)字節(jié)的數(shù)量。

          0000是數(shù)據(jù)被下載到存儲器當(dāng)中的地址。在文件結(jié)束記錄當(dāng)中地址是沒有意義被忽略的。0000H是典型的地址。

          01是記錄類型01(文件結(jié)束記錄)

          FF是這個記錄的校驗(yàn)和的補(bǔ)足碼。

          #Intel HEX文件例子

          下面是一個完整的Intel HEX文件的例子:

          :10001300AC12AD13AE10AF1112002F8E0E8F0F2244
          :10000300E50B250DF509E50A350CF5081200132259
          :03000000020023D8
          :0C002300787FE4F6D8FD7581130200031D
          :10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016
          :04003F00A42EFE22CB
          :00000001FF

          看了這個例子,我自己也打開了之前寫的51單片機(jī)的hex文件:

          :2000000002000E75210675225B75230200267B007C00900090758140758901758CF1758A45
          :2000200028D28C75A882758CF1758A280BBBFA157B00EC75F00A8485F020F5210CBC64027A
          :200040007C00120051C0E0C0D0120051D0D0D0E032E52193F580D2A2C2A27580FED2A3C29C
          :20006000A3120087E52093F580D2A2C2A27580FDD2A3C2A3120087227D327E287FF81151AA
          :1A008000DFFEDEF8DDF4227E047FF8DFFEDEFA223F065B4F666D7D077F6FBC
          :00000001FF

          #英文原文

          QUESTION:What?is?the?Intel?HEX?file?format?
          ANSWER:
          8.1?The?Intel?HEX?file?is?an?ASCII?text?file?with?lines?of?text?that?follow?theIntel?HEX?file?format.?Each?line?in?an?Intel?HEX?file?contains?one?HEX?record.These?records?are?made?up?of?hexadecimal?numbers?that?represent?machine?language?code?and/or?constant?data.?Intel?HEX?files?are?often?used?to?transfer?the?program?and?data?that?would?be?stored?in?a?ROM?or?EPROM.?Most?EPROM?programmers?or?emulators?can?use?Intel?HEX?files.
          8.2?Record?Format.
          An?Intel?HEX?file?is?composed?of?any?number?of?HEX?records.?Each?record?is?made?up?of?five?fields?that?are?arranged?in?the?following?format:
          :LLAAAATT[DD…]CC
          Each?group?of?letters?corresponds?to?a?different?field,?and?each?letter?represents?a?single?hexadecimal?digit.?Each?field?is?composed?of?at?least?two?hexadecimal?digits-which?make?up?a?byte-as?described?below:
          8.2.1?:?is?the?colon?that?starts?every?Intel?HEX?record.
          8.2.2?LL?is?the?record-length?field?that?represents?the?number?of?data?bytes?(dd)?in?the?record.
          8.2.3?AAAA?is?the?address?field?that?represents?the?starting?address?for?subsequent?data?in?the?record.
          8.2.4?TT?is?the?field?that?represents?the?HEX?record?type,?which?may?be?one?of?the?following:
          8.2.4.1?00?-?data?record
          8.2.4.2?01?-?end-of-file?record
          8.2.4.3?02?-?extended?segment?address?record
          8.2.4.4?04?-?extended?linear?address?record
          8.2.5?DD?is?a?data?field?that?represents?one?byte?of?data.?A?record?may?have?multiple?data?bytes.?The?number?of?data?bytes?in?the?record?must?match?the?number?specified?by?the?ll?field.
          8.2.6?CC?is?the?checksum?field?that?represents?the?checksum?of?the?record.?The?checksum?is?calculated?by?summing?the?values?of?all?hexadecimal?digit?pairs?in?the?record?modulo?256?and?taking?the?two's?complement.
          8.3?Data?Records.
          The?Intel?HEX?file?is?made?up?of?any?number?of?data?records?that?are?terminated?with?a?carriage?return?and?a?linefeed.?Data?records?appear?as?follows:
          :10246200464C5549442050524F46494C4500464C33
          where:
          8.3.1?10?is?the?number?of?data?bytes?in?the?record.
          8.3.2?2462?is?the?address?where?the?data?are?to?be?located?in?memory.
          8.3.3?00?is?the?record?type?00?(a?data?record).
          8.3.4?464C...464C?is?the?data.
          8.3.5?33?is?the?checksum?of?the?record.
          8.4?Extended?Linear?Address?Records?(HEX386).
          Extended?linear?address?records?are?also?known?as?32-bit?address?records?and?HEX386?records.?These?records?contain?the?upper?16?bits?(bits?16-31)?of?the?data?address.?The?extended?linear?address?record?always?has?two?data?bytes?and?appears?as?follows:
          :02000004FFFFFC
          where:
          8.4.1?02?is?the?number?of?data?bytes?in?the?record.
          8.4.2?0000?is?the?address?field.?For?the?extended?linear?address?record,?this?field?is?always?0000.
          8.4.3?04?is?the?record?type?04?(an?extended?linear?address?record).
          8.4.4?FFFF?is?the?upper?16?bits?of?the?address.
          8.4.5?FC?is?the?checksum?of?the?record?and?is?calculated?as?01h?+?NOT(02h?+?00h?+?00h?+?04h?+?FFh?+?FFh).
          8.4.6?When?an?extended?linear?address?record?is?read,?the?extended?linear?address?stored?in?the?data?field?is?saved?and?is?applied?to?subsequent?records?read?from?the?Intel?HEX?file.?The?linear?address?remains?effective?until?changed?by?another?extended?address?record.
          8.4.7?The?absolute-memory?address?of?a?data?record?is?obtained?by?adding?the?address?field?in?the?record?to?the?shifted?address?data?from?the?extended?linear?address?record.?The?following?example?illustrates?this?process..
          Address?from?the?data?record'
          s?address?field??????2462

          Extended?linear?address?record?data?field?????FFFF
          ??????????????????????????????????????-----------
          Absolute-memory?address?????????????????FFFF2462
          8.5?Extended?Segment?Address?Records?(HEX86).
          Extended?segment?address?records-also?known?as?HEX86?records-contain?bits?4-19
          of?the?data?address?segment.?The?extended?segment?address?record?always?has?two
          data?bytes?and?appears?as?follows:
          :020000021200EA
          where:
          8.5.1?02?is?the?number?of?data?bytes?in?the?record.
          8.5.2?0000?is?the?address?field.?For?the?extended?segment?address?record,?this?field?is?always?0000.
          8.5.3?02?is?the?record?type?02?(an?extended?segment?address?record).
          8.5.4?1200?is?the?segment?of?the?address.
          8.5.5?EA?is?the?checksum?of?the?record?and?is?calculated?as?01h?+?NOT(02h?+?00h?+?00h?+?02h?+?12h?+?00h).
          8.5.6?When?an?extended?segment?address?record?is?read,?the?extended?segment?addressstored?in?the?data?field?is?saved?and?is?applied?to?subsequent?records?read?from?the?Intel?HEX?file.?The?segment?address?remains?effective?until?changed?by?another?extended?address?record.
          8.5.7?The?absolute-memory?address?of?a?data?record?is?obtained?by?adding?the?addressfield?in?the?record?to?the?shifted-address?data?from?the?extended?segment?address?record.?The?following?example?illustrates?this?process.
          Address?from?the?data?record's?address?field???????2462
          Extended?segment?address?record?data?field??????1200
          ?????????????????????????????????????????--------
          Absolute?memory?address?????????????????00014462
          8.6?End-of-File?(EOF)?Records.
          An?Intel?HEX?file?must?end?with?an?end-of-file?(EOF)?record.?This?record?must?have?the?value?01?in?the?record?type?field.?An?EOF?record?always?appears?as?follows:
          :00000001FF
          where:
          8.6.1?00?is?the?number?of?data?bytes?in?the?record.
          8.6.2?0000?is?the?address?where?the?data?are?to?be?located?in?memory.?The?address?in?end-of-file?records?is?meaningless?and?is?ignored.?An?address?of?0000h?is?typical.
          8.6.3?01?is?the?record?type?01?(an?end-of-file?record).
          8.6.4?FF?is?the?checksum?of?the?record?and?is?calculated?as?01h?+?NOT(00h?+?00h?+?00h?+?01h).
          8.7?Example?Intel?HEX?File.
          Following?is?an?example?of?a?complete?Intel?HEX?file:
          :10001300AC12AD13AE10AF1112002F8E0E8F0F2244
          :10000300E50B250DF509E50A350CF5081200132259
          :03000000020023D8
          :0C002300787FE4F6D8FD7581130200031D
          :10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016
          :04003F00A42EFE22CB
          :00000001FF



          #推薦閱讀:
          ? ??專輯|Linux文章匯總
          ? ??專輯|程序人生
          ? ??專輯|C語言


          嵌入式Linux
          微信掃描二維碼,關(guān)注我的公眾號?
          瀏覽 74
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  青娱乐青青草视频在线观看 | 国产精品久久777777换脸 | 久9热| 91丨九色丨国产在线 | 美女操逼免费看 |