[misc.wanted] Motorola S19 Format

wfp5p@euclid.acc.Virginia.EDU (William F. Pemberton) (03/20/89)

I am looking for a program to convert from Motorola S19 Hex format to Intel
Hex format.

Instead of a conversion utility, I could also use an assembler for the 
68HC11 that would produce Intel Hex directly.

I would perfer either source code or something that is executable on a MS-DOS
machine.

Thanks in advance,


+----------------------------------------------------------------------------+
|Bill Pemberton                flash@virginia.bitnet   wfp5p@virginia.bitnet |
|(804)296-FRYD                 flash@virginia.edu      wfp5p@virginia.edu    |
|Academic Computing Center   +-----------------------------------------------+
|University of Virginia      | "I hate to advocate drugs, alcohol, and sex,  |
|Charlottesville, Va 22904   | but they've always worked for me" - H.Thompson|
+----------------------------+-----------------------------------------------+

hoffman@pitt.UUCP (Bob Hoffman) (03/24/89)

In article <547@babbage.acc.virginia.edu> wfp5p@euclid.acc.Virginia.EDU (William F. Pemberton) writes:
>
>I am looking for a program to convert from Motorola S19 Hex format to Intel
>Hex format.

Here it is, enjoy!

	---Bob.

/*
 * Convert Motorola S1/S9 hex files to Intel hex.
 *
 * R. B. Hoffman, July 1985.
 *
 * usage:   hexcvt < motorola-file > intel-file
 */

#include <stdio.h>

char line[256];

main() {
	int bc, val, cksm, fcksm, i;
	long laddr;

	while (fgets(line, 256, stdin) != NULL) {
		if (line[0] != 'S')
			continue;
		if (line[1] == '9')
			break;
		if (line[1] != '1')
			continue;
		sscanf(&line[2],"%2x",&bc);
		sscanf(&line[4],"%4x",&laddr);
		printf(":%02X%04X00", bc-3, laddr);
		cksm = bc + (laddr & 0xFF) + ((laddr >> 8) & 0xFF);
		for (i=0; i<(bc-3); i++) {
			sscanf(&line[i*2 + 8], "%2x", &val);
			cksm += val;
			printf("%02X", val);
		}
		sscanf(&line[(bc-3)*2 + 8], "%2x", &fcksm);
		cksm = ~cksm & 0xFF;
		if (cksm != fcksm)
			fprintf(stderr,"cksm=%02x, fcksm=%02x\n", cksm, fcksm);
		printf("%02X\n", (cksm+4) & 0xFF);
	}
	printf(":0000000000\n");
}
-- 
Bob Hoffman, N3CVL       {allegra, bellcore, cadre, idis, psuvax1}!pitt!hoffman
Pitt Computer Science    hoffman@vax.cs.pittsburgh.edu