什么是 Intel HEX 文件格式   转自:http://www.cnblogs.com/imapla/archive/2013/03/16/2926133.html
Intel HEX 文件是遵循 Intel HEX 文件格式的 ASCII 文本文件。在 Intel HEX 文件的每一行都包含了一个 HEX 记录。这些记录是由一些代表机器语言代码和常量的16进制数据组成的。Intel HEX 文件常用来传输要存储在 ROM 或者 EPROM 中的程序和数据。大部分的 EPROM 编程器能使用 Intel HEX 文件。

Intel HEX由任意数量的十六进制记录组成。每个记录包含5个域,它们按以下格式排列:

Start Code  每个 Intel HEX 记录都由冒号开头
Byte count 是数据长度域,它代表记录当中数据字节的数量
Address 是地址域,它代表记录当中数据的起始地址
Record type 是代表HEX记录类型的域,它可能是以下数据当中的一个:
  00-数据记录
  01-文件结束记录
  02-扩展段地址记录
  03-开始段地址记录
  04-扩展线性地址记录
  05-开始线性地址记录
Data 是数据域,一个记录可以有许多数据字节.记录当中数据字节的数量必须和数据长度域中指定的数字相符
Checksum 是校验和域,它表示这个记录的校验和.校验和的计算是通过将记录当中所有十六进制编码数字对的值相加,以256为模进行以下补足。

详见:http://en.wikipedia.org/wiki/Intel_HEX

The format is a text file, with each line containing hexadecimal values encoding a sequence of data and their starting offset or absolute address.

Each line of Intel HEX file consists of six parts:

    1. Start code, one character, an ASCII colon ':'.
    2. Byte count, two hex digits, a number of bytes (hex digit pairs) in the data field. 16 (0x10) or 32 (0x20) bytes of data are the usual compromise values between line length and address overhead.
    3. Address, four hex digits, a 16-bit address of the beginning of the memory position for the data. Limited to 64 kilobytes, the limit is worked around by specifying higher bits via additional record types. This address is big endian.
    4. Record type, two hex digits, 00 to 05, defining the type of the data field.
    5. Data, a sequence of n bytes of the data themselves, represented by 2n hex digits.
    6. Checksum, two hex digits - the least significant byte of the two's complement of the sum of the values of all fields except fields 1 and 6 (Start code ":" byte and two hex digits of the Checksum). It is calculated by adding together the hex-encoded bytes (hex digit pairs), then leaving only the least significant byte of the result, and making a 2's complement (either by subtracting the byte from 0x100, or inverting it by XOR-ing with 0xFF and adding 0x01). If you are not working with 8-bit variables, you must suppress the overflow by AND-ing the result with 0xFF. The overflow may occur since both 0x100-0 and (0x00 XOR 0xFF)+1 equal 0x100. If the checksum is correctly calculated, adding all the bytes (the Byte count, both bytes in Address, the Record type, each Data byte and the Checksum) together will always result in a value wherein the least significant byte is zero (0x00).
      For example, on :0300300002337A1E
      03 + 00 + 30 + 00 + 02 + 33 + 7A = E2, 2's complement is 1E

There are six record types:

    • 00data record, contains data and 16-bit address. The format described above.
    • 01End Of File record. Must occur exactly once per file in the last line of the file. The byte count is 00 and the data field is empty. Usually the address field is also 0000, in which case the complete line is ':00000001FF'. Originally the End Of File record could contain a start address for the program being loaded, e.g. :00AB2F0125 would cause a jump to address AB2F. This was convenient when programs were loaded from punched paper tape.
    • 02Extended Segment Address Record, segment-base address (two hex digit pairs in big endian order). Used when 16 bits are not enough, identical to 80x86 real mode addressing. The address specified by the data field of the most recent 02 record is multiplied by 16 (shifted 4 bits left) and added to the subsequent data record addresses. This allows addressing of up to a megabyte of address space. The address field of this record has to be 0000, the byte count is 02 (the segment is 16-bit). The least significant hex digit of the segment address is always 0.
    • 03Start Segment Address Record. For 80x86 processors, it specifies the initial content of the CS:IP registers. The address field is 0000, the byte count is 04, the first two bytes are the CS value, the latter two are the IP value.
    • 04Extended 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.
    • 05Start Linear Address Record. The address field is 0000, the byte count is 04. The 4 data bytes represent the 32-bit value loaded into the EIP register of the 80386 and higher CPU.

