source: buchla-68k/orig/GP/MDUMP.C@ 0170798

Last change on this file since 0170798 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 2.3 KB
Line 
1/*
2 =============================================================================
3 mdump.c -- Hexadecimal memory dump
4 Version 6 -- 1989-02-02 -- D.N. Lynx Crowe
5
6 Displays the contents of memory in hexadecimal.
7 If a byte is printable, it is also printed.
8
9 The format of the output is :
10
11 hex_add byte byte byte byte ... byte byte byte byte string
12
13 where:
14
15 hex_add Start address for that line in hex.
16 byte Representation of a byte in hex. Two characters
17 for each byte. PERLINE bytes per line.
18 string If the character is printable, it is printed,
19 otherwise a '.' is printed.
20 =============================================================================
21*/
22
23#define TESTER 0
24
25#include "stdio.h"
26#include "ctype.h"
27#include "stddefs.h"
28
29#define PERLINE 16
30
31/*
32
33*/
34
35/*
36 =============================================================================
37 prifp() -- print printable characters from a buffer
38 =============================================================================
39*/
40
41static
42prifp(chars, length)
43register char *chars;
44register int length;
45{
46 register int i, c;
47
48 for (i = 0; i < length; i++) {
49
50 c = 0x00FF & *chars++;
51
52 if (isascii(c) AND (isprint(c)))
53 printf("%c", c);
54 else
55 printf(".");
56 }
57}
58
59/*
60
61*/
62
63/*
64 =============================================================================
65 mdump() -- dump a memory area in hexadecimal
66 =============================================================================
67*/
68
69mdump(begin, end, start)
70register char *begin, *end;
71long start;
72{
73 register long i, ii;
74 int j, k;
75 char c, chars[PERLINE];
76
77 if (begin > end)
78 return;
79
80 i = 0L;
81 ii = start;
82 j = 0;
83
84 while (begin LE end) {
85
86 c = *begin++;
87
88 if (NOT (i % PERLINE)) {
89
90 if (i) {
91
92 j=0;
93 printf(" ");
94 prifp(chars, PERLINE);
95 }
96
97 printf("\n%08lX:", ii);
98 }
99
100 ii++;
101 i++;
102
103 printf(" %02.2X", (c & 0x00FF));
104 chars[j++] = c;
105 }
106
107/*
108
109*/
110 if (k = (i % PERLINE)) {
111
112 k = PERLINE - k;
113
114 for (ii = 0; ii < (3 * k); ++ii)
115 printf(" ");
116 }
117
118 printf(" ");
119 prifp(chars, PERLINE);
120 printf("\n");
121}
122
123/*
124
125*/
126
127#if TESTER
128
129char area[128];
130
131main()
132{
133 register short i;
134
135 for (i = 0; i < 128; i++)
136 area[i] = i + 128;
137
138 mdump(area, (area + 127), area);
139}
140
141#endif
Note: See TracBrowser for help on using the repository browser.