view miscprog/pircksum.c @ 402:1b83d07576bf

compal/boot/c123-boot.disasm: missed vector branch at 0x1c
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jan 2023 00:06:59 +0000
parents bf4286245c74
children
line wrap: on
line source

/*
 * This program has been used to verify and refine my understanding of the
 * checksum scheme used for Pirelli's RF calibration data.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

main(argc, argv)
	char **argv;
{
	FILE *f;
	u_long offset, len;
	u_char inb, accum;

	if (argc != 4) {
		fprintf(stderr, "usage: %s fact.bin offset len\n", argv[0]);
		exit(1);
	}
	f = fopen(argv[1], "r");
	if (!f) {
		perror(argv[1]);
		exit(1);
	}
	offset = strtoul(argv[2], 0, 16);
	len = strtoul(argv[3], 0, 16);
	fseek(f, offset, SEEK_SET);
	for (accum = 0; len; len--) {
		inb = getc(f);
		accum += inb;
	}
	inb = getc(f);
	printf("Computed cksum %02X, following byte %02X\n", accum, inb);
	exit(0);
}