From 279f6e0ad878742e9da4669d225dd2e0156d32af Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 17 Apr 2019 10:34:30 -0400 Subject: [PATCH] zasm: invert emulator io_write() handling This facilitates debugging. To know the value of `A` at any point, you can do `out (0), a`. The number of bytes in the output will be the value of `A`. --- apps/zasm/emul/glue.asm | 3 ++- apps/zasm/emul/zasm.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/zasm/emul/glue.asm b/apps/zasm/emul/glue.asm index 6fb1a95..edaa75e 100644 --- a/apps/zasm/emul/glue.asm +++ b/apps/zasm/emul/glue.asm @@ -18,7 +18,8 @@ init: call USER_CODE ; signal the emulator we're done ; BC contains the number of written bytes - ld a, b + ld a, c + ld c, b out (c), a halt diff --git a/apps/zasm/emul/zasm.c b/apps/zasm/emul/zasm.c index 3cb911a..180f1ef 100644 --- a/apps/zasm/emul/zasm.c +++ b/apps/zasm/emul/zasm.c @@ -32,7 +32,7 @@ static uint8_t io_read(int unused, uint16_t addr) static void io_write(int unused, uint16_t addr, uint8_t val) { - written = (val << 8) + (addr & 0xff); + written = ((addr & 0xff) << 8) + (val & 0xff); running = 0; }