如何读懂 Intel HEX 文件的更多相关文章

  1. Intel HEX文件解析

    近期有一个需求就是为Arduino开发板做一个基于蓝牙的无线烧录程序.眼下的Arduino程序都是通过USB线连接到电脑的主机上,实际的传输过程是基于USB协议的,这个过程还是比較麻烦的.由于每次的编 ...

  2. 读懂CCS链接命令文件(.cmd)

    链接器的核心工作就是符号表解析和重定位,链接命令文件则使得编程者可以给链接器提供必要的指导和辅助信息.多数时候,由于集成开发环境的存在,开发者无需了解链接命令文件的编写,使用默认配置即可.但若需要对计 ...

  3. Intel HEX格式

    来来 !! come baby  !  只强调一点这篇文章有checksum的算法,是我最喜欢地!! 参考:https://blog.csdn.net/extlife/article/details/ ...

  4. 【转】Intel HEX介绍

    记录格式 Intel HEX由任意数量的十六进制记录组成.每个记录包含5个域,它们按以下格式排列: :llaaaatt[dd...]cc 每一组字母对应一个不同的域,每一个字母对应一个十六进制编码的数 ...

  5. Intel hex 文件格式解密

    Intel hex 文件常用来保存单片机或其他处理器的目标程序代码.它保存物理程序存储区中的目标代码映象.一般的编程器都支持这种格式. Intel hex 文件全部由可打印的ASCII字符组成(可以用 ...

  6. Hex文件

    那么什么是Hex文件呢?Intel Hex文件是由一行行符合Intel Hex文件格式的文本所构成的ASCII文本文件.在Intel Hex文件中,每一行包含一个Hex记录.这些记录由对应机器语言码和 ...

  7. 【转】单片机HEX文件完全解读

    转:http://www.eefocus.com/craftor/blog/10-07/193051_8ce59.html Craftor原创,首发于与非网,转载请保留此处. HEX文件,是Intel ...

  8. 一文读懂Redis持久化

    Redis 是一个开源( BSD 许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存和消息中间件.它支持的数据类型很丰富,如字符串.链表.集合.以及散列等,并且还支持多种排序功能. 什么叫持久 ...

  9. 解析.DBC文件, 读懂CAN通信矩阵,实现车内信号仿真

    通常我们拿到某个ECU的通信矩阵数据库文件,.dbc后缀名的文件. 直接使用CANdb++ Editor打开,可以很直观的读懂信号矩阵的信息,例如下图: 现在要把上图呈现的信号从.dbc文件中解析出来 ...

随机推荐

  1. 在ubunut下使用pycharm和eclipse进行python远程调试

    我比较喜欢Pycharm,因为这个是JetBrains公司出的python IDE工具,该公司下的java IDE工具--IDEA,无论从界面还是操作上都甩eclipse几条街,但项目组里有些人使用e ...

  2. Screen对象

    document.write("Screen-width:"+screen.width+"Screen-height:"+screen.height);docu ...

  3. 生成1~n的全排列

    输入正整数n,输出n的全排列. 样例输入1: 3 样例输出1: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 分析: 按字典序从小到大的顺序输出所有的排列. (字典序:两个序 ...

  4. String性能优化

    String 使用的优化建议 其他 String 使用的优化建议 以上我们描述了在我们的大量文本分析案例中调用 String 的 subString方法导致内存消耗的问题,下面再列举一些其他将导致内存 ...

  5. ACM - 概率、期望题目 小结(临时)

    概率DP求期望大多数都是全期望公式的运用.主要思考状态空间的划分以及状态事件发生的概率.问题可以分为无环和有环两类.无环一类多数比较简单,可以通过迭代或者记忆化搜索完成.有环一类略复杂,可以通过假设方 ...

  6. CGAffineTransformMakeTranslation和CGAffineTransformTranslate

    分类: ios基础2013-01-06 22:05 15513人阅读 评论(2) 收藏 举报 1.CGAffineTransformMakeTranslation每次都是以最初位置的中心点为起始参照 ...

  7. select multiple images in Android Gallery

    http://stackoverflow.com/questions/18520976/all-properties-of-intent-putextra-to-crop-image-in-andro ...

  8. ERP权限设置和CRM分析 (十二)

    个人信息管理: 需求描述: 1.在权限信息表添加一条个人信息修改权限. 2.在TreeMenu表添加一条数据作为个"人信息修改"菜单. 3. 人事登记人员在登记员工信息的时候,自动 ...

  9. 20145210 《Java程序设计》第一周学习总结

    教材学习内容总结 第一章: 1.Java三大平台,JavaSE的四个组成部分 Java根据应用领域的不同,区分为Java SE.Java EE.Java ME三大平台. 各应用平台的基础:Java S ...

  10. 【转发】构建高可伸缩性的WEB交互式系统(下)

    原文转自:http://kb.cnblogs.com/page/504518/ 本文是<构建高可伸缩性的WEB交互式系统>系列文章的第三篇,以网易的NEJ框架为例,对模块的可伸缩性进行分析 ...