S?? File formats...

Derek Jewett jewett at sunset.net
Thu Apr 23 03:42:57 GMT 1998


While playing with s19 file formats I thought I would send some source code
on a converter, hope it helps...

Derek

****************************************************************************
*****


/*
 * 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 at vax.cs.pittsburgh.edu




More information about the Diy_efi mailing list