Category : Miscellaneous Language Source Code
Archive   : HACKROM.ZIP
Filename : CHKSUM.C

 
Output of file : CHKSUM.C contained in archive : HACKROM.ZIP
/* Ibm rom checksum routine written by Allan Teo 5 may 1987*/

#include
#include
main(argc,argv)
int argc;
char **argv;
{
int c1, c;
char *s;
unsigned char x,i;
FILE *infile,*outfile;
if (argc != 3)
{
printf("Argument error\n");
printf("Usage: Chksum inputfile outputfile\n");
printf("This program produces a file with the proper checksum\n");
printf("You can then program that file to an eprom.. Wait Calculating\n");

exit(0);
}
argv++; /* get filename */
if ((infile = fopen(*argv, "rb")) == NULL)
{
perror("Can't open input file ",argv);
exit(0);
}
s = *argv;
argv++;

if (!strcmp(s,*argv))
{
printf("Input and Output files cannot be the same\n");
exit(0);
}
outfile=fopen(*argv,"wb");
x=0;
/* Buffer for unwanted last byte of file */
c1 = getc(infile);
while (((c = getc(infile)) != EOF))
{
x = x +c1;
putc(c1,outfile);
c1 = c;

}
i = x + c1;
c = (~x)+1;
putc(c,outfile);
printf("\nChecksum Byte should be %0x\n", c );
printf("Current Checksum Byte is %0x\n",c1);
printf("It should be at the last location in the ROM FILE\n");
printf("Current Checksum is %0x <- This byte should be 0 to be correct\n",i);
fclose(infile); fclose(outfile);
printf("Changes written to %s\n",*argv);

exit(0);
}


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : HACKROM.ZIP
Filename : CHKSUM.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/