Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / arossupport / hexdump.c
blobdeeb51619a7b9c53f7c2a470e216a2d16824745d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Prints a hexdump of a memory region
6 Lang: english
7 */
9 #include <ctype.h>
10 #include <aros/debug.h>
12 /*****************************************************************************
14 NAME */
15 #include <proto/arossupport.h>
17 void hexdump (
19 /* SYNOPSIS */
20 const void * data,
21 IPTR offset,
22 ULONG count)
24 /* FUNCTION
25 Prints a hexdump of the data beginning at data. The format
26 is liks this:
28 xxxxxxxx: dddddddd dddddddd dddddddd dddddddd aaaaaaaaaaaaaaaa
30 Where x is the address (8 chars hex), dd is a data byte (2 chars
31 hex) and a is the ASCII representation of a data byte or "." if
32 the data byte is not printable.
34 INPUTS
35 data - Start here with the dump
36 offset - This offset is used as the address in the output. If
37 you give 0L here, then the first address will be
38 00000000. If you give (IPTR)data here, then the
39 first address will be the memory address of the data.
40 count - How many bytes to print.
42 RESULT
43 None.
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 HISTORY
56 05-12-96 digulla created
58 ******************************************************************************/
60 ULONG t, end;
61 int i;
63 end = (count + 15) & -16;
65 for (t=0; t<end; t++)
67 if ((t&15) == 0)
68 kprintf ("%08lx:", offset+t);
70 if ((t&3) == 0)
71 kprintf (" ");
73 if (t < count)
74 kprintf ("%02x", ((UBYTE *)data)[t]);
75 else
76 kprintf (" ");
78 if ((t&15) == 15)
80 kprintf (" ");
82 for (i=15; i>=0; i--)
84 if (isprint (((UBYTE *)data)[t-i]))
85 kprintf ("%c", ((UBYTE *)data)[t-i]);
86 else
87 kprintf (".");
90 kprintf ("\n");
93 } /* hexdump */