Forum
Isqrt.bas (*solved*) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Isqrt.bas (*solved*) (/showthread.php?tid=425)



Isqrt.bas (*solved*) - slenkar - 02-14-2012

When I try to use Isqrt.bas it says:

ISqrt.bas:125: Error: illegal preprocessor character '$'


Re: Isqrt.bas - britlion - 02-14-2012

slenkar Wrote:When I try to use Isqrt.bas it says:

ISqrt.bas:125: Error: illegal preprocessor character '$'

Um. I wrote that piece. I'd better look.


Ah. I'm calling this a compiler bug. It used to compile that. The current version doesn't.

The code uses "jr nc,$+3" to mean "jump to three bytes forward from here" - $ should mean "current location", and the compiler didn't blink with this some versions ago.

Here's a fix, replacing it with a label:

sqrtLFsqrt16loop:
sbc hl,de ; IF speed is critical, and you don't mind spending the extra bytes,
; you could unroll this loop 7 times instead of DJNZ.

; deprecated because of issues - jr nc,$+3 (note that if you unroll this loop, you'll need 7 labels for the jumps the other way!)
jr nc,sqrtLFsqrthop1
add hl,de

sqrtLFsqrthop1:
ccf
rl d
rla
adc hl,hl
rla
adc hl,hl
DJNZ sqrtLFsqrt16loop


However, as I noted in the comment, this is a pain if you decided to unroll the loop for maximum speed - you'd need 7 labels for the jumps!

Anyway, I've updated the copy in the wiki, to make this one go away.


Boriel, how did jr $+3 suddenly stop compiling?! Smile


Re: Isqrt.bas - boriel - 02-14-2012

Hmmm.
This is obviouly a bug.
I need to trace back to see in which version it was introduced. :x
Anyway, the fix is easy, I guess. :roll:


Re: Isqrt.bas - boriel - 02-18-2012

It was another bug in the preprocessor (that changed some revisions before, to allow powerful macros).
It was a simple fix. Please, update and check, and tell me if it works:!:
I see you updated iSQRT.bas in the Wiki, but now the old version should also compile too.


Re: Isqrt.bas - boriel - 02-18-2012

Update: Forgot to mention, 1.2.9-s778 is available, as always, in the download page: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Archive#Latest_Development_Version">http://www.boriel.com/wiki/en/index.php ... nt_Version</a><!-- m -->