add another arch specific function for IRQ handling.
[AROS.git] / compiler / arossupport / hexdump.c
blobff733798356272958e074840f66505480ebf60e7
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Prints a hexdump of a memory region
6 Lang: english
7 */
9 #include <aros/debug.h>
11 /*****************************************************************************
13 NAME */
14 #include <proto/arossupport.h>
16 void hexdump (
18 /* SYNOPSIS */
19 const void * data,
20 IPTR offset,
21 ULONG count)
23 /* FUNCTION
24 Prints a hexdump of the data beginning at 'data'. The format
25 is like this:
27 xxxxxxxx: dddddddd dddddddd dddddddd dddddddd aaaaaaaaaaaaaaaa
29 Where x is the address (8 chars hex), dd is a data byte (2 chars
30 hex) and a is the ASCII representation of a data byte or "." if
31 the data byte is not printable.
33 INPUTS
34 data - Start here with the dump
35 offset - This offset is used as the address in the output. If
36 you give 0L here, then the first address will be
37 00000000. If you give (IPTR)data here, then the
38 first address will be the memory address of the data.
39 count - How many bytes to print.
41 RESULT
42 None.
44 NOTES
46 EXAMPLE
48 BUGS
50 SEE ALSO
52 INTERNALS
54 ******************************************************************************/
56 ULONG t, end;
57 int i;
59 end = (count + 15) & -16;
61 for (t=0; t<end; t++)
63 if ((t&15) == 0)
64 kprintf ("%p:", offset+t);
66 if ((t&3) == 0)
67 kprintf (" ");
69 if (t < count)
70 kprintf ("%02x", ((UBYTE *)data)[t]);
71 else
72 kprintf (" ");
74 if ((t&15) == 15)
76 kprintf (" ");
78 for (i=15; i>=0; i--)
80 UBYTE c = ((UBYTE *)data)[t-i];
83 * isprint() introduces dependency on stdc.library, which
84 * prevents using this function from within KS code.
86 if ((c > 0x1F) && (c < 0x7E))
87 kprintf ("%c", c);
88 else
89 kprintf (".");
92 kprintf ("\n");
95 } /* hexdump */