[comp.os.cpm] Sigh... here we go again

mrapple@uop.edu (Nick Sayer) (11/18/88)

It's me again. This time I'm interested in the format of a
.HEX file. I've noticed this:

:1001000000112233445566778899AABBCCDDEEFFxx
| |  |  ||------------------------------| |
| |  |  |              |                  checksum?
| |  |  |              data bytes
| |  |  zero byte
| |  address
| number of bytes in data field
required ":"

:0000000000 marks EOF

The questions are this: Is there a purpose to the zero byte
before the begining of the data field? How do you compute the
checksum on the end of the line?

---------------------------------------------------------------------- 
Nick Sayer | Packet Radio: N6QQQ @ WA6RDH | Fido: 161/31
uucp: ...!sdcsvax!ucbvax!ucdavis!uop!mrapple
Disclaimer:   You didn't REALLY believe that, did you?
cat flames > /dev/null

mlinar@caesar.usc.edu (Mitch Mlinar) (11/19/88)

In article <1739@uop.edu> mrapple@uop.edu (Nick Sayer) writes:
>It's me again. This time I'm interested in the format of a
>.HEX file. I've noticed this:
>
>:1001000000112233445566778899AABBCCDDEEFFxx
>| |  |  ||------------------------------| |
>| |  |  |              |                  checksum?
>| |  |  |              data bytes
>| |  |  zero byte
>| |  address
>| number of bytes in data field
>required ":"
>
>:0000000000 marks EOF
>
>The questions are this: Is there a purpose to the zero byte
>before the begining of the data field? How do you compute the
>checksum on the end of the line?

The zero byte is NOT always zero; it indicates the record type of this
line of hex code.  The last line of a HEX file is usually:

	:00xxyy01

where xxyy is the starting address for example, although I have seen other
meanings for it.  The 01 indicates this is the last record.

Checksum is computed by taking the sum of all bytes on the line (the colon is
ignored) and inverting it.  In other words, if you sum all bytes on the
line including the checksum, the result should be an 8-bit zero (ignore any
carry beyond 8-bits).

I have seem some implementations which, for some reason, ignore the count
byte (1st one) in computing the checksum.  Don't know how that happened,
but that method is wrong.

-Mitch