Motorola S-records in EASy68K

DESCRIPTION

An S-record file consists of a sequence of specially formatted ASCII character strings. An S-record will be less than or equal to 78 bytes in length.

The original Unix man page on S-records is the only place that a 78-byte limit on total record length or 64-byte limit on data length is documented. These values should not be trusted for the general case. Always assume that a record can be as long as 514 (decimal) characters in length (255 * 2 = 510, plus 4 characters for the type and count fields), plus any terminating character(s). Input buffers should be long enough to hold 515 chars, thus leaving room for the terminating null character. The order of S-records within a file is of no significance and no particular order may be assumed with the exception of the termination record at the end.

The general format of an S-record follows:

+-------------------//------------------//-----------------------+
| type | count | address  |            data           | checksum |
+-------------------//------------------//-----------------------+
type -- A char[2] field. These characters describe the type of record (S0, S1, S2, S3, S5, S7, S8, or S9).

count -- A char[2] field. These characters when paired and interpreted as a hexadecimal value, display the count of remaining character pairs in the record.

address -- A char[4,6, or 8] field. These characters grouped and interpreted as a hexadecimal value, display the address at which the data field is to be loaded into memory. The length of the field depends on the number of bytes necessary to hold the address. A 2-byte address uses 4 characters, a 3-byte address uses 6 characters, and a 4-byte address uses 8 characters.

data -- A char [0-64] field. These characters when paired and interpreted as hexadecimal values represent the memory loadable data or descriptive information.

checksum -- A char[2] field. These characters when paired and interpreted as a hexadecimal value display the least significant byte of the ones complement of the sum of the byte values represented by the pairs of characters making up the count, the address, and the data fields.

Each record is terminated with a line feed. If any additional or different record terminator(s) or delay characters are needed during transmission to the target system it is the responsibility of the transmitting program to provide them.

S0 Record. The address field is unused and will be filled with zeros (0x0000). The code/data field contains descriptive information identifying the following block of S-records as having been created by EASy68K.

S1 Record. The address field is interpreted as a 2-byte address. The data field is composed of memory loadable data.

S2 Record. The address field is interpreted as a 3-byte address. The data field is composed of memory loadable data.

S3 Record. The address field is interpreted as a 4-byte address. The data field is composed of memory loadable data.

S5 Record. The address field is interpreted as a 2-byte value and contains the count of S1, S2, and S3 records previously transmitted. There is no data field. (EASy68K does not generate this record.)

S7 Record. Termination record. The address field contains the starting execution address and is interpreted as 4-byte address. There is no data field. This is the last record in the file. (EASyBIN always uses this termination record when creating S-Record files.)

S8 Record. Termination record. The address field contains the starting execution address and is interpreted as 3-byte address. There is no data field.  This is the last record in the file. (EASy68K always uses this termination record when creating S-Record files.)

S9 Record. Termination record. The address field contains the starting execution address and is interpreted as 2-byte address. There is no data field. This is the last record in the file.

 

EXAMPLE

The following program was assembled with EASy68K. The .L68 file is shown. The .L68 file contains the address, machine code, line number and source code.

 

 

00001000 Starting Address

Assembler used: EASy68K Editor v1.9.2

Created On: 1/28/2004 4:51:58 PM

 

Address    Machine Code        Line        Source Code

 

00000000                         1  *-----------------------------------------------------------

00000000                         2  * Program Number: S-Record demo for EASy68k

00000000                         3  * Written by : Chuck Kelly

00000000                         4  * Date Created : Jan-28-2004

00000000                         5  * Description : demonstrate the S-Record file format used by EASy68K.

00000000                         6  *

00000000                         7  * This program is public domain.

00000000                         8  *-----------------------------------------------------------

00000000                         9

00001000                        10  START   ORG     $1000   the program will load into address $1000

00001000 123C 0003              11          move.b  #3,d1   put 3 in low byte of data register D1

