5
int main(int argc, char *argv[]) {
7
size_t count = 0, total = 0;
8
int offset = 0, toread = 1, toskip = 0;
12
if ((argc != 4)&&(argc != 7)) {
13
printf("Usage: %s <file> <dwords> <value> [offset_dwords read_dwords skip_dwords] \n", argv[0]);
17
FILE *f = fopen(argv[1], "r");
19
printf("Can't open %s\n", argv[1]);
25
printf("Can't parse size %s\n", argv[2]);
29
if (sscanf(argv[3], "%x", &value) != 1) {
30
printf("Can't parse register %s\n", argv[3]);
34
buf = malloc(size * sizeof(uint32_t));
36
printf("Can't allocate %lu bytes of memory\n", size * sizeof(uint32_t));
41
offset = atoi(argv[4]);
42
toread = atoi(argv[5]);
43
toskip = atoi(argv[6]);
47
num = fread(buf, 4, size, f);
49
printf("Only %lu of %lu dwords in the file\n", num, size);
54
for (i = offset; i < size; i += toskip) {
55
for (j = 0; j < toread; j++, i++) {
57
if (buf[i] != value) {
64
printf("%lu of %lu is wrong\n", count, total);