4 * (C) Copyright 1989-1995
19 * The module lkihx.c contains the function to
20 * output the relocated object code in the
23 * lkihx.c contains the following function:
26 * lkihx.c contains no local variables.
30 * Record Mark Field - This field signifies the start of a
31 * record, and consists of an ascii colon
34 * Record Length Field - This field consists of two ascii
35 * characters which indicate the number of
36 * data bytes in this record. The
37 * characters are the result of converting
38 * the number of bytes in binary to two
39 * ascii characters, high digit first. An
40 * End of File record contains two ascii
41 * zeros in this field.
43 * Load Address Field - This field consists of the four ascii
44 * characters which result from converting
45 * the the binary value of the address in
46 * which to begin loading this record. The
47 * order is as follows:
49 * High digit of high byte of address.
50 * Low digit of high byte of address.
51 * High digit of low byte of address.
52 * Low digit of low byte of address.
54 * In an End of File record this field con-
55 * sists of either four ascii zeros or the
56 * program entry address. Currently the
57 * entry address option is not supported.
59 * Record Type Field - This field identifies the record type,
60 * which is either 0 for data records or 1
61 * for an End of File record. It consists
62 * of two ascii characters, with the high
63 * digit of the record type first, followed
64 * by the low digit of the record type.
66 * Data Field - This field consists of the actual data,
67 * converted to two ascii characters, high
68 * digit first. There are no data bytes in
69 * the End of File record.
71 * Checksum Field - The checksum field is the 8 bit binary
72 * sum of the record length field, the load
73 * address field, the record type field,
74 * and the data field. This sum is then
75 * negated (2's complement) and converted
76 * to two ascii characters, high digit
82 * int i 0 - process data
85 * The function ihx() outputs the relocated data
86 * in the standard Intel Hex format.
89 * Addr_T chksum byte checksum
93 * FILE * ofp output file handle
94 * int rtcnt count of data words
95 * int rtflg[] output the data flag
96 * Addr_T rtval[] relocated data
99 * int fprintf() c_library
102 * The data is output to the file defined by ofp.
108 register Addr_T chksum;
116 for (i = 0, chksum = -2; i < rtcnt; i++) {
120 fprintf(ofp, ":%02X", chksum);
121 for (i = 0; i < rtcnt ; i++) {
123 fprintf(ofp, "%02X", rtval[i]);
130 fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
132 fprintf(ofp, ":00000001FF\n");