home *** CD-ROM | disk | FTP | other *** search
- From: ian@sibyl.eleceng.ua.oz.au
- Newsgroups: alt.sources
- Subject: [comp.sys.nsc.32k] intelhex
- Message-ID: <1990Jun1.210955.26308@math.lsa.umich.edu>
- Date: 1 Jun 90 21:09:55 GMT
-
- Archive-name: intelhex/31-May-90
- Original-posting-by: ian@sibyl.eleceng.ua.oz.au
- Original-subject: intelhex
- Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
-
- [Reposted from comp.sys.nsc.32k.
- Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]
-
- Someone (Dave Rand?) Posted a little program "intelhex.c". I don't know what
- this generates, but it certainly isn't what our prom burner calls intel-hex
- format. Here is a program which does generate a format acceptable to our prom
- burner. The "unsigned" mightn't be necessary but this program is firmly in the
- "quick hack" category so I haven't bothered to check.
-
- ----------------------------cut here--------------------------------------
- #include <stdio.h>
-
- main()
- {
- int i, nbytes = 0;
- unsigned char bytes[32];
- int offset = 0;
- do
- {
- int ret;
- int checksum;
- unsigned char type;
- ret = fread(bytes, 1, 32, stdin);
- if (ret == 0)
- {
- type = 1;
- offset -= nbytes;
- }
- else
- type = 0;
- nbytes = ret;
- checksum = nbytes;
- checksum += (offset & 0xff);
- checksum += ((offset >> 8) & 0xff);
- checksum += type;
- printf(":%2.2X%4.4X%2.2X", nbytes, offset, type);
- offset += nbytes;
- for (i = 0; i < nbytes; i++)
- {
- printf("%2.2X", bytes[i]);
- checksum += bytes[i];
- }
- printf("%2.2X\n", ((-checksum) & 0xff));
- }
- while (nbytes != 0);
- exit (0);
- }
- ------------------------------------end-----------------------------------
-
- Ian Dall
-