From 4327153ffd4bc1a3cb3e26dce388609f61b4389e Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 15 Jun 2019 15:50:27 -0400 Subject: [PATCH] zasm: fix include EOF detection That was an interesting bug. It didn't cause a problem in emulation, but in an RC2014 on an SD card, an include that didn't end with two newlines would cause an infinite loop. --- apps/zasm/io.asm | 7 +++---- kernel/fs.asm | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/zasm/io.asm b/apps/zasm/io.asm index c1e50f4..dff7c7a 100644 --- a/apps/zasm/io.asm +++ b/apps/zasm/io.asm @@ -80,8 +80,9 @@ ioGetC: ; We're in "include mode", read from FS ld ix, IO_INCLUDE_BLK call _blkGetC + jr nz, .includeEOF cp 0x0a ; newline - jr nz, .notNewline + ret nz ; not newline? nothing to do ; We have newline. Increase lineno and return (the rest of the ; processing below isn't needed. push hl @@ -90,9 +91,7 @@ ioGetC: pop hl ret -.notNewline: - or a ; cp 0 - ret nz ; not zero, all good +.includeEOF: ; We reached EOF. What we do depends on whether we're in Local Pass ; mode. Yes, I know, a bit hackish. Normally, we *should* be ; transparently getting of include mode and avoid meddling with global diff --git a/kernel/fs.asm b/kernel/fs.asm index 7a3637a..b3e28b2 100644 --- a/kernel/fs.asm +++ b/kernel/fs.asm @@ -484,6 +484,7 @@ fsGetC: push hl call fsPlaceH call fsblkGetC + cp a ; ensure Z pop hl ret