FreeCalypso > hg > freecalypso-sw
comparison loadtools/ltmisc.c @ 71:0c1480317c18
dieid via fc-loadtool: added ability to save to a file
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 26 Jul 2013 18:11:41 +0000 |
parents | e2698daf40d1 |
children |
comparison
equal
deleted
inserted
replaced
70:e2698daf40d1 | 71:0c1480317c18 |
---|---|
5 | 5 |
6 #include <sys/types.h> | 6 #include <sys/types.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 cmd_dieid() | 10 cmd_dieid(argc, argv) |
11 char **argv; | |
11 { | 12 { |
12 uint32_t addr; | 13 static uint32_t addrs[4] = {0xFFFEF010, 0xFFFEF012, 0xFFFEF014, |
13 uint16_t data; | 14 0xFFFEF016}; |
14 int stat; | 15 uint16_t data[4]; |
16 int i, stat; | |
17 FILE *of; | |
15 | 18 |
16 for (addr = 0xFFFEF010; addr <= 0xFFFEF016; addr += 2) { | 19 for (i = 0; i < 4; i++) { |
17 stat = do_r16(addr, &data); | 20 stat = do_r16(addrs[i], data + i); |
18 if (stat) | 21 if (stat) |
19 return(stat); | 22 return(stat); |
20 printf("%08lX: %04X\n", (u_long)addr, (int)data); | 23 printf("%08lX: %04X\n", (u_long)addrs[i], (int)data[i]); |
21 } | 24 } |
25 if (argc < 2) | |
26 return(0); | |
27 of = fopen(argv[1], "w"); | |
28 if (!of) { | |
29 perror(argv[1]); | |
30 return(-1); | |
31 } | |
32 for (i = 0; i < 4; i++) | |
33 fprintf(of, "%08lX: %04X\n", (u_long)addrs[i], (int)data[i]); | |
34 fclose(of); | |
35 printf("Saved to %s\n", argv[1]); | |
22 return(0); | 36 return(0); |
23 } | 37 } |