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.


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


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.


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


        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

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




Looking at the first line:

Start of Line:

The line starts with an 'S'.



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


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:


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


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


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


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.


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.


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


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.


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


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:


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.