[f40a309] | 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 |
|
---|
[b28a12e] | 25 | #include "ram.h"
|
---|
[f40a309] | 26 |
|
---|
| 27 | #define PERLINE 16
|
---|
| 28 |
|
---|
| 29 | /*
|
---|
| 30 | =============================================================================
|
---|
| 31 | pipc() -- print if printable characters
|
---|
| 32 | =============================================================================
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[7258c6a] | 35 | static void pipc(int8_t chars[], int16_t length)
|
---|
[f40a309] | 36 | {
|
---|
[7258c6a] | 37 | int16_t i;
|
---|
[f40a309] | 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 |
|
---|
[e102943] | 52 | void mdump(int8_t *from, int8_t *to, int32_t start)
|
---|
[f40a309] | 53 | {
|
---|
[7258c6a] | 54 | int32_t i, ii;
|
---|
| 55 | int16_t j, jj, k;
|
---|
| 56 | int8_t c, chars[PERLINE];
|
---|
[f40a309] | 57 |
|
---|
| 58 | i = 0L;
|
---|
| 59 | ii = start;
|
---|
| 60 | j = 0;
|
---|
| 61 |
|
---|
[e102943] | 62 | if (from GT to)
|
---|
[f40a309] | 63 | return;
|
---|
| 64 |
|
---|
[e102943] | 65 | while (from LE to) {
|
---|
[f40a309] | 66 |
|
---|
[e102943] | 67 | c = *from++;
|
---|
[f40a309] | 68 |
|
---|
| 69 | if (! (i % PERLINE)) {
|
---|
| 70 |
|
---|
| 71 | if (i) {
|
---|
| 72 |
|
---|
| 73 | j=0;
|
---|
| 74 | printf(" ");
|
---|
| 75 | pipc(chars, PERLINE);
|
---|
| 76 | }
|
---|
[7848656] | 77 |
|
---|
[f40a309] | 78 | printf("\n%08lX:", ii);
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | ii++;
|
---|
| 82 | i++;
|
---|
| 83 |
|
---|
| 84 | printf(" %02.2X", (c & 0x00FF));
|
---|
| 85 | chars[j++] = c;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
[e102943] | 88 | if ((k = (int16_t)(i % PERLINE))) {
|
---|
[f40a309] | 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 |
|
---|
| 103 | char area[128];
|
---|
| 104 |
|
---|
| 105 | main()
|
---|
| 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
|
---|
[6262b5c] | 116 |
|
---|