The -ck
option is for calculating a hash value. The usage
of this option is:
-ck=start-end@dest [+offset][wWidth][tCode][gAlgorithm][pPolynomial][rwidth]
where:
start
and end
specify
the address range over which the hash will be calculated. If these addresses are not a
multiple of the algorithm width, the value zero will be padded into the relevant input
word locations that are missing.dest
is the address where the hash result will
be stored. This value cannot be within the range of calculation.offset
is an optional initial value to be used
in the calculations.Width
is optional and specifies the width of
the result. Results can be calculated for byte-widths of 1 to 4 bytes for most
algorithms, but it represents the bit width for SHA algorithms. If a positive width is
requested, the result will be stored in big-endian byte order. A negative width will
cause the result to be stored in little-endian byte order. If the width is left
unspecified, the result will be 2 bytes wide and stored in little-endian byte order.
This width argument is not used if you have selected any Fletcher algorithm.Code
is a hexadecimal code that will trail
each byte in the result. This can allow each byte of the hash result to be embedded
within an instruction, for example code=34
will embed the result in a
retlw
instruction on Mid-range devices.Algorithm
is an integer to select which Hexmate hash algorithm to use to calculate the result. A list of
selectable algorithms is provided in Table 1. If unspecified, the default algorithm used is 8-bit checksum addition (algorithm
1).Polynomial
is a hexadecimal value which is the
polynomial to be used if you have selected a CRC algorithm.r
is a decimal
word width. If this is non-zero, then bytes within each word are read in reverse order
when calculating a hash value. At present, the width must be 0 or 2. A zero width
disables the reverse-byte feature, as if the r
suboption was not
present. This suboption should be used when using Hexmate to match a CRC produced by a
PIC hardware CRC module that use the Scanner module to stream data to it.All numerical arguments are assumed to be hexadecimal values, except for the algorithm selector and result width, which are assumed to be decimal values.
A typical example of the use of the checksum option is:
-ck=0-1FFF@2FFE+2100w2g2
This will calculate a checksum over the range 0 to 0x1FFF and program the checksum result at address 0x2FFE. The checksum value will be offset by 0x2100. The result will be two bytes wide.
Selector | Algorithm Description |
---|---|
-5 | Reflected cyclic redundancy check (CRC). |
-4 | Subtraction of 32 bit values from initial value. |
-3 | Subtraction of 24 bit values from initial value. |
-2 | Subtraction of 16 bit values from initial value. |
-1 | Subtraction of 8 bit values from initial value. |
1 | Addition of 8 bit values from initial value. |
2 | Addition of 16 bit values from initial value. |
3 | Addition of 24 bit values from initial value. |
4 | Addition of 32 bit values from initial value. |
5 | Cyclic redundancy check (CRC). |
7 | Fletcher’s checksum (8 bit calculation, 2-byte result width). |
8 | Fletcher’s checksum (16 bit calculation, 4-byte result width). |
10 | SHA-2 (currently only SHA256 is supported) |
See Hash Functions for more details about the algorithms that are used to calculate checksums.