今日在调试过程中,需要将单片机中的sram保存,或者将flash的数据加载,这时需要在keil调试界面中,使用save和load两个命令,官网有说明http://www.keil.com/support/man/docs/uv4/uv4_debug_commands.htm
今天调试的时,就用到了save指令,指令的用法比如,save a.txt 0x0,0x1000,其实a.txt里面显示的是hex格式的,那么就需要理解hex格式的定义,网上也比较好的文章。
load指令没有使用过,暂时保留,未来遇到了,在添加吧。
hex格式在keil官网也有https://www.keil.com/support/docs/1584/
Information in this article applies to:
What is the Intel HEX file format?
The Intel HEX file is an ASCII text file with lines of text that follow the Intel 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.
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:
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
This record is decoded as follows:
:10246200464C5549442050524F46494C4500464C33 ||||||||||| CC->Checksum |||||||||DD->Data |||||||TT->Record Type |||AAAA->Address |LL->Record Length :->Colon
where:
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:
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.
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
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:
When an extended segment address record is read, the extended segment address stored 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.
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 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
Start linear address records specify the start address of the application. These records contain the full linear 32 bit address. The start linear address record always has four data bytes and appears as follows:
:04000005000000CD2A
where:
The Start Linear Address specifies the address of the __main (pre-main) function but not the address of the startup code which usually calls __main after calling SystemInit(). An odd linear start address specifies that __main is compiled for the Thumb instruction set.
The Start Linear Address Record can appear anywhere in hex file. In most cases this record can be ignored because it does not contain information which is needed to program flash memory.
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:
Following is an example of a complete Intel HEX file:
:10001300AC12AD13AE10AF1112002F8E0E8F0F2244 :10000300E50B250DF509E50A350CF5081200132259 :03000000020023D8 :0C002300787FE4F6D8FD7581130200031D :10002F00EFF88DF0A4FFEDC5F0CEA42EFEEC88F016 :04003F00A42EFE22CB :00000001FF
The following Discussion Forum threads may provide information related to this topic.
原文:https://www.cnblogs.com/CodeWorkerLiMing/p/13848999.html