source: buchla-68k/orig/IOLIB/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
RevLine 
[3ae31e9]1/*
2 =============================================================================
3 mdump.c -- Hexadecimal memory dump
4 Version 5 -- 1987-10-29 -- 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 "stddefs.h"
26#include "stdio.h"
27#include "ctype.h"
28
29#define PERLINE 16
30
31/*
32
33*/
34
35/*
36 =============================================================================
37 pipc() -- print if printable characters
38 =============================================================================
39*/
40
41static
42pipc(chars, length)
43char chars[];
44int length;
45{
46 int i;
47
48 for (i = 0; i < length; i++)
49 if (isascii(0x00FF & chars[i]) AND (isprint(0x00FF & chars[i])))
50 printf("%c", chars[i]);
51 else
52 printf(".");
53}
54
55/*
56
57*/
58
59/*
60 =============================================================================
61 mdump() -- dump a memory area in hexadecimal
62 =============================================================================
63*/
64
65mdump(begin, end, start)
66char *begin, *end;
67long start;
68{
69 long i, ii;
70 int j, jj, k;
71 char c, chars[PERLINE];
72
73 i = 0L;
74 ii = start;
75 j = 0;
76
77 if (begin GT end)
78 return;
79
80 while (begin LE end) {
81
82 c = *begin++;
83
84 if (! (i % PERLINE)) {
85
86 if (i) {
87
88 j=0;
89 printf(" ");
90 pipc(chars, PERLINE);
91 }
92
93 printf("\n%08lX:", ii);
94 }
95
96 ii++;
97 i++;
98
99 printf(" %02.2X", (c & 0x00FF));
100 chars[j++] = c;
101 }
102
103 if (k = (i % PERLINE)) {
104
105 k = PERLINE - k;
106
107 for (jj = 0; jj < (3 * k); ++jj)
108 printf(" ");
109 }
110
111 printf(" ");
112 pipc(chars, PERLINE);
113 printf("\n");
114}
115
116/*
117
118*/
119
120#if TESTER
121
122char area[128];
123
124main()
125{
126 register short i;
127
128 for (i = 0; i < 128; i++)
129 area[i] = i + 128;
130
131 mdump(area, (area + 127), area);
132}
133
134#endif
Note: See TracBrowser for help on using the repository browser.