FireBirdLib - Topfield TMS PVR TAP Programming Library
DumpMemory.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <string.h>
3#include "libFireBird.h"
4
5void DumpMemory(byte* p, dword size, int BytesPerLine)
6{
8
9 byte *StartAddress = p;
10 int CollectedBytes, i;
11 char text[200], Header[20];
12 char s[255];
13 dword Remaining;
14
15 if(!p)
16 {
17 TAP_Print("0x00000000 NULL\n");
18
19 TRACEEXIT();
20 return;
21 }
22
23 s[0] = '\0';
24 text[0] = '\0';
25 CollectedBytes = 0;
26
27 TAP_SPrint(Header, "%p 0x%4.4lx: ", p, (dword)(p - StartAddress));
28
29 Remaining = size;
30 while(Remaining > 0)
31 {
32 TAP_SPrint(&s[strlen(s)], "%2.2x ", *p);
33 if((*p >= 0x20) && (*p <= 0x7e)) // && (*p != 0x25)
34 TAP_SPrint(&text[strlen(text)], "%c", *p);
35 else
36 TAP_SPrint(&text[strlen(text)], ".");
37
38 CollectedBytes++;
39 p++;
40 Remaining--;
41
42 if(CollectedBytes >= BytesPerLine)
43 {
44 TAP_SPrint(&s[strlen(s)], " %s\n", text);
45 TAP_Print(Header);
46 TAP_Print(s);
47 s[0] = '\0';
48 text[0] = '\0';
49 TAP_SPrint(Header, "%p 0x%4.4lx: ", p, (dword)(p - StartAddress));
50 CollectedBytes = 0;
51 }
52 }
53 if(strlen(s))
54 {
55 size %= BytesPerLine;
56 if(size)
57 {
58 size = BytesPerLine - size;
59 for(i = 0; i < (int)size; i++)
60 strcat(s, " ");
61 }
62
63 TAP_SPrint(&s[strlen(s)], " %s\n", text);
64 TAP_Print(Header);
65 TAP_Print(s);
66 }
67
68 TRACEEXIT();
69}
void DumpMemory(byte *p, dword size, int BytesPerLine)
Definition: DumpMemory.c:5
#define TAP_Print
Definition: libFireBird.h:181
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243