/* * @(#) $Id: hexsum.h,v 1.2 90/05/01 21:45:44 marc Exp $ * * Copyright (c) 1989,1990 Marco S. Hyman * * Permission to copy all or part of this material for any purpose is * granted provided that the above copyright notice and this paragraph * are duplicated in all copies. THIS SOFTWARE IS PROVIDED ``AS IS'' * AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS * FOR A PARTICULAR PURPOSE. * * $Log: hexsum.h,v $ * Revision 1.2 90/05/01 21:45:44 marc * - use getopt, clean up coments. * * Revision 1.1 89/11/19 13:40:21 mhyman * Initial revision * */ /* Hexsum is a utility that calculates a checksum for a given range of an intel hex file and then modifies the hex file to include the checksum. Since checksums may be required for only a portion of a file the user is allowed to specify the lower and upper bounds of the calculation. The fill pattern for unreferenced memory may be specified as well as the address to place the checksum. The checksum is calculated such that the sum of all memory locations from the lower bounds thru the upper bounds plus the checksum (if it is not within the given bounds) modulus 256 is zero. */ /* The format of the input hex file is: Type 0 (data) :ccaaaa00b1b2...bnkk Type 1 (end of file) :ccaaaa01kk : is the literal `:' cc is a hex count of the data bytes in the record - may be zero aaaa is the load address (type 0) of the data bytes within the record or the start address (type 1) of the program. b1b2...bn are the data bytes. There are cc data pairs in the record. kk is a modulus 256 checksum of the record such that cc + aa... + b1 + b2 + ... + bn + kk = 0 Data after a type 1 record is usually ignored. */ /* The following defines describe the offsets of the fields in the hex records. */ # define HexFlag 0 # define HexCount 1 # define HexAdrs 3 # define HexType 7 # define HexData 9 # ifdef DEBUG /* The Report macro takes a parameter describing the debug data to be printed. The entire parameter should be surrounded by parathesis, and include a a standard printf "control string", and any additional parameters needed (just like printf). An example REPORT might be: Report( ( "Value of j: %d" , j ) ) */ # define Report(err) { \ printf err; \ putchar('\n'); \ } # else # define Report(err) # endif