Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 ユーザーズマニュアル

製品コード
SW006021-1
ページ / 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 296
 2012 Microchip Technology Inc.
8.3.1
Checksum Specifications
If you are generating a HEX file output, use HEXMATE’s checksum tools, described in 
Section 8.6 “HEXMATE”.
For other file formats, the OBJTOHEX checksum specification allows automated 
checksum calculation and takes the form of several lines, each line describing one 
checksum. The syntax of a checksum line is:
addr1-addr2 where1-where2 +offset
All of addr1addr2where1where2 and offset are HEX numbers, without the 
usual H suffix.
Such a specification says that the bytes at addr1 through to addr2 inclusive should 
be summed and the sum placed in the locations where1 through where2 inclusive. 
For an 8 bit checksum these two addresses should be the same. For a checksum 
stored low byte first, where1 should be less than where2, and vice versa.
The +offset value is optional, but if supplied, the value will be used to initialize the 
checksum. Otherwise it is initialized to zero.
For example:
0005-1FFF 3-4 +1FFF
This will sum the bytes in 5 through 1FFFH inclusive, then add 1FFFH to the sum. The 
16 bit checksum will be placed in locations 3 and 4, low byte in 3. The checksum is ini-
tialized with 1FFFH to provide protection against an all zero ROM, or a ROM misplaced 
in memory. A run time check of this checksum would add the last address of the ROM 
being checksummed into the checksum. For the ROM in question, this should be 
1FFFH. The initialization value may, however, be used in any desired fashion.