4 * (C) Copyright 1989-1995
18 * The module lkihx.c contains the function to
19 * output the relocated object code in the
22 * lkihx.c contains the following functions:
25 * lkihx.c contains no local variables.
29 * Record Mark Field - This field signifies the start of a
30 * record, and consists of an ascii colon
33 * Record Length Field - This field consists of two ascii
34 * characters which indicate the number of
35 * data bytes in this record. The
36 * characters are the result of converting
37 * the number of bytes in binary to two
38 * ascii characters, high digit first. An
39 * End of File record contains two ascii
40 * zeros in this field.
42 * Load Address Field - This field consists of the four ascii
43 * characters which result from converting
44 * the the binary value of the address in
45 * which to begin loading this record. The
46 * order is as follows:
48 * High digit of high byte of address.
49 * Low digit of high byte of address.
50 * High digit of low byte of address.
51 * Low digit of low byte of address.
53 * In an End of File record this field con-
54 * sists of either four ascii zeros or the
55 * program entry address. Currently the
56 * entry address option is not supported.
58 * Record Type Field - This field identifies the record type,
59 * which is either 0 for data records or 1
60 * for an End of File record. It consists
61 * of two ascii characters, with the high
62 * digit of the record type first, followed
63 * by the low digit of the record type.
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, the record type field,
73 * and the data field. This sum is then
74 * negated (2's complement) and converted
75 * to two ascii characters, high digit
81 * int i 0 - process data
84 * The function ihx() outputs the relocated data
85 * in the standard Intel Hex format.
88 * Addr_T chksum byte checksum
92 * FILE * ofp output file handle
93 * int rtcnt count of data words
94 * int rtflg[] output the data flag
95 * Addr_T rtval[] relocated data
98 * int fprintf() c_library
101 * The data is output to the file defined by ofp.
107 register Addr_T chksum;
115 for (i = 0, chksum = -2; i < rtcnt; i++) {
119 fprintf(ofp, ":%02X", chksum);
120 for (i = 0; i < rtcnt ; i++) {
122 fprintf(ofp, "%02X", rtval[i]);
129 fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
131 fprintf(ofp, ":00000001FF\n");