Nowadays the MOS Technology format is rarely used. In fact not many people even remember its existence, I suppose. The major disadvantage in modern applications is that the addressing range is limited to only 64kb.
All data lines are called records and each record contains the following 5 fields:
Every record starts with this identifier.
The byte-count. A 2 digit value (1 byte), counting the actual number of data bytes in the record.
The address field. A 4 digit (2 byte) number representing the first address to be used by this record.
The actual data of this record. There can be 1 to 255 data bytes per record (see cc)
Total Checksum. Covers byte count, address and all the data bytes of this record.
Every record begins with a semicolon ;. Records contain only ASCII characters! No spaces or tabs are allowed in a record. In fact, apart from the 1st semicolon 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.
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 an end of file record nothing follows the byte count, not even a checksum.
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.
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.
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.
The Checksum is the 16-bit sum of the byte count, both address bytes and all data bytes. Thus all bytes on the data line are added together and the end result is truncated to 16-bits.
;10B000576F77212044696420796F75207265610624 ;10B0106C6C7920676F207468726F756768206106B9 ;10B0206C6C20746861742074726F75626C652006C6 ;0DB030746F207265616420746869733F05A3 ;00
In the example above you can see a piece of code in MOS Technology 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.