Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!howland.reston.ans.net!agate!library.ucla.edu!csulb.edu!csus.edu!netcom.com!sheldon From: sheldon@netcom.com (Sheldon Simms) Subject: Re: The PHOENIX Project Message-ID: Organization: Netcom Online Communications Services (408-241-9760 login: guest) References: <1994Apr1.143423.4072@vax1.mankato.msus.edu> <2no33f$hrd@blackice.winternet.mpls.mn.us> Date: Wed, 6 Apr 1994 03:21:53 GMT Lines: 201 In article <2no33f$hrd@blackice.winternet.mpls.mn.us> rwifall@starship.cs.NMSU.edu (Richard Wifall) writes: >In article <1994Apr1.143423.4072@vax1.mankato.msus.edu> ultimav@vax1.mankato.msus.edu (Everybody knows!....) writes: > >> motorola 68xx family, and i believe that Richard Witfall was writting >> a downloader for the produced *.s19 files.. > > Uhhh.. Well, I actually haven't done anything on this yet. I >need to either reverse engineer the .s19 file to figure out what >exactly it means or find some specs on it. It should be a simple >program once I figure that out. Actually an S19 format file is just file using a subset of the full Motorola S-record format. Specifically, the S1 and S9 records. (maybe an S0 too.) S-RECORD OUTPUT FORMAT ---------------------- The S-record format for output modules is for encoding programs or data files in a printable format for transportation between computer systems. The transportation process can be visually monitored, and the S-records can be easily edited. S-RECORD CONTENT Visually, S-records are essentially character strings made of several fields that identify the record type, record length, memory address, code/data, and checksum. Each byte of binary data encodes as a two- character hexadecimal number: the first character represents the high- order four bits, and the second character represents the low-order four bits of the byte. Figure 1 illustrates the five fields that comprise an S-record. Table 1 lists the composition of each S-record field. +------+---------------+---------+-----------+----------+ | TYPE | RECORD LENGTH | ADDRESS | CODE/DATA | CHECKSUM | +------+---------------+---------+-----------+----------+ Figure 1. +---------------+------------+--------------------------------------------+ | Field | Printable | Contents | | | Characters | | +---------------+------------+--------------------------------------------+ | Type | 2 | S-record type -- S0, S1, etc. | +---------------+------------+--------------------------------------------+ | | | The count of the character pairs in the | | Record Length | 2 | record, excluding the type and record | | | | length. | +---------------+------------+--------------------------------------------+ | Address | 4, 6, or 8 | The 2-, 3-, or 4-byte address at which the | | | | data field is to be loaded into memory. | +---------------+------------+--------------------------------------------+ | | | From 0 to n bytes of executable code, | | | | memory loadable data, or descriptive | | Code/Data | 0 - 2n | information. For compatibility with tele- | | | | typewriters, some programs may limit the | | | | number of bytes to as few as 28 (56 print- | | | | able characters in the S-record). | +---------------+------------+--------------------------------------------+ | | | The least significant byte of the one's | | | | complement of the sum of the values | | Checksum | 2 | represented by the pairs of characters | | | | making up the record length, address, and | | | | the code/data fields. | +---------------+------------+--------------------------------------------+ Table 1. When downloading S-record, each must be terminated by a CR. Additionally, an S-record may have an initial field that fits other data such as line numbers generated by some time-sharing systems. The record length (byte count) and checksum fields insure transmission accuracy. S-RECORD TYPES There are eight types of S-records to accomodate the encoding, trans- portation, and decoding functions. The various Motorola record trans- portation control programs (e.g. upload, download, etc.), cross-assemblers, linkers, and other file creating or debugging programs, only utilize S-records serving the program's purpose. For more information on support of specific S-records, refer to the user's manual for that program. An S-record format module may contain S-records of the following types: S0 - The header record for each block of S-records. The code/data field may contain any descriptive information identifying the following block of S-records. Under VERSAdos, the resident linker's IDENT command can be used to designate module name, version number, revision number, and description information that will make up the header record. The address field is normally zeros. S1 - A record containing code/data and the 2-byte address at which the code/data is to reside. S2 - A record containing code/data and the 3-byte address at which the code/data is to reside. S3 - A record containing code/data and the 4-byte address at which the code/data is to reside. S5 - A record containing the number of S1, S2, and S3 records transmitted in a particular block. This count appears in the address field. There is no code/data field. S7 - A termination record for a block of S3 records. The address field may optionally contain the 4-byte address of the instruction to which control is to be passed. There is no code/data field. S8 - A termination record for a block of S2 records. The address field may optionally contain the 3-byte address of the instruction to which control is to be passed. There is no code/data field. S9 - A termination record for a block of S1 records. The address field may optionally contain the 2-byte address of the instruction to which control is to be passed. Under VERSAdos, the resident linker's ENTRY command can be used to specify this address. If this address is not specified, the first entry point specification encountered in the object module input will be used. There is no code/data field. Each block of S-records uses only one termination record. S7 and S8 records are only active when control is to be passed to a 3- or 4-byte address; otherwise, an S9 is used for termination. Normally, there is only one header record, although it is possible for multiple header records to occur. S-RECORD CREATION Dump utilities, debuggers, a VERSAdos resident linkage editor, or cross assemblers and linkers produce S-record format programs. On VERSAdos systems the build load module (MBLM) utility allows an executable load module to be built from S-records. It has a counterpart utility in BUILDS that allows an S-record file to be created from a load module. Programs are available for downloading or uploading a file in S-record format from a host system to an 8- or 16-bit microprocessor-based system. A typical S-record format module is printed or displayed as follows: S00600004844521B S1130000285F245F2212226A000424290008237C2A S11300100002000800082629001853812341001813 S113002041E900084E42234300182342000824A952 S107003000144ED492 S9030000FC The module has an S0 record, four S1 records, and an S9 record. The following character pairs comprise the S-record format module. S0 Record: S0 - S-record type S0, indicating that it is a header record. 06 - Hexadecimal 06 (decimal 6), indicating that six character pairs (or ASCII bytes) follow. 0000 - A 4-character, 2-byte address field; zeros in this example. 48 - ASCII 'H' 44 - ASCII 'D' 52 - ASCII 'R' 1B - The checksum. First S1 Record: S1 - S-record type S1, indicating that it is a code/data record to be loaded/verified at a 2-byte address. 13 - Hexadecimal 13 (decimal 19), indicating that 19 character pairs, representing 19 bytes of binary data, follow. 0000 - A 4-character, 2-byte address field (hexadecimal address 0000) indicating where the data that follows is to be loaded. The next 16 character pairs of the first S1 record are the ASCII bytes of the actual program code/data. In this assembly language example, the program's hexadecimal opcodes are sequentially written in the code/data fields of the S1 records. Opcode Instruction -------- ------------- 285F MOVE.L (A7)+,A4 245F MOVE.L (A7)+,A2 2212 MOVE.L (A2),D1 226A0004 MOVE.L 4(A2),A1 24290008 MOVE.L FUNCTION(A1),D2 237C MOVE.L #FORCEFUNC,FUNCTION(A1) The rest of this code continues in the remaining S1 record's code/data fields and stores in memory location 0010, etc. 2A - The checksum of the first S1 record. The second and third S1 records also contain hexadecimal 13 (decimal 19) character pairs and end with checksums 13 and 52, respectively. The fourth S1 record contains 07 character pairs and has a checksum of 92. S9 Record: S9 - S-record type S9, indicating that it is a termination record. 03 - Hexadecimal 03, indicating that three character pairs (3 bytes) follow. 0000 - The address field, zeros. FC - The checksum of the S9 record. Each printable character in an S-record encodes in hexadecimal (ASCII in this example) representation of the binary bits that transmit. ---------------------- -- W. Sheldon Simms | Newt's Friend / Jack Kemp for President sheldon@netcom.com | Freedom implies responsibility -------------------------+--------------------------------------------