00001004 5A01                   12          add.b   #5,d1   add 5 to low byte of data register D1

00001006                        13  * Display string textD1

00001006 303C 000E              14          move    #14,d0  load task number into D0

0000100A 43F9 00044446          15          lea   textD1,a1 load address of string to display into A1

00001010 4E4F                   16          trap    #15     trap #15 activates input/output task

00001012                        17  * Display D1 as a number

00001012 303C 0003              18          move    #3,d0   task number 3 into D0

00001016                        19  * task number 3 is used to display the contents of D1.L as a number

00001016 4E4F                   20          trap    #15     display number in D1.l

00001018 4EB9 00022222          21          jsr     newLine

0000101E                        22  * Stop execution

0000101E 4E72 2000              23          STOP    #$2000

00001022                        24

00022222                        25          org     $22222  this subroutine is located at address $22222

00022222                        26  * Subroutine to display Carriage Return and Line Feed

00022222                        27  newLine:

00022222 48E7 8040              28          movem.l d0/a1,-(a7) push d0 & a1

00022226 303C 000E              29          move    #14,d0  task number into D0

0002222A 43F9 00044462          30          lea     crlf,a1 address of string

00022230 4E4F                   31          trap    #15     display return, linefeed

00022232 4CDF 0201              32          movem.l (a7)+,d0/a1  restore d0 & a1

00022236 4E75                   33          rts     return

00022238                        34

00044444                        35          org     $44444  this data is located at address $44444

00044444                        36  sum2    ds.w    1       reserve word of memory for sum2

00044446 44 31 20 63 6F 6E ...  37  textD1  dc.b 'D1 contains: ',0   null terminated string

00044454 44 32 20 63 6F 6E ...  38  textD2  dc.b 'D2 contains: ',0   null terminated string

00044462 0D 0A 00               39  crlf    dc.b $d,$a,0             carriage return & line feed, null

00044465                        40

00044465                        41  */\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

00044465                        42  * E R R O R E R R O R E R R O R E R R O R E R R O R

00044465                        43  */\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

00044465                        44  * EASy68K does not support addresses beyond $FFFFFF or 16MBytes

00044465                        45  * Comment out the following org directive if you want to run this program.

12345678                        46          org     $12345678

12345678 69 6E 76 61 6C 69 ...  47  junk    dc.b 'invalid address'

12345687                        48

12345687                        49          END     START     end of program with start address specified

 

 

The S-record file created from the above program follows:.

S021000036384B50524F47202020313143524541544544204259204541535936384B6D

S1251000123C00035A01303C000E43F9000444464E4F303C00034E4F4EB9000222224E72200004

S21A02222248E78040303C000E43F9000444624E4F4CDF02014E75C2

S223044446443120636F6E7461696E733A2000443220636F6E7461696E733A20000D0A009A

S31412345678696E76616C69642061646472657373EA

S804001000EB

 

The S0 Record contains the following information:

                               /-version number
          module name         / /-revision number                     checksum
S0  0000 6 8 K P R O G       1 1 C R E A T E D   B Y   E A S Y 6 8 K /
S021000036384B50524F47202020313143524541544544204259204541535936384B6D

The version and revision number refer to the EASy68K S-Record file type, not the product version.

The file consists of one S0 record, one S1 record, two S2 records, one S3 record and an S8 record.

The first S1 record is comprised as follows:

S1 25 1000 123C00035A01303C000E43F9000444464E4F303C00034E4F4EB9000222224E722000 04

The first S2 record is comprised as follows:

S2 1A 022222 48E78040303C000E43F9000444624E4F4CDF02014E75 C2

The second S2 record contains additional data which is to be loaded at address $044446

The first S3 record is comprised as follows:

S3 14 12345678 696E76616C69642061646472657373 EA

The S8 record is comprised as follows:

 

S8 04 001000 EB

EASy68K always uses the S8 record.