genraminit.c 440 Bytes
Newer Older
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
1 2 3 4 5
#include <stdio.h>
#include <stdlib.h>

main(int argc, char *argv[])
{
6 7 8 9 10 11 12 13
	if (argc < 3)
		return -1;
	FILE *f = fopen(argv[1], "rb");
	if (!f)
		return -1;
	unsigned char x[4];
	int i = 0;
	int n = atoi(argv[2]);
14

15 16 17 18 19
	while (!feof(f)) {
		fread(x, 1, 4, f);
		printf("write %x %02X%02X%02X%02X\n", i++, x[0], x[1], x[2],
		       x[3]);
	}
20

21 22 23 24 25
	for (; i < n;) {
		printf("write %x %02X%02X%02X%02X\n", i++, 0, 0, 0, 0);
	}
	fclose(f);
	return 0;
26
}