source: buchla-68k/iolib/mdump.c@ e877e55

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

Zero redundant declarations.

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