comparison libcommon/hexdump.c @ 9:c9ef9e91dd8e

new libcommon, initial version
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 06:55:38 +0000
parents
children
comparison
equal deleted inserted replaced
8:34bbb0585cab 9:c9ef9e91dd8e
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include "simresp.h"
4
5 display_sim_resp_in_hex(outf)
6 FILE *outf;
7 {
8 unsigned off, cc, n, c;
9
10 for (off = 0; off < sim_resp_data_len; off += cc) {
11 fprintf(outf, "%02X:", off);
12 cc = 16;
13 if (sim_resp_data_len - off < cc)
14 cc = sim_resp_data_len - off;
15 for (n = 0; n < 16; n++) {
16 if (n == 0 || n == 8)
17 putc(' ', outf);
18 putc(' ', outf);
19 if (n < cc)
20 fprintf(outf, "%02X", sim_resp_data[off + n]);
21 else {
22 putc(' ', outf);
23 putc(' ', outf);
24 }
25 }
26 putc(' ', outf);
27 putc(' ', outf);
28 for (n = 0; n < cc; n++) {
29 c = sim_resp_data[off + n];
30 if (c < 0x20 || c > 0x7E)
31 c = '.';
32 putc(c, outf);
33 }
34 putc('\n', outf);
35 }
36 return(0);
37 }
38
39 cmd_sim_resp(argc, argv, outf)
40 char **argv;
41 FILE *outf;
42 {
43 return display_sim_resp_in_hex(outf);
44 }