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 lkihx.c contains the function to
26 * output the relocated object code in the
29 * lkihx.c contains the following functions:
32 * lkihx.c contains no local variables.
36 * Record Mark Field - This field signifies the start of a
37 * record, and consists of an ascii colon
40 * Record Length Field - This field consists of two ascii
41 * characters which indicate the number of
42 * data bytes in this record. The
43 * characters are the result of converting
44 * the number of bytes in binary to two
45 * ascii characters, high digit first. An
46 * End of File record contains two ascii
47 * zeros in this field.
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 * Record Type Field - This field identifies the record type,
66 * which is either 0 for data records or 1
67 * for an End of File record. It consists
68 * of two ascii characters, with the high
69 * digit of the record type first, followed
70 * by the low digit of the record type.
72 * Data Field - This field consists of the actual data,
73 * converted to two ascii characters, high
74 * digit first. There are no data bytes in
75 * the End of File record.
77 * Checksum Field - The checksum field is the 8 bit binary
78 * sum of the record length field, the load
79 * address field, the record type field,
80 * and the data field. This sum is then
81 * negated (2's complement) and converted
82 * to two ascii characters, high digit
88 * int i 0 - process data
91 * The function ihx() outputs the relocated data
92 * in the standard Intel Hex format.
95 * Addr_T chksum byte checksum
99 * FILE * ofp output file handle
100 * int rtcnt count of data words
101 * int rtflg[] output the data flag
102 * Addr_T rtval[] relocated data
105 * int fprintf() c_library
108 * The data is output to the file defined by ofp.
114 register Addr_T chksum;
122 for (i = 0, chksum = -2; i < rtcnt; i++) {
126 fprintf(ofp, ":%02X", chksum);
127 for (i = 0; i < rtcnt ; i++) {
129 fprintf(ofp, "%02X", rtval[i]);
136 fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
138 fprintf(ofp, ":00000001FF\n");