🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.nsc.32k
Article #188

intelhex

#188
From: ian
Date: Thu, 31 May 1990 02:09
47 lines
1632 bytes
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
Technical Details
Message-ID: <9006010111.1815@munnari.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!zaphod.mps.ohio-state.edu!mips!daver!bungi.com!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!usc!zaphod.mps.ohio-state.edu!mips!daver!bungi.com!news
From: ian@sibyl.eleceng.ua.oz.au
Newsgroups: comp.sys.nsc.32k
Subject: intelhex
Message-ID: <9006010111.1815@munnari.oz.au>
Date: 31 May 90 02:09:32 GMT
Sender: news@daver.bungi.com
Lines: 47
Approved: news@daver.bungi.com