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.
This commit is contained in:
Virgil Dupras 2019-06-15 15:50:27 -04:00
parent 92a04f4627
commit 4327153ffd
2 changed files with 4 additions and 4 deletions

View File

@ -80,8 +80,9 @@ ioGetC:
; We're in "include mode", read from FS ; We're in "include mode", read from FS
ld ix, IO_INCLUDE_BLK ld ix, IO_INCLUDE_BLK
call _blkGetC call _blkGetC
jr nz, .includeEOF
cp 0x0a ; newline cp 0x0a ; newline
jr nz, .notNewline ret nz ; not newline? nothing to do
; We have newline. Increase lineno and return (the rest of the ; We have newline. Increase lineno and return (the rest of the
; processing below isn't needed. ; processing below isn't needed.
push hl push hl
@ -90,9 +91,7 @@ ioGetC:
pop hl pop hl
ret ret
.notNewline: .includeEOF:
or a ; cp 0
ret nz ; not zero, all good
; We reached EOF. What we do depends on whether we're in Local Pass ; 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 ; mode. Yes, I know, a bit hackish. Normally, we *should* be
; transparently getting of include mode and avoid meddling with global ; transparently getting of include mode and avoid meddling with global

View File

@ -484,6 +484,7 @@ fsGetC:
push hl push hl
call fsPlaceH call fsPlaceH
call fsblkGetC call fsblkGetC
cp a ; ensure Z
pop hl pop hl
ret ret