-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhexdump.c
53 lines (39 loc) · 809 Bytes
/
hexdump.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// $Id$
// $Revision$
// $Date$
// $Author$
// $HeadURL$
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include "m8cdis.h"
#include "hexdump.h"
//
//
//
int hexdumpDisplay (unsigned char *memory, int memorySize)
{
int i;
printf ("Dump of memory loaded from hex file\n");
for (i = 0; i < memorySize; i += 16)
{
unsigned char *p;
int j;
int l;
printf (" %04xh: ", i);
l = (((memorySize - i) < 16) ? (memorySize - i) : 16);
for (p = &memory [i], j = 0; j < l; j++, p++)
printf ("%02x ", *p);
for (j = 0; j < 16 - l; j++)
printf (" ");
printf (" ");
for (p = &memory [i], j = 0; j < l; j++, p++)
printf ("%c", isprint (*p) ? *p : '.');
printf ("\n");
}
printf ("\n");
return 1;
}