From 6aa53afabc053058aef27f32c6f01d3732822ce9 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 12 May 2019 08:49:59 -0400 Subject: [PATCH] zasm: add memdump mode --- tools/emul/zasm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/emul/zasm.c b/tools/emul/zasm.c index 14b833b..3785be3 100644 --- a/tools/emul/zasm.c +++ b/tools/emul/zasm.c @@ -31,6 +31,9 @@ // Other consts #define STDIN_BUFSIZE 0x8000 +// When defined, we dump memory instead of dumping expected stdout +//#define MEMDUMP + static Z80Context cpu; static uint8_t mem[0x10000]; // STDIN buffer, allows us to seek and tell @@ -57,7 +60,10 @@ static void io_write(int unused, uint16_t addr, uint8_t val) { addr &= 0xff; if (addr == STDIO_PORT) { +// When mem-dumping, we don't output regular stuff. +#ifndef MEMDUMP putchar(val); +#endif } else if (addr == STDIN_REWIND) { inpt_ptr = 0; } else { @@ -107,6 +113,11 @@ int main() while (!cpu.halted) { Z80Execute(&cpu); } +#ifdef MEMDUMP + for (int i=0; i<0x10000; i++) { + putchar(mem[i]); + } +#endif fflush(stdout); return 0; }