3 Copyright (C) 1989-1995 Alan R. Baldwin
4 721 Berkeley St., Kent, Ohio 44240
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 * The module lks19.c contains the function to
26 * output the relocated object code in the
27 * Motorola S19 format.
29 * lks19.c contains the following function:
32 * lks19.c contains no local variables.
36 * Record Type Field - This field signifies the start of a
37 * record and identifies the the record
40 * Ascii S1 - Data Record
41 * Ascii S9 - End of File Record
43 * Record Length Field - This field specifies the record length
44 * which includes the address, data, and
45 * checksum fields. The 8 bit record
46 * length value is converted to two ascii
47 * characters, high digit first.
49 * Load Address Field - This field consists of the four ascii
50 * characters which result from converting
51 * the the binary value of the address in
52 * which to begin loading this record. The
53 * order is as follows:
55 * High digit of high byte of address.
56 * Low digit of high byte of address.
57 * High digit of low byte of address.
58 * Low digit of low byte of address.
60 * In an End of File record this field con-
61 * sists of either four ascii zeros or the
62 * program entry address. Currently the
63 * entry address option is not supported.
65 * Data Field - This field consists of the actual data,
66 * converted to two ascii characters, high
67 * digit first. There are no data bytes in
68 * the End of File record.
70 * Checksum Field - The checksum field is the 8 bit binary
71 * sum of the record length field, the load
72 * address field, and the data field. This
73 * sum is then complemented (1's comple-
74 * ment) and converted to two ascii
75 * characters, high digit first.
80 * int i 0 - process data
83 * The function s19() outputs the relocated data
84 * in the standard Motorola S19 format.
87 * Addr_T chksum byte checksum
91 * FILE * ofp output file handle
92 * int rtcnt count of data words
93 * int rtflg[] output the data flag
94 * Addr_T rtval[] relocated data
97 * int fprintf() c_library
100 * The data is output to the file defined by ofp.
106 register Addr_T chksum;
114 for (i = 0, chksum = 1; i < rtcnt; i++) {
118 fprintf(ofp, "S1%02X", chksum);
119 for (i = 0; i < rtcnt ; i++) {
121 fprintf(ofp, "%02X", rtval[i]);
125 fprintf(ofp, "%02X\n", (0-chksum-1) & 0xff);
127 fprintf(ofp, "S9030000FC\n");