Article View: comp.sys.intel
Article #1889Re: Motorola S19 Format
From: Bob Hoffman
Date: Thu, 23 Mar 1989 16:53
Date: Thu, 23 Mar 1989 16:53
52 lines
1765 bytes
1765 bytes
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
Technical Details
Message-ID:
<4724@pitt.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!pt.cs.cmu.edu!cadre!pitt!hoffmanReferences:
<547@babbage.acc.virginia.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!pt.cs.cmu.edu!cadre!pitt!hoffman From: hoffman@pitt.UUCP (Bob Hoffman) Newsgroups: comp.sys.intel,misc.wanted,comp.misc,comp.sources.wanted Subject: Re: Motorola S19 Format Message-ID: <4724@pitt.UUCP> Date: 23 Mar 89 16:53:13 GMT References: <547@babbage.acc.virginia.edu> Reply-To: hoffman@vax.cs.pittsburgh.edu (Bob Hoffman) Distribution: na Organization: Univ. of Pittsburgh Computer Science Lines: 52