Tektronix file format

The Tektronix file format is not often used. The major disadvantage in modern applications is that the addressing range is limited to only 64kb.

Records

All data lines are called records and each record contains the following 5 fields:

/aaaaccasddss

/

Every record starts with this identifier.

aaaa

The address field. A 4 digit (2 byte) number representing the first address to be used by this record.

cc

The byte-count. A 2 digit value (1 byte), counting the actual number of data bytes in the record.

as

Address checksum. Covers 2 address bytes and the byte count.

dd

The actual data of this record. There can be 1 to 255 data bytes per record (see cc)

ss

Data Checksum. Covers only all the data bytes of this record.

Record Begin

Every record begins with a slash /. Records contain only ASCII characters! No spaces or tabs are allowed in a record. In fact, apart from the 1st slash and the End Of Line characters,no other characters than 0..9 and A..F are allowed in a record. Interpretation of a record should be case insensitive, so it does not matter if you use a..f or A..F.

Address Field

This is the address where the first data byte of the record should be stored. After storing that data byte the address is incremented by 1 to point to the address for the next data byte of the record. And so on, until all data bytes are stored.
The address is represented by a 4 digit hex number (2 bytes), with the MSD first.
The order of addresses in the records of a file is not important. The file may also contain address gaps, to skip a portion of unused memory.

Byte Count

The byte count cc counts the actual number of data bytes in the current record. Usually records have 32 data bytes, but any number between 1 and 255 is possible.
A value of $00 for cc indicates the end of the file. In the case of end of file only the address checksum AS will follow the byte count of $00.
It is not recommended to send too many data bytes in a record for that may increase the transmission time in case of errors. Also avoid sending only a few data bytes per record because the address overhead will be too heavy in comparison to the payload.

Address Checksum

This field is a running nibble sum of the Address and Byte Count fields only. The 4 nibbles (hex-digits) of the address field and the 2 nibbles of the byte count are added together to form the Address Checksum.
Note that $5A is the maximum value for the Address Checksum (6 x $F).

Data Field

The payload of the record is formed by the Data field. The number of data bytes expected is given by the Byte Count field. The last record of the file may not contain a Data field.

Data Checksum

Again this is a running nibble sum. It is calculated by adding all nibbles of the Data field together, resulting in a one byte value. The last record of the file may not contain a Data Checksum field.

Example

/B000100C576F77212044696420796F7520726561A5
/B010100D6C6C7920676F207468726F7567682061C1
/B020100E6C6C20746861742074726F75626C6520AF
/B0300D1B746F207265616420746869733F8D
/B03D001B

In the example above you can see a piece of code in Tektronix format. The first 3 lines have 16 bytes of data each, which can be seen by the byte count. The 4th line has only 13 bytes, because the program is at its end there.
The Address Checksum is quite easy to verify in this example because there are so many zeroes in the address part.
Notice that the last record of the file contains no data bytes, and that there is only an Address Checksum.