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

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

No more warnings in iolib.

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