S19 File Format - as it pertains to 68HC11 AS11 output.

by Tom Dickens

Back to docs & references.

Last updated:


This description of the S19 file format was generated based on example code provided by Randy Sargent (rsargent@newtonlabs.com).

The format of the .s19 file generated by AS11.EXE, and read into PCBUG11 for programming the 68HC11, is detailed here.


General Description:

The .s19 file is a file consisting of readable characters in the set of {S,0-9,A-F}. The file contains addresses and byte-information to be located in memory starting from the addresses. Addresses are specified by 4, 6, or 8 character HEX strings, and bytes are specified by 2-character HEX strings.

Details:

Note: Each line MUST start with an 'S' character.

Line-Codes

The following codes are known:

The data bytes are character-pairs which are the byte data in HEX to be located in memory starting at the specified address.


Example

For example, the following assembly code generates the following .s19 data:

:::example.asm

        ORG $B600               ; Start of EEPROM
        jsr     Init_4_Servos
        ldd     #$0800          ; Servo middle position
        std     $1018           ; Initial setting for servo 0
        std     $101a           ; Initial setting for servo 1
        std     $101c           ; Initial setting for servo 2
        std     $101e           ; Initial setting for servo 3
        jsr     Init_SPI
        ldd     #$0002
        std     SPI_POINTER
        clr  SPI_DATA+4
        clr  COUNT

Loop:
        ldaa    COUNT
        staa    $1004           ; port B
        brclr   SPI_DATA+4 $FF Loop     ; Wait for 5th SPI byte

[snip]

:::example.s19

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055
S123B6209610B710041306FFF7CC0002DD007F0006DC021A83AA5526E7D6049605B710048F
S123B6405818CE1018183A164F050505050518ED0020CD363CCE10008655A7208678A70C1B
S123B660A70D383239FEB680DFC7B6B68297C986AAB710048604B7100986C4B710280E3972
S123B6807EB6837C0010CE100018DE001F2980FCB6102A188C0002260481AA260618A700F5
S107B6A07C00013BEA
S9030000FC

Looking at the first line:

Start of Line:

The line starts with an 'S'.

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

Command:

The second character on the line is the command, in this case a '1':

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

This means that the address will be a 2-byte (4-character) address.

Line Length:

The third and fourth characters on the line are the number of character pairs (bytes) on the line, including the address:

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

In this line this is a 23 (a HEX 23), which is 35 in decimal.

Address:

The next section on the line is the address, the length of which is specified by the command character:

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

B600 This 4-character (2-byte) address is a HEX $B600, the start of the EEPROM in a 68HC11E1.

Check-Sum:

The last 2 characters are a 1-byte check-sum for the line. The check-sum is calculated by summing, in HEX, all of the 2-character bytes on the line starting wit the third and fourth characters (the length byte), and running up to the check-sum byte. This resulting number is truncated to a number in the range of 0 to 255 (anded with 0x00FF), and then complemented. This result is the line's checksum.

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

For this line, starting with the "23" and summing through the "10", the sum is 0xCAA. Truncating we get 0xAA, and complementing we get 0x55, the 55 as seen at the end of the line.

Data-Bytes:

The character-pairs between the address and the end-of-the-line checksum are the data-bytes:

S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055

These bytes will be placed sequentially in memory starting with the specified address. In this line, the first data-byte is BD, which is the machine-code for the JSR line of the code, will be placed in memory at address $B600. The next 2 bytes, B653, is the machine-code of the address the jump will take, the location of the Init_4_Servos subroutine, and will be places in memory locations $B601 and $B602; and so on.

Note that even when the data spans more than 32 sequential bytes in memory, a maximum of 32 data bytes is used. The data is continued on the next line in the file, with the address being specified ($B620 in our example). This is redundant, but allows each line in the .s19 file to completely specify the address and the data.

End-Of-File:

The last line in this example .s19 file shows the end-of-file specifier.

S9030000FC

The end-of-file command is a '9' (and as specified in Randy's code, a '7' or an '8' may also be specified).

The next 2 characters are the line-length byte, 3 bytes in this case:

S9030000FC

The remaining 6 characters in the file are perhaps some sort of file check-sum, but I do not have the details for how they are calculated, nor could I see the connection for the use of this data.

Note: In my example assembly-language file, the last instruction is an RTI, which assembles into a hex 3B. This 3B shows up as the last data-byte in the next to the last line in the .s19 file, which shows us that the information on this last line in the .s19 file is not used for part of our code.