FreeCalypso > hg > freecalypso-tools
comparison target-utils/libcommon/cmd_memdump_human.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | 9214118ae941 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * This is a human-oriented memory dump command. The dump is given in | |
3 * both hex and ASCII, with readable spacing. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include "types.h" | |
8 | |
9 void | |
10 cmd_memdump_human(argbulk) | |
11 char *argbulk; | |
12 { | |
13 char *argv[3]; | |
14 u_long start, length; | |
15 u_long offset; | |
16 u_char intbuf[16]; | |
17 int i, c; | |
18 | |
19 if (parse_args(argbulk, 2, 2, argv, 0) < 0) | |
20 return; | |
21 if (parse_hexarg(argv[0], 8, &start) < 0) { | |
22 printf("ERROR: arg1 must be a valid 32-bit hex address\n"); | |
23 return; | |
24 } | |
25 if (parse_hexarg(argv[1], 8, &length) < 0) { | |
26 printf("ERROR: arg2 must be a valid 32-bit hex value (length)\n"); | |
27 return; | |
28 } | |
29 if (start & 0xF || length & 0xF) { | |
30 printf("ERROR: implementation limit: 16-byte alignment required\n"); | |
31 return; | |
32 } | |
33 for (offset = 0; offset < length; offset += 0x10) { | |
34 bcopy(start + offset, intbuf, 0x10); | |
35 printf("%08X: ", start + offset); | |
36 for (i = 0; i < 16; i++) { | |
37 printf("%02X ", intbuf[i]); | |
38 if ((i & 3) == 3) | |
39 putchar(' '); | |
40 } | |
41 for (i = 0; i < 16; i++) { | |
42 c = intbuf[i]; | |
43 if (c >= ' ' && c <= '~') | |
44 putchar(c); | |
45 else | |
46 putchar('.'); | |
47 } | |
48 putchar('\n'); | |
49 } | |
50 } |