]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/cmd_mem.c
One dump_mem() for all memory types (avr eeprom and ram, z180 ram)
[z180-stamp.git] / avr / cmd_mem.c
index 66dc88f355d9b4f1f918a82b873552d77a15e911..975cab4fd965e4778b4f81d9c76fe690e6157d2a 100644 (file)
@@ -14,7 +14,6 @@
 #include "common.h"
 #include <stdlib.h>
 #include <ctype.h>
-#include <avr/pgmspace.h>
 
 #include "command.h"
 #include "cli_readline.h"
@@ -39,66 +38,15 @@ static      uint32_t        base_address = 0;
 
 /*--------------------------------------------------------------------------*/
 
-int z180_dump_mem(uint32_t startaddr, uint32_t len, const char *title)
-{
-       uint8_t buf[16];
-       uint8_t llen = 16;
-       uint8_t pre = startaddr % 16;
-       uint32_t addr = startaddr & ~0x0f;
-       len += pre;
-       uint8_t i;
-
-       if (title && *title)
-               printf_P(PSTR("%s\n"),title);
-
-       while (len) {
-               if (len < 16)
-                       llen = len;
 
+void z180_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
+{
                z80_bus_cmd(Request);
-               for (i = pre; i < llen; i++)
-                       buf[i] = z80_read(addr + i);
+               while (count--)
+                       *buf++ = z80_read(addr++);
                z80_bus_cmd(Release);
-
-               printf_P(PSTR("%.5lx:"), addr);
-#if 0
-               print_blanks(3 * pre);
-
-               /* Print hex values */
-               for (i = pre; i < llen; i++)
-                       printf_P(PSTR(" %.2x"), buf[i]);
-#else
-               for (i = 0; i < llen; i++) {
-                       if ((i % 8) == 0)
-                               putchar(' ');
-                       if (i < pre)
-                               printf_P(PSTR(".. "));
-                       else
-                               printf_P(PSTR("%.2x "), buf[i]);
-               }
-#endif
-               /* fill line with whitespace for nice ASCII print */
-#if 1
-               print_blanks(3 * (16u - i) + (16u-i)/8 + 1 + pre);
-#else
-
-#endif
-               /* Print data in ASCII characters */
-               for (i = pre; i < llen; i++)
-                       printf_P(PSTR("%c"), isprint(buf[i]) ? buf[i] : '.');
-               putchar('\n');
-
-               pre = 0;
-               addr += 16;
-               len -= llen;
-
-               if (ctrlc())
-                       return -1;
-       }
-       return 0;
 }
 
-
 /*--------------------------------------------------------------------------*/
 
 /* Memory Display
@@ -140,7 +88,7 @@ command_ret_t do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
        }
 
        /* Print the lines. */
-       z180_dump_mem(addr, length, NULL);
+       dump_mem(addr, length, z180_read_buf, NULL);
 
        dp_last_addr = addr + length;
        dp_last_length = length;