S19 File Format as it pertains to 68HC11 AS11 output by Tom Dickens Obtained from http www nwlink com dickens5 tom 68hc11 docs s19 file format html 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 All leading white space on each line is ignored The first 4 characters in each line of the file contain o o o the character S a single digit code 1 9 and a 2 character number indicating the number of bytes in the line The last 2 characters in a line are a checksum The remaining characters in the line are 2 character data bytes The end of line characters in the file can be either n or r 0x0A or 0x0D or both Note Each line MUST start with an S character Line Codes The following codes are known 1 characters 5 8 in the line specify a 16 bit address 2 characters 5 10 in the line specify a 24 bit address 3 characters 5 12 in the line specify a 32 bit address 7 8 9 end of file A checksum follows but if generally ignored 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 S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055 S123B6209610B710041306FFF7CC0002DD007F0006DC021A83AA5526E7D6049605B710048F S123B6405818CE1018183A164F050505050518ED0020CD363CCE10008655A7208678A70C1B S123B660A70D383239FEB680DFC7B6B68297C986AAB710048604B7100986C4B710280E3972 S123B6807EB6837C0010CE100018DE001F2980FCB6102A188C0002260481AA260618A700F5 S107B6A07C00013BEA S9030000FC snip example s19 Looking at the first line Start of Line The line starts with an S Command S123B600BDB653CC0800FD1018FD101AFD101CFD101EBDB665CC0002DD007F00067F001055 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 Check Sum Data Bytes End Of File S9030000FC S9030000FC 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 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 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 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
View Full Document