summaryrefslogtreecommitdiff
path: root/avr/cmd_mem.c
diff options
context:
space:
mode:
authorLeo C2014-11-21 02:15:16 +0100
committerLeo C2014-11-21 02:15:16 +0100
commite39cd2a2822a410ba06d61657a467c8307daa35d (patch)
tree3d8207fb2fbb4ea6cebde1b6631da9df6767347f /avr/cmd_mem.c
parent05437fb4cdb907816a4fc3ffafa2617fcf33266a (diff)
downloadz180-stamp-e39cd2a2822a410ba06d61657a467c8307daa35d.zip
One dump_mem() for all memory types (avr eeprom and ram, z180 ram)
Diffstat (limited to 'avr/cmd_mem.c')
-rw-r--r--avr/cmd_mem.c61
1 files changed, 5 insertions, 56 deletions
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index 500b973..975cab4 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -38,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
@@ -139,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;